Skip to content

Commit c19a996

Browse files
committed
Refactor code and enhance maintainability.
1 parent fc46167 commit c19a996

29 files changed

Lines changed: 2286 additions & 2007 deletions

code/backend/app.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import traceback
88
import uuid
99
from datetime import datetime, timezone
10-
from typing import Any, Dict, Tuple
10+
from typing import Any, Dict, Optional, Tuple
1111

1212
import compat_stubs # noqa: F401 - must be first
1313

@@ -126,6 +126,21 @@ def before_request() -> None:
126126
f"[{g.request_id}] {request.method} {request.url} - IP: {request.remote_addr}"
127127
)
128128

129+
def _safe_jwt_identity() -> Optional[str]:
130+
"""Best-effort JWT identity lookup for audit logging.
131+
132+
get_jwt_identity() raises if the current request's JWT was never
133+
successfully verified (missing, malformed, or expired token) - which
134+
is expected for anonymous or failed-auth requests, not an error
135+
worth logging. Swallowing just that lookup (rather than the whole
136+
audit_service.log_api_request(...) call, as before) keeps the audit
137+
trail intact for every request, including failed-auth ones.
138+
"""
139+
try:
140+
return get_jwt_identity()
141+
except Exception:
142+
return None
143+
129144
@app.after_request
130145
def after_request(response: Any) -> Any:
131146
if hasattr(g, "start_time"):
@@ -143,12 +158,7 @@ def after_request(response: Any) -> Any:
143158
response_time_ms=int(response_time),
144159
ip_address=request.remote_addr,
145160
user_agent=request.headers.get("User-Agent"),
146-
user_id=(
147-
get_jwt_identity()
148-
if hasattr(request, "headers")
149-
and "Authorization" in request.headers
150-
else None
151-
),
161+
user_id=_safe_jwt_identity(),
152162
)
153163
except Exception as e:
154164
app.logger.error(f"Failed to create audit log: {e}")

web-frontend/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
<meta charset="utf-8" />
55
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<meta name="theme-color" content="#3f51b5" />
7+
<meta name="theme-color" content="#0D1220" />
88
<meta
99
name="description"
10-
content="BlockScore - Decentralized Credit Scoring System"
10+
content="BlockScore - AI-native credit scoring built on your on-chain and financial activity"
1111
/>
1212
<link rel="apple-touch-icon" href="/logo192.png" />
1313
<link rel="manifest" href="/manifest.json" />
1414
<link rel="preconnect" href="https://fonts.googleapis.com" />
1515
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1616
<link
17-
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Roboto:wght@300;400;500;700&family=Roboto+Mono&display=swap"
17+
href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap"
1818
rel="stylesheet"
1919
/>
2020
<title>BlockScore | Decentralized Credit Scoring</title>

web-frontend/public/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"short_name": "BlockScore",
3-
"name": "BlockScore - Decentralized Credit Scoring",
3+
"name": "BlockScore - AI-native Credit Scoring",
44
"icons": [
55
{
66
"src": "favicon.ico",
@@ -20,6 +20,6 @@
2020
],
2121
"start_url": ".",
2222
"display": "standalone",
23-
"theme_color": "#3f51b5",
24-
"background_color": "#f5f5f5"
23+
"theme_color": "#0D1220",
24+
"background_color": "#F5F6FA"
2525
}

web-frontend/src/components/Dashboard.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

web-frontend/src/components/LoanCalculator.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)