# azmirshah1/goaura-dashboard architecture

> Architecture diagram of the GitHub repository azmirshah1/goaura-dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azmirshah1/goaura-dashboard
- Repository: https://github.com/azmirshah1/goaura-dashboard

## Overview

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: [`backend/app/scoring/engine.py`](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/engine.py) (Scoring Engine), [`backend/app/api`](https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/api) (API Routes), [`backend/app/scoring`](https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/scoring) (Signal Models), [`backend/app/tng`](https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/tng) (TNG Layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_next_app["Next.js App<br/>web frontend"]
  node_ui_components["UI Components<br/>presentational components"]
  node_api_client["API Client<br/>frontend service<br/>[api.ts]"]
end

subgraph group_backend["Backend"]
  node_main_api["FastAPI App<br/>backend api<br/>[main.py]"]
  node_api_routes["API Routes<br/>http routers"]
  node_ingest_api["Ingest API<br/>ingest endpoints<br/>[ingest.py]"]
  node_sync_api["Sync API<br/>sync endpoints<br/>[sync.py]"]
  node_admin_api["Admin API<br/>admin endpoints<br/>[admin.py]"]
  node_models["Data Models<br/>orm models"]
  node_database[("Database Layer<br/>orm/session<br/>[database.py]")]
  node_scoring_engine["Scoring Engine<br/>scoring orchestrator<br/>[engine.py]"]
  node_dimensions["Signal Models<br/>scoring dimensions"]
  node_capacity["Capacity<br/>signal model<br/>[capacity.py]"]
  node_stability["Stability<br/>signal model<br/>[stability.py]"]
  node_willingness["Willingness<br/>signal model<br/>[willingness.py]"]
  node_adjusters["Adjusters<br/>score modifiers"]
end

subgraph group_data["Data & External"]
  node_tng_ingest["TNG Layer<br/>ingestion adapter"]
  node_tng_client["TNG Client<br/>external connector<br/>[client.py]"]
  node_tng_parser["CSV Parser<br/>statement parser<br/>[parser.py]"]
  node_tng_transformer["Transformer<br/>metric transform<br/>[transformer.py]"]
  node_postgres[("PostgreSQL<br/>system database")]
end

subgraph group_ops["Runtime"]
  node_docker{{"Docker Compose<br/>runtime<br/>[docker-compose.yml]"}}
end

node_browser(("Browser<br/>user client"))
node_docs["Docs"]

node_browser -->|"uses"| node_next_app
node_next_app -->|"renders"| node_ui_components
node_next_app -->|"calls"| node_api_client
node_api_client -->|"HTTP"| node_main_api
node_main_api -->|"registers"| node_api_routes
node_api_routes -->|"exposes"| node_ingest_api
node_api_routes -->|"exposes"| node_sync_api
node_api_routes -->|"exposes"| node_admin_api
node_ingest_api -->|"scores"| node_scoring_engine
node_sync_api -->|"imports"| node_tng_ingest
node_ingest_api -->|"persists"| node_models
node_sync_api -->|"persists"| node_models
node_admin_api -->|"queries"| node_models
node_models -->|"uses"| node_database
node_database -->|"writes"| node_postgres
node_scoring_engine -->|"combines"| node_dimensions
node_dimensions -->|"includes"| node_capacity
node_dimensions -->|"includes"| node_stability
node_dimensions -->|"includes"| node_willingness
node_scoring_engine -->|"applies"| node_adjusters
node_adjusters -->|"stores"| node_postgres
node_tng_ingest -->|"fetches"| node_tng_client
node_tng_ingest -->|"parses"| node_tng_parser
node_tng_ingest -->|"transforms"| node_tng_transformer
node_tng_transformer -->|"feeds"| node_scoring_engine
node_docs -.->|"defines"| node_scoring_engine
node_docker -->|"runs"| node_main_api
node_docker -->|"runs"| node_next_app
node_docker -->|"runs"| node_postgres

click node_next_app "https://github.com/azmirshah1/goaura-dashboard/tree/main/frontend/src/app"
click node_ui_components "https://github.com/azmirshah1/goaura-dashboard/tree/main/frontend/src/components"
click node_api_client "https://github.com/azmirshah1/goaura-dashboard/blob/main/frontend/src/lib/api.ts"
click node_main_api "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/main.py"
click node_api_routes "https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/api"
click node_ingest_api "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/api/ingest.py"
click node_sync_api "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/api/sync.py"
click node_admin_api "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/api/admin.py"
click node_models "https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/models"
click node_database "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/database.py"
click node_scoring_engine "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/engine.py"
click node_dimensions "https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/scoring"
click node_capacity "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/capacity.py"
click node_stability "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/stability.py"
click node_willingness "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/willingness.py"
click node_adjusters "https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/scoring"
click node_tng_ingest "https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/tng"
click node_tng_client "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/tng/client.py"
click node_tng_parser "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/tng/parser.py"
click node_tng_transformer "https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/tng/transformer.py"
click node_docker "https://github.com/azmirshah1/goaura-dashboard/blob/main/docker-compose.yml"
click node_docs "https://github.com/azmirshah1/goaura-dashboard/tree/main/docs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_next_app,node_ui_components,node_api_client toneBlue
class node_main_api,node_api_routes,node_ingest_api,node_sync_api,node_admin_api,node_models,node_database,node_scoring_engine,node_dimensions,node_capacity,node_stability,node_willingness,node_adjusters toneAmber
class node_tng_ingest,node_tng_client,node_tng_parser,node_tng_transformer,node_postgres toneMint
class node_docker toneRose
class node_browser,node_docs toneNeutral
```

## Components

### Frontend

Next.js presentation layer and UI composition

- [Next.js App](https://github.com/azmirshah1/goaura-dashboard/tree/main/frontend/src/app): web frontend · Routes and page shells for dashboard, profiles, ingest, connect, and scoring views · `frontend/src/app`
- [UI Components](https://github.com/azmirshah1/goaura-dashboard/tree/main/frontend/src/components): presentational components · Shared badges, charts, panels, and layout helpers used across the frontend · `frontend/src/components`
- [API Client](https://github.com/azmirshah1/goaura-dashboard/blob/main/frontend/src/lib/api.ts): frontend service · Centralized backend request layer for browser-to-API communication · `frontend/src/lib/api.ts`

### Backend

FastAPI domain API, scoring, and persistence

- [FastAPI App](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/main.py): backend api · Application entrypoint that wires routers and startup behavior · `backend/app/main.py`
- [API Routes](https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/api): http routers · Profile ingest, sync, and admin endpoints · `backend/app/api`
- [Ingest API](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/api/ingest.py): ingest endpoints · Manual profile creation and scoring submission flow · `backend/app/api/ingest.py`
- [Sync API](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/api/sync.py): sync endpoints · TNG transaction synchronization entrypoints · `backend/app/api/sync.py`
- [Admin API](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/api/admin.py): admin endpoints · Profile browsing and deletion endpoints · `backend/app/api/admin.py`
- [Data Models](https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/models): orm models · SQLAlchemy entities for profiles and scores · `backend/app/models`
- [Database Layer](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/database.py): orm/session · Engine and session management for PostgreSQL access · `backend/app/database.py`
- [Scoring Engine](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/engine.py): scoring orchestrator · Coordinates score calculation, tiering, and stored outputs · `backend/app/scoring/engine.py`
- [Signal Models](https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/scoring): scoring dimensions · Core scoring dimensions for capacity, stability, and willingness · `backend/app/scoring`
- [Capacity](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/capacity.py): signal model · Capacity signal contribution to the score · `backend/app/scoring/capacity.py`
- [Stability](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/stability.py): signal model · Stability signal contribution to the score · `backend/app/scoring/stability.py`
- [Willingness](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/scoring/willingness.py): signal model · Willingness signal contribution to the score · `backend/app/scoring/willingness.py`
- [Adjusters](https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/scoring): score modifiers · Policy, thin-data, repayment, and product-specific score adjustments · `backend/app/scoring`

### Data & External

Database and inbound TNG inputs

- [TNG Layer](https://github.com/azmirshah1/goaura-dashboard/tree/main/backend/app/tng): ingestion adapter · Fetches, parses, and transforms TNG data into behavioral metrics · `backend/app/tng`
- [TNG Client](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/tng/client.py): external connector · Fetches live or mock TNG data · `backend/app/tng/client.py`
- [CSV Parser](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/tng/parser.py): statement parser · Parses uploaded TNG CSV statements · `backend/app/tng/parser.py`
- [Transformer](https://github.com/azmirshah1/goaura-dashboard/blob/main/backend/app/tng/transformer.py): metric transform · Converts raw transactions into scoring metrics · `backend/app/tng/transformer.py`
- **PostgreSQL**: system database · System of record for profiles, scores, and derived outputs

### Runtime

Containerized local deployment

- [Docker Compose](https://github.com/azmirshah1/goaura-dashboard/blob/main/docker-compose.yml): runtime · Local runtime boundary for backend, frontend, and database · `docker-compose.yml`

### Other components

- **Browser**: user client · End-user surface that consumes the web app
- [Docs](https://github.com/azmirshah1/goaura-dashboard/tree/main/docs): product docs · Algorithm and product requirements that define the scoring model · `docs`

## Connections

- 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
