# siddhantaternos/senra architecture

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

- Interactive diagram: https://gitdiagram.com/siddhantaternos/senra
- Repository: https://github.com/siddhantaternos/senra

## Overview

SENRA is a personal-finance API for tracking expenses, income, and investments, with market data, insights, reports, imports, and an AI chat assistant. The main runtime path is a user request into the FastAPI application, which registers feature routers; those handlers read or write financial records in SQLite. Separate routes support account management, importing bank data, portfolio valuation, and stock research. The README gives no further product detail, and several router implementations were not sampled, so their internal behavior and connections are left unspecified.

Main entry points: [`app/main.py`](https://github.com/siddhantaternos/senra/blob/main/app/main.py) (FastAPI app), [`app/database.py`](https://github.com/siddhantaternos/senra/blob/main/app/database.py) (Database sessions), [`app/models.py`](https://github.com/siddhantaternos/senra/blob/main/app/models.py) (Finance models), [`app/routers/portfolio.py`](https://github.com/siddhantaternos/senra/blob/main/app/routers/portfolio.py) (Portfolio tracking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_api["FastAPI app<br/>[main.py]"]
  node_auth["Accounts and auth<br/>[auth.py]"]
  node_database_layer["Database sessions<br/>[database.py]"]
  node_models["Finance models<br/>[models.py]"]
  node_sqlite[("SQLite records<br/>[expenses.db]")]
end

subgraph group_finance["Financial records"]
  node_expenses["Expense tracking<br/>[expenses.py]"]
  node_income["Income tracking<br/>[income.py]"]
  node_importer["Statement import<br/>[import_data.py]"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
  node_reports["Financial reports<br/>[reports.py]"]
  node_pocket["Pocket management<br/>[pocket.py]"]
end

subgraph group_investing["Investing and markets"]
  node_portfolio["Portfolio tracking<br/>[portfolio.py]"]
  node_stocks["Stock research<br/>[stocks.py]"]
  node_nse["NSE live data<br/>[nse_live.py]"]
end

subgraph group_intelligence["Insights and assistance"]
  node_insights["Spending insights<br/>[insights.py]"]
  node_agent["Finance AI chat<br/>[agent.py]"]
end

node_user(("User"))
node_market_data["Market data service"]
node_groq["Groq AI service"]

node_user -->|"sends requests"| node_api
node_api -->|"registers routes"| node_auth
node_api -->|"registers routes"| node_expenses
node_api -->|"registers routes"| node_pocket
node_api -->|"registers routes"| node_stocks
node_api -->|"registers routes"| node_nse
node_api -->|"registers routes"| node_importer
node_api -->|"registers routes"| node_insights
node_api -->|"registers routes"| node_income
node_api -->|"registers routes"| node_portfolio
node_api -->|"registers routes"| node_dashboard
node_api -->|"registers routes"| node_agent
node_api -->|"creates tables"| node_database_layer
node_database_layer -->|"opens database"| node_sqlite
node_models -->|"uses base"| node_database_layer
node_auth -->|"reads and writes"| node_models
node_expenses -->|"reads and writes"| node_models
node_expenses -->|"gets sessions"| node_database_layer
node_income -->|"gets sessions"| node_database_layer
node_importer -->|"saves records"| node_models
node_importer -->|"gets sessions"| node_database_layer
node_portfolio -->|"reads and writes"| node_models
node_portfolio -->|"gets sessions"| node_database_layer
node_portfolio -->|"fetches prices"| node_market_data
node_stocks -->|"fetches quotes"| node_market_data
node_agent -->|"reads and writes"| node_models
node_agent -->|"requests completions"| node_groq
node_agent -->|"gets sessions"| node_database_layer
node_dashboard -->|"gets sessions"| node_database_layer
node_insights -->|"gets sessions"| node_database_layer
node_reports -->|"queries records"| node_database_layer
node_reports -->|"checks identity"| node_auth

click node_api "https://github.com/siddhantaternos/senra/blob/main/app/main.py"
click node_auth "https://github.com/siddhantaternos/senra/blob/main/app/routers/auth.py"
click node_database_layer "https://github.com/siddhantaternos/senra/blob/main/app/database.py"
click node_models "https://github.com/siddhantaternos/senra/blob/main/app/models.py"
click node_sqlite "https://github.com/siddhantaternos/senra/blob/main/expenses.db"
click node_expenses "https://github.com/siddhantaternos/senra/blob/main/app/routers/expenses.py"
click node_income "https://github.com/siddhantaternos/senra/blob/main/app/routers/income.py"
click node_importer "https://github.com/siddhantaternos/senra/blob/main/app/routers/import_data.py"
click node_dashboard "https://github.com/siddhantaternos/senra/blob/main/app/routers/dashboard.py"
click node_reports "https://github.com/siddhantaternos/senra/blob/main/app/routers/reports.py"
click node_pocket "https://github.com/siddhantaternos/senra/blob/main/app/routers/pocket.py"
click node_portfolio "https://github.com/siddhantaternos/senra/blob/main/app/routers/portfolio.py"
click node_stocks "https://github.com/siddhantaternos/senra/blob/main/app/routers/stocks.py"
click node_nse "https://github.com/siddhantaternos/senra/blob/main/app/routers/nse_live.py"
click node_insights "https://github.com/siddhantaternos/senra/blob/main/app/routers/insights.py"
click node_agent "https://github.com/siddhantaternos/senra/blob/main/app/routers/agent.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_api,node_auth,node_database_layer,node_models,node_sqlite,node_user toneBlue
class node_expenses,node_income,node_importer,node_dashboard,node_reports,node_pocket toneAmber
class node_portfolio,node_stocks,node_nse toneMint
class node_insights,node_agent toneRose
class node_market_data,node_groq toneIndigo
```

## Components

### API runtime

- [FastAPI app](https://github.com/siddhantaternos/senra/blob/main/app/main.py): `app/main.py`
- [Accounts and auth](https://github.com/siddhantaternos/senra/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [Database sessions](https://github.com/siddhantaternos/senra/blob/main/app/database.py): `app/database.py`
- [Finance models](https://github.com/siddhantaternos/senra/blob/main/app/models.py): `app/models.py`
- [SQLite records](https://github.com/siddhantaternos/senra/blob/main/expenses.db): `expenses.db`

### Financial records

- [Expense tracking](https://github.com/siddhantaternos/senra/blob/main/app/routers/expenses.py): `app/routers/expenses.py`
- [Income tracking](https://github.com/siddhantaternos/senra/blob/main/app/routers/income.py): `app/routers/income.py`
- [Statement import](https://github.com/siddhantaternos/senra/blob/main/app/routers/import_data.py): `app/routers/import_data.py`
- [Dashboard](https://github.com/siddhantaternos/senra/blob/main/app/routers/dashboard.py): `app/routers/dashboard.py`
- [Financial reports](https://github.com/siddhantaternos/senra/blob/main/app/routers/reports.py): `app/routers/reports.py`
- [Pocket management](https://github.com/siddhantaternos/senra/blob/main/app/routers/pocket.py): `app/routers/pocket.py`

### Investing and markets

- [Portfolio tracking](https://github.com/siddhantaternos/senra/blob/main/app/routers/portfolio.py): `app/routers/portfolio.py`
- [Stock research](https://github.com/siddhantaternos/senra/blob/main/app/routers/stocks.py): `app/routers/stocks.py`
- [NSE live data](https://github.com/siddhantaternos/senra/blob/main/app/routers/nse_live.py): `app/routers/nse_live.py`

### Insights and assistance

- [Spending insights](https://github.com/siddhantaternos/senra/blob/main/app/routers/insights.py): `app/routers/insights.py`
- [Finance AI chat](https://github.com/siddhantaternos/senra/blob/main/app/routers/agent.py): `app/routers/agent.py`

### Other components

- **User**
- **Market data service**
- **Groq AI service**

## Connections

- User → FastAPI app: sends requests (evidence: `app/main.py`)
- FastAPI app → Accounts and auth: registers routes (evidence: `app/main.py`)
- FastAPI app → Expense tracking: registers routes (evidence: `app/main.py`)
- FastAPI app → Pocket management: registers routes (evidence: `app/main.py`)
- FastAPI app → Stock research: registers routes (evidence: `app/main.py`)
- FastAPI app → NSE live data: registers routes (evidence: `app/main.py`)
- FastAPI app → Statement import: registers routes (evidence: `app/main.py`)
- FastAPI app → Spending insights: registers routes (evidence: `app/main.py`)
- FastAPI app → Income tracking: registers routes (evidence: `app/main.py`)
- FastAPI app → Portfolio tracking: registers routes (evidence: `app/main.py`)
- FastAPI app → Dashboard: registers routes (evidence: `app/main.py`)
- FastAPI app → Finance AI chat: registers routes (evidence: `app/main.py`)
- FastAPI app → Database sessions: creates tables (evidence: `app/main.py`)
- Database sessions → SQLite records: opens database (evidence: `app/database.py`)
- Finance models → Database sessions: uses base (evidence: `app/models.py`)
- Accounts and auth → Finance models: reads and writes (evidence: `app/routers/auth.py`)
- Expense tracking → Finance models: reads and writes (evidence: `app/routers/expenses.py`)
- Expense tracking → Database sessions: gets sessions (evidence: `app/routers/expenses.py`)
- Income tracking → Database sessions: gets sessions (evidence: `app/routers/income.py`)
- Statement import → Finance models: saves records (evidence: `app/routers/import_data.py`)
- Statement import → Database sessions: gets sessions (evidence: `app/routers/import_data.py`)
- Portfolio tracking → Finance models: reads and writes (evidence: `app/routers/portfolio.py`)
- Portfolio tracking → Database sessions: gets sessions (evidence: `app/routers/portfolio.py`)
- Portfolio tracking → Market data service: fetches prices (evidence: `app/routers/portfolio.py`)
- Stock research → Market data service: fetches quotes (evidence: `app/routers/stocks.py`)
- Finance AI chat → Finance models: reads and writes (evidence: `app/routers/agent.py`)
- Finance AI chat → Groq AI service: requests completions (evidence: `app/routers/agent.py`)
- Finance AI chat → Database sessions: gets sessions (evidence: `app/routers/agent.py`)
- Dashboard → Database sessions: gets sessions (evidence: `app/routers/dashboard.py`)
- Spending insights → Database sessions: gets sessions (evidence: `app/routers/insights.py`)
- Financial reports → Database sessions: queries records (evidence: `app/routers/reports.py`)
- Financial reports → Accounts and auth: checks identity (evidence: `app/routers/reports.py`)
