How azmirshah1/goaura-dashboard works
1. Overall shape
GoAura is a two-tier application: a Python/FastAPI backend that owns scoring, persistence, and TNG data handling, and a Next.js frontend that presents profiles, ingest flows, and score explainability views. PostgreSQL is the system of record.
2. Primary backend boundary
The backend is the core domain layer. backend/app/main.py wires the app and registers routers from api/. The API is split by concern:
- ingest for manual profile creation and scoring
- sync for TNG transaction synchronization
- admin for profile browsing and deletion
3. Data model and persistence
The database stores two main entities:
- user_profiles for identity, persona/category metadata, and behavioral metrics
- aura_scores for the computed score, tiering, breakdown JSON, and advance-related outputs
SQLAlchemy is used as the ORM, with database.py managing the engine and sessions. Tables are created automatically on startup.
4. Scoring subsystem
The scoring logic is isolated under backend/app/scoring/. engine.py orchestrates the calculation, while the dimension modules split the model into distinct signals:
- capacity.py
- stability.py
- willingness.py
Additional modules modify or constrain the outcome:
- repayment.py for repayment-history effects
- cold_start.py for thin-data adjustments
- compliance.py for blacklist / BNM-style policy gating
- advance.py for Aura Advance calculation
- explainer.py for human-readable justification
5. Scoring flow
The main flow is: profile or transaction data enters the backend → behavioral metrics are derived or supplied → scoring engine computes a score and tier → explanation and advance output are stored alongside the profile. This makes scoring a backend-owned, repeatable transformation rather than a frontend calculation.
6. TNG integration layer
The tng/ package is the ingestion boundary for TNG eWallet data. It has three pieces:
- client.py for fetching TNG data, including mock mode
- parser.py for CSV statement uploads
- transformer.py for converting raw transactions into behavioral metrics used by scoring
This layer isolates external data shape from the scoring model.
7. External service dependency
TNG is the only domain-specific external system visible in the repo. The backend is configured for mock synthetic data by default and can be pointed at live TNG OAuth/API credentials in production. That means the same ingestion path supports demo mode and real integration without changing the core scoring engine.
8. Frontend responsibilities
The frontend is a Next.js app that consumes the backend API and renders the user-facing workflow: dashboard, profile list/detail, ingest form, TNG connect screen, and scoring explainers. It does not appear to own business logic; its role is presentation and API orchestration.
9. Frontend navigation surfaces
The app routes show the main product surfaces:
- /profiles and /profiles/[id] for browsing score records
- /ingest for manual intake
- /connect for TNG connection
- /scoring and /gai for score/index education and explanation
Shared UI components such as badges, charts, and signal rows visualize the score breakdown and tiering.
10. API consumption pattern
frontend/src/lib/api.ts likely centralizes calls to the FastAPI backend via NEXT_PUBLIC_API_URL. The architecture therefore uses a clean client/server split: browser UI calls backend endpoints directly, with the backend handling all data persistence and score computation.
11. Operational packaging
Docker Compose is the main runtime boundary. It runs PostgreSQL and the backend together for local development, with an optional production profile that also containerizes the frontend. The backend listens on port 8000 and PostgreSQL is exposed on 5433 in the dev setup.
12. Documentation and product context
The docs/ folder contains the scoring algorithm and product requirements, which suggests the scoring rules are an explicit domain artifact rather than incidental code. The repository is structured to support explainability: algorithm docs, score explainer output, and frontend visualizations all reinforce the same score computation path.
13. What to draw in an architecture diagram
The key boxes are:
- Browser / Next.js frontend
- FastAPI backend API
- Scoring engine subsystem
- TNG ingestion subsystem
- PostgreSQL database
- External TNG API / CSV input
The critical arrows are: frontend → backend API; backend ingest/sync → TNG data layer; scoring engine → database writes; frontend → backend for profile retrieval and explanations.
Main entry points: engine.py Scoring Engine · api API Routes · scoring Signal Models · tng TNG Layer
Components 24
Frontend
Next.js presentation layer and UI composition
- Next.js App · Routes and page shells for dashboard, profiles, ingest, connect, and scoring views
frontend/src/app - UI Components · Shared badges, charts, panels, and layout helpers used across the frontend
frontend/src/components - API Client · Centralized backend request layer for browser-to-API communication
frontend/src/lib/api.ts
Backend
FastAPI domain API, scoring, and persistence
- FastAPI App · Application entrypoint that wires routers and startup behavior
backend/app/main.py - API Routes · Profile ingest, sync, and admin endpoints
backend/app/api - Ingest API · Manual profile creation and scoring submission flow
backend/app/api/ingest.py - Sync API · TNG transaction synchronization entrypoints
backend/app/api/sync.py - Admin API · Profile browsing and deletion endpoints
backend/app/api/admin.py - Data Models · SQLAlchemy entities for profiles and scores
backend/app/models - Database Layer · Engine and session management for PostgreSQL access
backend/app/database.py - Scoring Engine · Coordinates score calculation, tiering, and stored outputs
backend/app/scoring/engine.py - Signal Models · Core scoring dimensions for capacity, stability, and willingness
backend/app/scoring - Capacity · Capacity signal contribution to the score
backend/app/scoring/capacity.py - Stability · Stability signal contribution to the score
backend/app/scoring/stability.py - Willingness · Willingness signal contribution to the score
backend/app/scoring/willingness.py - Adjusters · Policy, thin-data, repayment, and product-specific score adjustments
backend/app/scoring
Data & External
Database and inbound TNG inputs
- TNG Layer · Fetches, parses, and transforms TNG data into behavioral metrics
backend/app/tng - TNG Client · Fetches live or mock TNG data
backend/app/tng/client.py - CSV Parser · Parses uploaded TNG CSV statements
backend/app/tng/parser.py - Transformer · Converts raw transactions into scoring metrics
backend/app/tng/transformer.py - PostgreSQL · System of record for profiles, scores, and derived outputs
Runtime
Containerized local deployment
- Docker Compose · Local runtime boundary for backend, frontend, and database
docker-compose.yml
Other components
- Browser · End-user surface that consumes the web app
- Docs · Algorithm and product requirements that define the scoring model
docs
Connections 29
- Browser → Next.js App: uses · Users interact with the web UI through the Next.js app
- Next.js App → UI Components: renders · Pages compose shared visual components
- Next.js App → API Client: calls · Frontend routes request data through a centralized API client
- API Client → FastAPI App: HTTP · Browser-side requests target the FastAPI backend
- FastAPI App → API Routes: registers · Entrypoint mounts the domain routers
- API Routes → Ingest API: exposes · Manual ingest and scoring endpoints
- API Routes → Sync API: exposes · TNG sync endpoints
- API Routes → Admin API: exposes · Profile administration endpoints
- Ingest API → Scoring Engine: scores · Manual profile input flows into the scoring pipeline
- Sync API → TNG Layer: imports · TNG synchronization uses the ingestion adapter
- Ingest API → Data Models: persists · Ingested profiles and scores are stored via ORM models
- Sync API → Data Models: persists · Synced behavioral data updates stored entities
- Admin API → Data Models: queries · Admin browsing and deletion operate on stored records
- Data Models → Database Layer: uses · ORM models are backed by the database session layer
- Database Layer → PostgreSQL: writes · Persistence targets PostgreSQL
- Scoring Engine → Signal Models: combines · Engine orchestrates the core signal dimensions
- Signal Models → Capacity: includes · Capacity model component
- Signal Models → Stability: includes · Stability model component
- Signal Models → Willingness: includes · Willingness model component
- Scoring Engine → Adjusters: applies · Outcome modifiers and policy gates shape the final score
- Adjusters → PostgreSQL: stores · Computed score output and breakdown are written alongside profiles
- TNG Layer → TNG Client: fetches · Client handles live or mock TNG retrieval
- TNG Layer → CSV Parser: parses · CSV statements are converted into structured inputs
- TNG Layer → Transformer: transforms · Raw transactions become behavioral metrics
- Transformer → Scoring Engine: feeds · Derived metrics feed the scoring calculation
- Docs → Scoring Engine: defines · Algorithm docs describe the scoring rules and explainability model
- Docker Compose → FastAPI App: runs · Compose starts the backend service
- Docker Compose → Next.js App: runs · Compose can include the frontend service
- Docker Compose → PostgreSQL: runs · Compose provisions the database