# valor0506/finsight-ai architecture

> Architecture diagram of the GitHub repository valor0506/finsight-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/valor0506/finsight-ai
- Repository: https://github.com/valor0506/finsight-ai

## Overview

FinSight AI lets users sign in, select a commodity or equity, and request an AI-generated market report. The API checks the request and queues background work; the worker fetches market and macro data, generates analysis, builds a DOCX, and stores it for status and download. The frontend also provides registration, login, dashboard, and report-status views. Several backend connections are supported by the SOURCE INDEX rather than full excerpts; integrations are shown only where the excerpts document them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/App.jsx) (App routing), [`backend/tasks/report_task.py`](https://github.com/valor0506/finsight-ai/blob/main/backend/tasks/report_task.py) (Report task), [`backend/main.py`](https://github.com/valor0506/finsight-ai/blob/main/backend/main.py) (FastAPI routes), [`frontend/src/api/client.js`](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/api/client.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["App routing<br/>[App.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_landing["Landing page<br/>[Landing.jsx]"]
  node_login["Login page<br/>[Login.jsx]"]
  node_register["Registration page<br/>[Register.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_generate["Report request<br/>[GenerateReport.jsx]"]
  node_status["Report status<br/>[ReportStatus.jsx]"]
  node_authctx["Auth state<br/>[AuthContext.jsx]"]
  node_protected["Route guard<br/>[ProtectedRoute.jsx]"]
  node_client["API client<br/>[client.js]"]
end

subgraph group_api["API and identity"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_auth["Token auth<br/>[auth.py]"]
  node_config["Runtime settings<br/>[config.py]"]
  node_models[("User and reports<br/>[database.py]")]
end

subgraph group_reporting["Report processing"]
  node_worker["Report task<br/>[report_task.py]"]
  node_queue["Celery and Redis<br/>[celery_app.py]"]
  node_builder["DOCX builder<br/>[docx_builder.py]"]
end

subgraph group_data["Market data and analysis"]
  node_fetch["Market data fetch<br/>[data_fetcher.py]"]
  node_analyst["LLM analysis<br/>[llm_analyst.py]"]
end

node_user(("Investor"))
node_markets{{"Market data APIs"}}
node_llm{{"OpenRouter"}}
node_storage[("Supabase storage")]

node_user -->|"uses"| node_app
node_app -->|"renders"| node_navbar
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_generate
node_app -->|"routes to"| node_status
node_app -->|"provides auth"| node_authctx
node_app -->|"guards pages"| node_protected
node_authctx -->|"calls auth API"| node_client
node_generate -->|"requests report"| node_client
node_dashboard -->|"loads reports"| node_client
node_client -->|"HTTP requests"| node_api
node_api -->|"uses auth"| node_auth
node_api -->|"queries and writes"| node_models
node_api -->|"queues task"| node_worker
node_worker -->|"runs on"| node_queue
node_worker -->|"fetches data"| node_fetch
node_worker -->|"requests analysis"| node_analyst
node_worker -->|"builds document"| node_builder
node_fetch -->|"fetches quotes"| node_markets
node_analyst -.->|"generates analysis"| node_llm
node_worker -->|"uploads and updates"| node_storage
node_fetch -->|"reads settings"| node_config
node_analyst -->|"reads settings"| node_config
node_queue -->|"reads settings"| node_config
node_models -->|"reads settings"| node_config

click node_app "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/App.jsx"
click node_navbar "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/components/Navbar.jsx"
click node_landing "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/Landing.jsx"
click node_login "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/Login.jsx"
click node_register "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/Register.jsx"
click node_dashboard "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/Dashboard.jsx"
click node_generate "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/GenerateReport.jsx"
click node_status "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/ReportStatus.jsx"
click node_authctx "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/context/AuthContext.jsx"
click node_protected "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/components/ProtectedRoute.jsx"
click node_client "https://github.com/valor0506/finsight-ai/blob/main/frontend/src/api/client.js"
click node_api "https://github.com/valor0506/finsight-ai/blob/main/backend/main.py"
click node_auth "https://github.com/valor0506/finsight-ai/blob/main/backend/core/auth.py"
click node_config "https://github.com/valor0506/finsight-ai/blob/main/backend/core/config.py"
click node_models "https://github.com/valor0506/finsight-ai/blob/main/backend/models/database.py"
click node_worker "https://github.com/valor0506/finsight-ai/blob/main/backend/tasks/report_task.py"
click node_queue "https://github.com/valor0506/finsight-ai/blob/main/backend/tasks/celery_app.py"
click node_fetch "https://github.com/valor0506/finsight-ai/blob/main/backend/agents/data_fetcher.py"
click node_analyst "https://github.com/valor0506/finsight-ai/blob/main/backend/agents/llm_analyst.py"
click node_builder "https://github.com/valor0506/finsight-ai/blob/main/backend/report_builder/docx_builder.py"

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_app,node_navbar,node_landing,node_login,node_register,node_dashboard,node_generate,node_status,node_authctx,node_protected,node_client toneBlue
class node_api,node_auth,node_config,node_models,node_storage toneAmber
class node_worker,node_queue,node_builder,node_markets,node_llm toneMint
class node_fetch,node_analyst toneRose
class node_user toneIndigo
```

## Components

### Web application

- [App routing](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Navigation](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Landing page](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/Landing.jsx): `frontend/src/pages/Landing.jsx`
- [Login page](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration page](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Dashboard](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Report request](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/GenerateReport.jsx): `frontend/src/pages/GenerateReport.jsx`
- [Report status](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/pages/ReportStatus.jsx): `frontend/src/pages/ReportStatus.jsx`
- [Auth state](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Route guard](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/components/ProtectedRoute.jsx): `frontend/src/components/ProtectedRoute.jsx`
- [API client](https://github.com/valor0506/finsight-ai/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### API and identity

- [FastAPI routes](https://github.com/valor0506/finsight-ai/blob/main/backend/main.py): `backend/main.py`
- [Token auth](https://github.com/valor0506/finsight-ai/blob/main/backend/core/auth.py): `backend/core/auth.py`
- [Runtime settings](https://github.com/valor0506/finsight-ai/blob/main/backend/core/config.py): `backend/core/config.py`
- [User and reports](https://github.com/valor0506/finsight-ai/blob/main/backend/models/database.py): `backend/models/database.py`

### Report processing

- [Report task](https://github.com/valor0506/finsight-ai/blob/main/backend/tasks/report_task.py): `backend/tasks/report_task.py`
- [Celery and Redis](https://github.com/valor0506/finsight-ai/blob/main/backend/tasks/celery_app.py): `backend/tasks/celery_app.py`
- [DOCX builder](https://github.com/valor0506/finsight-ai/blob/main/backend/report_builder/docx_builder.py): `backend/report_builder/docx_builder.py`

### Market data and analysis

- [Market data fetch](https://github.com/valor0506/finsight-ai/blob/main/backend/agents/data_fetcher.py): `backend/agents/data_fetcher.py`
- [LLM analysis](https://github.com/valor0506/finsight-ai/blob/main/backend/agents/llm_analyst.py): `backend/agents/llm_analyst.py`

### Other components

- **Investor**
- **Market data APIs**
- **OpenRouter**
- **Supabase storage**

## Connections

- Investor → App routing: uses
- App routing → Navigation: renders (evidence: `frontend/src/App.jsx`)
- App routing → Landing page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Login page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Registration page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Report request: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Report status: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Auth state: provides auth (evidence: `frontend/src/App.jsx`)
- App routing → Route guard: guards pages (evidence: `frontend/src/App.jsx`)
- Auth state → API client: calls auth API (evidence: `frontend/src/context/AuthContext.jsx`)
- Report request → API client: requests report (evidence: `frontend/src/pages/GenerateReport.jsx`)
- Dashboard → API client: loads reports (evidence: `frontend/src/pages/Dashboard.jsx`)
- API client → FastAPI routes: HTTP requests (evidence: `frontend/src/api/client.js`)
- FastAPI routes → Token auth: uses auth (evidence: `backend/main.py`)
- FastAPI routes → User and reports: queries and writes (evidence: `backend/main.py`)
- FastAPI routes → Report task: queues task (evidence: `backend/main.py`)
- Report task → Celery and Redis: runs on (evidence: `backend/tasks/report_task.py`)
- Report task → Market data fetch: fetches data (evidence: `backend/tasks/report_task.py`)
- Report task → LLM analysis: requests analysis (evidence: `backend/tasks/report_task.py`)
- Report task → DOCX builder: builds document (evidence: `backend/tasks/report_task.py`)
- Market data fetch → Market data APIs: fetches quotes (evidence: `backend/agents/data_fetcher.py`)
- LLM analysis → OpenRouter: generates analysis
- Report task → Supabase storage: uploads and updates (evidence: `backend/tasks/report_task.py`)
- Market data fetch → Runtime settings: reads settings (evidence: `backend/agents/data_fetcher.py`)
- LLM analysis → Runtime settings: reads settings (evidence: `backend/agents/llm_analyst.py`)
- Celery and Redis → Runtime settings: reads settings (evidence: `backend/tasks/celery_app.py`)
- User and reports → Runtime settings: reads settings (evidence: `backend/models/database.py`)
