# krishanth7/agent architecture

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

- Interactive diagram: https://gitdiagram.com/krishanth7/agent
- Repository: https://github.com/krishanth7/agent

## Overview

NIFTY Agent is a monitoring dashboard for an autonomous-trading concept, but this repository does not execute trades: displayed account and performance figures are mock or seeded data, while monthly targets persist in PostgreSQL/TimescaleDB. The main workflow is browser dashboard → HTTP API → services that read and derive account, target, performance, and calendar views → displayed cards. Exchange hours, holidays, and theme behavior are frontend-side. An explicitly configured, read-only Angel One connection test is a separate optional integration. Backend wiring beyond the sampled source is represented only where documented by the README or module descriptions.

Main entry points: [`backend/app/api/v1`](https://github.com/krishanth7/agent/tree/main/backend/app/api/v1) (Dashboard routes), [`src/components/dashboard/Dashboard.tsx`](https://github.com/krishanth7/agent/blob/main/src/components/dashboard/Dashboard.tsx) (Dashboard view), [`backend/app/services/performance_service.py`](https://github.com/krishanth7/agent/blob/main/backend/app/services/performance_service.py) (Performance service), [`backend/app/repositories/postgres`](https://github.com/krishanth7/agent/tree/main/backend/app/repositories/postgres) (Postgres repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard frontend"]
  node_dashboard["Dashboard view<br/>[Dashboard.tsx]"]
  node_cards["Dashboard cards"]
  node_market["Market clock<br/>[market.ts]"]
  node_theme["Theme controls<br/>[theme.ts]"]
  node_resource["API resource state<br/>[useApiResource.ts]"]
  node_api_client["HTTP client<br/>[client.ts]"]
  node_api_modules["API resource modules"]
end

subgraph group_api["API and services"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_router["API route dispatch<br/>[router.py]"]
  node_routes["Dashboard routes"]
  node_account_service["Account service<br/>[account_service.py]"]
  node_target_service["Target service<br/>[target_service.py]"]
  node_performance_service["Performance service"]
  node_calculations["Domain calculations<br/>[calculations.py]"]
  node_agent_service["Agent service<br/>[agent_service.py]"]
end

subgraph group_data["Data and persistence"]
  node_mock_repositories["Mock repositories"]
  node_postgres_repositories["Postgres repositories"]
  node_database[("PostgreSQL / TimescaleDB")]
end

subgraph group_broker["Broker integration"]
  node_broker_service["Broker service<br/>[broker_service.py]"]
  node_broker_adapter["Angel One adapter<br/>[adapter.py]"]
end

node_user(("Dashboard user"))
node_angel_one(("Angel One"))

node_user -->|"views"| node_dashboard
node_dashboard -->|"renders"| node_cards
node_dashboard -->|"reads locally"| node_market
node_dashboard -->|"toggles"| node_theme
node_cards -->|"loads data"| node_resource
node_resource -->|"invokes"| node_api_modules
node_api_modules -->|"requests via"| node_api_client
node_api_client -->|"HTTP requests"| node_backend
node_backend -->|"includes"| node_router
node_router -->|"dispatches"| node_routes
node_routes -->|"invokes"| node_account_service
node_routes -->|"invokes"| node_target_service
node_routes -->|"invokes"| node_performance_service
node_routes -->|"invokes"| node_agent_service
node_routes -.->|"invokes"| node_broker_service
node_account_service -->|"reads"| node_mock_repositories
node_target_service -->|"reads / writes"| node_postgres_repositories
node_performance_service -->|"reads"| node_mock_repositories
node_performance_service -->|"reads"| node_postgres_repositories
node_performance_service -->|"derives metrics"| node_calculations
node_postgres_repositories -->|"reads / writes"| node_database
node_broker_service -.->|"creates / queries"| node_broker_adapter
node_broker_adapter -.->|"read-only requests"| node_angel_one

click node_dashboard "https://github.com/krishanth7/agent/blob/main/src/components/dashboard/Dashboard.tsx"
click node_cards "https://github.com/krishanth7/agent/tree/main/src/components/dashboard"
click node_market "https://github.com/krishanth7/agent/blob/main/src/lib/market.ts"
click node_theme "https://github.com/krishanth7/agent/blob/main/src/lib/theme.ts"
click node_resource "https://github.com/krishanth7/agent/blob/main/src/hooks/useApiResource.ts"
click node_api_client "https://github.com/krishanth7/agent/blob/main/src/lib/api/client.ts"
click node_api_modules "https://github.com/krishanth7/agent/tree/main/src/lib/api"
click node_backend "https://github.com/krishanth7/agent/blob/main/backend/app/main.py"
click node_router "https://github.com/krishanth7/agent/blob/main/backend/app/api/router.py"
click node_routes "https://github.com/krishanth7/agent/tree/main/backend/app/api/v1"
click node_account_service "https://github.com/krishanth7/agent/blob/main/backend/app/services/account_service.py"
click node_target_service "https://github.com/krishanth7/agent/blob/main/backend/app/services/target_service.py"
click node_performance_service "https://github.com/krishanth7/agent/blob/main/backend/app/services/performance_service.py"
click node_calculations "https://github.com/krishanth7/agent/blob/main/backend/app/domain/calculations.py"
click node_agent_service "https://github.com/krishanth7/agent/blob/main/backend/app/services/agent_service.py"
click node_broker_service "https://github.com/krishanth7/agent/blob/main/backend/app/services/broker_service.py"
click node_broker_adapter "https://github.com/krishanth7/agent/blob/main/backend/app/brokers/angel_one/adapter.py"
click node_mock_repositories "https://github.com/krishanth7/agent/tree/main/backend/app/repositories/mock"
click node_postgres_repositories "https://github.com/krishanth7/agent/tree/main/backend/app/repositories/postgres"
click node_database "https://github.com/krishanth7/agent/tree/main/backend/app/db"

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_dashboard,node_cards,node_market,node_theme,node_resource,node_api_client,node_api_modules,node_user toneBlue
class node_backend,node_router,node_routes,node_account_service,node_target_service,node_performance_service,node_calculations,node_agent_service toneAmber
class node_mock_repositories,node_postgres_repositories,node_database toneMint
class node_broker_service,node_broker_adapter toneRose
class node_angel_one toneIndigo
```

## Components

### Dashboard frontend

- [Dashboard view](https://github.com/krishanth7/agent/blob/main/src/components/dashboard/Dashboard.tsx): `src/components/dashboard/Dashboard.tsx`
- [Dashboard cards](https://github.com/krishanth7/agent/tree/main/src/components/dashboard): `src/components/dashboard`
- [Market clock](https://github.com/krishanth7/agent/blob/main/src/lib/market.ts): `src/lib/market.ts`
- [Theme controls](https://github.com/krishanth7/agent/blob/main/src/lib/theme.ts): `src/lib/theme.ts`
- [API resource state](https://github.com/krishanth7/agent/blob/main/src/hooks/useApiResource.ts): `src/hooks/useApiResource.ts`
- [HTTP client](https://github.com/krishanth7/agent/blob/main/src/lib/api/client.ts): `src/lib/api/client.ts`
- [API resource modules](https://github.com/krishanth7/agent/tree/main/src/lib/api): `src/lib/api`

### API and services

- [FastAPI application](https://github.com/krishanth7/agent/blob/main/backend/app/main.py): `backend/app/main.py`
- [API route dispatch](https://github.com/krishanth7/agent/blob/main/backend/app/api/router.py): `backend/app/api/router.py`
- [Dashboard routes](https://github.com/krishanth7/agent/tree/main/backend/app/api/v1): `backend/app/api/v1`
- [Account service](https://github.com/krishanth7/agent/blob/main/backend/app/services/account_service.py): `backend/app/services/account_service.py`
- [Target service](https://github.com/krishanth7/agent/blob/main/backend/app/services/target_service.py): `backend/app/services/target_service.py`
- [Performance service](https://github.com/krishanth7/agent/blob/main/backend/app/services/performance_service.py): `backend/app/services/performance_service.py`
- [Domain calculations](https://github.com/krishanth7/agent/blob/main/backend/app/domain/calculations.py): `backend/app/domain/calculations.py`
- [Agent service](https://github.com/krishanth7/agent/blob/main/backend/app/services/agent_service.py): `backend/app/services/agent_service.py`

### Data and persistence

- [Mock repositories](https://github.com/krishanth7/agent/tree/main/backend/app/repositories/mock): `backend/app/repositories/mock`
- [Postgres repositories](https://github.com/krishanth7/agent/tree/main/backend/app/repositories/postgres): `backend/app/repositories/postgres`
- [PostgreSQL / TimescaleDB](https://github.com/krishanth7/agent/tree/main/backend/app/db): `backend/app/db`

### Broker integration

- [Broker service](https://github.com/krishanth7/agent/blob/main/backend/app/services/broker_service.py): `backend/app/services/broker_service.py`
- [Angel One adapter](https://github.com/krishanth7/agent/blob/main/backend/app/brokers/angel_one/adapter.py): `backend/app/brokers/angel_one/adapter.py`

### Other components

- **Dashboard user**
- **Angel One**

## Connections

- Dashboard user → Dashboard view: views
- Dashboard view → Dashboard cards: renders
- Dashboard view → Market clock: reads locally
- Dashboard view → Theme controls: toggles
- Dashboard cards → API resource state: loads data
- API resource state → API resource modules: invokes
- API resource modules → HTTP client: requests via
- HTTP client → FastAPI application: HTTP requests
- FastAPI application → API route dispatch: includes
- API route dispatch → Dashboard routes: dispatches
- Dashboard routes → Account service: invokes
- Dashboard routes → Target service: invokes
- Dashboard routes → Performance service: invokes
- Dashboard routes → Agent service: invokes
- Dashboard routes → Broker service: invokes
- Account service → Mock repositories: reads
- Target service → Postgres repositories: reads / writes
- Performance service → Mock repositories: reads
- Performance service → Postgres repositories: reads
- Performance service → Domain calculations: derives metrics
- Postgres repositories → PostgreSQL / TimescaleDB: reads / writes
- Broker service → Angel One adapter: creates / queries
- Angel One adapter → Angel One: read-only requests
