# pruthvi3715/vois-elida architecture

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

- Interactive diagram: https://gitdiagram.com/pruthvi3715/vois-elida
- Repository: https://github.com/pruthvi3715/vois-elida

## Overview

1. **System shape**
   ELIDA is a two-tier product: a **React/Vite frontend** for user interaction and a **FastAPI backend** for all analysis, auth, and data access. The backend is not just a CRUD API; it is the execution layer for a multi-agent investment analysis pipeline that combines market data, user profile data, and LLM-based reasoning.

2. **Frontend boundary**
   The frontend is organized around page-level workflows: **Dashboard, Analysis, Portfolio, History, Profile, Learn, Login/Register, Comparison, Settings**. Shared UI pieces like charts, match score cards, agent cards, and regret warnings indicate that the UI is centered on presenting analysis results rather than editing content. `AuthContext` and `AnalysisContext` act as the main client-side state boundaries for identity and in-flight analysis data.

3. **Backend application boundary**
   `backend/app/main.py` is the FastAPI entrypoint, while `core/` contains cross-cutting concerns: configuration, logging, security, and centralized error handling. `database.py` and `models/` define persistence boundaries, separating API orchestration from stored user/profile/history data.

4. **Authentication subsystem**
   Authentication is isolated under `backend/app/auth/`, with service, routes, and dependencies split cleanly. The presence of JWT-oriented security utilities and dependency injection suggests protected endpoints for user-specific features such as profile and history. On the frontend, protected routing is enforced through `ProtectedElement`.

5. **Domain model: Investor DNA**
   A key domain concept is **Investor DNA**, modeled in `models/investor_dna.py`. This is the personalization layer used to score how well an investment aligns with a user’s risk tolerance, time horizon, goals, and sector preferences. This model is a central input to the match-score and coaching logic, not a UI-only feature.

6. **Multi-agent analysis pipeline**
   The backend’s `agents/` package defines the core intelligence layer: **Scout, Quant, Macro, Philosopher, Regret, Coach**, all built on a shared base. The agents represent distinct analytical lenses: data collection, fundamentals, macro context, quality/ethics, behavioral risk, and final synthesis. `orchestrator.py` is the coordination boundary that likely sequences these agents and merges their outputs into one analysis response.

7. **Service layer responsibilities**
   Most business logic lives in `services/`. This layer includes market-data adapters (`coingecko_service`, `fred_service`, `ticker_search_service`), LLM/RAG support (`claude_service`, `rag_service`, `finance_knowledge_base`), scoring and personalization (`match_score_service`, `score_labels`), and quality controls (`data_validator`, `sanity_checker`). The service layer is where the backend integrates external sources and normalizes them into analysis-ready inputs.

8. **Behavioral finance and risk simulation**
   The `regret` agent plus `regret`-related UI components show that the system explicitly models **loss aversion and worst-case outcomes**, not just upside. This behavioral layer feeds the final recommendation and the displayed warnings, making the architecture distinct from a traditional stock screener. In diagram terms, this is a separate analysis branch that influences the final coach synthesis.

9. **User-facing API slices**
   API routing is split by concern: `auth/`, `routers/profile.py`, and `routers/history.py`. This implies a clean separation between identity, personalized investor settings, and stored analysis history. The frontend pages likely consume these endpoints to populate the Profile and History experiences, while analysis pages call the orchestration endpoint(s) for live evaluation.

10. **Persistence and caching**
   The system uses **SQLite + SQLAlchemy** for durable app data, with a separate `cache_service` and `demo_cache.py` for performance and demo-friendly responses. There is also a `data/history.json` seed/sample dataset, which suggests a lightweight local data source for prototypes or historical examples. The architecture therefore has three storage concerns: relational user/history data, cached responses, and external market/RAG data.

11. **External data and AI dependencies**
   The README and service names indicate integration with **LLM providers** and external market-data APIs. The architecture explicitly supports an LLM fallback chain and uses RAG for factual grounding, so the backend depends on both live financial data and a vector/knowledge store. In a diagram, these are external dependencies feeding the service layer rather than direct frontend integrations.

12. **Quality, testing, and documentation boundaries**
   Tests cover the key seams: agents, auth, and orchestrator behavior. The repo also contains extensive docs for architecture, API reference, workflows, and presentation material, which suggests the system is intentionally documented as a teaching/demo platform. That makes the architectural boundaries relatively stable and explicit: UI, auth, orchestration, domain scoring, data adapters, and persistence.

Main entry points: [`backend/app/services`](https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/services) (Services), [`backend/app/main.py`](https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/main.py) (API app), [`frontend/src/pages`](https://github.com/pruthvi3715/vois-elida/tree/main/frontend/src/pages) (Workflows), [`frontend/src/main.tsx`](https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/main.tsx) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App shell<br/>react entry<br/>[main.tsx]"]
  node_frontend_context_auth(("Auth state<br/>client context<br/>[AuthContext.tsx]"))
  node_frontend_context_analysis(("Analysis state<br/>client context"))
  node_frontend_pages["Workflows<br/>pages"]
  node_frontend_components["UI widgets<br/>shared components"]
  node_frontend_protected{{"Protected routes<br/>route guard"}}
  node_frontend_api["API client<br/>http client<br/>[api.js]"]
end

subgraph group_backend["Backend"]
  node_backend_main["API app<br/>fastapi entrypoint<br/>[main.py]"]
  node_backend_core["Core<br/>cross-cutting"]
  node_backend_auth{{"Auth"}}
  node_backend_orchestrator["Orchestrator<br/>analysis coordinator<br/>[orchestrator.py]"]
  node_backend_agents{{"Agents<br/>multi-agent system"}}
  node_backend_services["Services<br/>business logic"]
  node_backend_models[("Models")]
  node_backend_db[("Database<br/>persistence<br/>[database.py]")]
  node_backend_routers["Profile/History APIs<br/>resource routers"]
  node_backend_cache["Cache<br/>[cache_service.py]"]
end

subgraph group_external["External"]
  node_data_seed["Seed history<br/>sample data<br/>[history.json]"]
  node_llm_provider["LLM API<br/>external ai"]
  node_market_data["Market data<br/>external feeds"]
end

node_frontend_app -->|"wraps"| node_frontend_context_auth
node_frontend_app -->|"wraps"| node_frontend_context_analysis
node_frontend_app -->|"routes to"| node_frontend_pages
node_frontend_pages -->|"uses"| node_frontend_components
node_frontend_pages -->|"guards"| node_frontend_protected
node_frontend_pages -->|"calls"| node_frontend_api
node_frontend_protected -->|"reads"| node_frontend_context_auth
node_backend_main -->|"loads"| node_backend_core
node_backend_main -->|"mounts"| node_backend_auth
node_backend_main -->|"mounts"| node_backend_routers
node_backend_main -->|"exposes"| node_backend_orchestrator
node_backend_orchestrator -->|"coordinates"| node_backend_agents
node_backend_orchestrator -->|"depends on"| node_backend_services
node_backend_services -->|"fetches"| node_market_data
node_backend_services -->|"queries"| node_llm_provider
node_backend_services -->|"reads/writes"| node_backend_cache
node_backend_services -->|"uses"| node_backend_models
node_backend_models -->|"persists via"| node_backend_db
node_backend_routers -->|"delegates"| node_backend_services
node_backend_auth -->|"uses"| node_backend_core
node_backend_auth -->|"uses"| node_backend_models
node_backend_services -->|"loads"| node_data_seed

click node_frontend_app "https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/main.tsx"
click node_frontend_context_auth "https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/context/AuthContext.tsx"
click node_frontend_context_analysis "https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/context/AnalysisContext.tsx"
click node_frontend_pages "https://github.com/pruthvi3715/vois-elida/tree/main/frontend/src/pages"
click node_frontend_components "https://github.com/pruthvi3715/vois-elida/tree/main/frontend/src/components"
click node_frontend_protected "https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/components/auth/ProtectedElement.tsx"
click node_frontend_api "https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/api.js"
click node_backend_main "https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/main.py"
click node_backend_core "https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/core"
click node_backend_auth "https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/auth"
click node_backend_orchestrator "https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/orchestrator.py"
click node_backend_agents "https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/agents"
click node_backend_services "https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/services"
click node_backend_models "https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/models"
click node_backend_db "https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/database.py"
click node_backend_routers "https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/routers"
click node_backend_cache "https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/services/cache_service.py"
click node_data_seed "https://github.com/pruthvi3715/vois-elida/blob/main/backend/data/history.json"

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_frontend_app,node_frontend_context_auth,node_frontend_context_analysis,node_frontend_pages,node_frontend_components,node_frontend_protected,node_frontend_api toneBlue
class node_backend_main,node_backend_core,node_backend_auth,node_backend_orchestrator,node_backend_agents,node_backend_services,node_backend_models,node_backend_db,node_backend_routers,node_backend_cache toneAmber
class node_data_seed,node_llm_provider,node_market_data toneMint
```

## Components

### Frontend

React/Vite UI, client state, and page workflows.

- [App shell](https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/main.tsx): react entry · Bootstraps the Vite app and global layout/routing. · `frontend/src/main.tsx`
- [Auth state](https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/context/AuthContext.tsx): client context · Holds identity and login state for protected flows. · `frontend/src/context/AuthContext.tsx`
- [Analysis state](https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/context/AnalysisContext.tsx): client context · Tracks in-flight analysis and result state. · `frontend/src/context/AnalysisContext.tsx`
- [Workflows](https://github.com/pruthvi3715/vois-elida/tree/main/frontend/src/pages): pages · Dashboard, analysis, portfolio, history, profile, learn, comparison, and settings screens. · `frontend/src/pages`
- [UI widgets](https://github.com/pruthvi3715/vois-elida/tree/main/frontend/src/components): shared components · Charts, score cards, warnings, chatbot, and layout pieces for analysis presentation. · `frontend/src/components`
- [Protected routes](https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/components/auth/ProtectedElement.tsx): route guard · Blocks authenticated pages until login succeeds. · `frontend/src/components/auth/ProtectedElement.tsx`
- [API client](https://github.com/pruthvi3715/vois-elida/blob/main/frontend/src/api.js): http client · Frontend gateway for backend calls. · `frontend/src/api.js`

### Backend

FastAPI app, orchestration, services, and persistence.

- [API app](https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/main.py): fastapi entrypoint · Creates the FastAPI application and registers routes. · `backend/app/main.py`
- [Core](https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/core): cross-cutting · Configuration, logging, security, and error handling. · `backend/app/core`
- [Auth](https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/auth): authentication · JWT-oriented auth routes, services, and dependencies. · `backend/app/auth`
- [Orchestrator](https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/orchestrator.py): analysis coordinator · Coordinates the agent pipeline and assembles analysis output. · `backend/app/orchestrator.py`
- [Agents](https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/agents): multi-agent system · Scout, Quant, Macro, Philosopher, Regret, and Coach analysis lenses. · `backend/app/agents`
- [Services](https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/services): business logic · Market-data adapters, scoring, RAG, validation, caching, and portfolio/history helpers. · `backend/app/services`
- [Models](https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/models): domain models · Database models and Investor DNA personalization model. · `backend/app/models`
- [Database](https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/database.py): persistence · SQLAlchemy-backed durable app storage. · `backend/app/database.py`
- [Profile/History APIs](https://github.com/pruthvi3715/vois-elida/tree/main/backend/app/routers): resource routers · User-specific API slices for profile and history data. · `backend/app/routers`
- [Cache](https://github.com/pruthvi3715/vois-elida/blob/main/backend/app/services/cache_service.py): response cache · Cached and demo-friendly responses for performance and repeatability. · `backend/app/services/cache_service.py`

### External

Third-party data, AI providers, and storage dependencies.

- [Seed history](https://github.com/pruthvi3715/vois-elida/blob/main/backend/data/history.json): sample data · Local historical sample data used for demos and bootstrapping. · `backend/data/history.json`
- **LLM API**: external ai · Third-party language model provider used for reasoning and synthesis.
- **Market data**: external feeds · External market and macro data sources such as CoinGecko, FRED, and ticker search.

## Connections

- App shell → Auth state: wraps · Provides auth state to the app.
- App shell → Analysis state: wraps · Provides analysis state to the app.
- App shell → Workflows: routes to · Renders page-level workflows.
- Workflows → UI widgets: uses · Composes shared presentation components.
- Workflows → Protected routes: guards · Protects authenticated routes.
- Workflows → API client: calls · Fetches backend data and submits analysis requests.
- Protected routes → Auth state: reads · Checks user identity state.
- API app → Core: loads · Applies configuration, logging, security, and errors.
- API app → Auth: mounts · Registers authentication endpoints.
- API app → Profile/History APIs: mounts · Registers profile and history APIs.
- API app → Orchestrator: exposes · Serves analysis execution endpoints.
- Orchestrator → Agents: coordinates · Sequences specialist agents and merges outputs.
- Orchestrator → Services: depends on · Uses scoring, RAG, validation, and data adapters.
- Services → Market data: fetches · Pulls live market and macro inputs.
- Services → LLM API: queries · Uses LLM reasoning and synthesis.
- Services → Cache: reads/writes · Caches repeatable responses and demo data.
- Services → Models: uses · Transforms domain objects and persisted records.
- Models → Database: persists via · Stores relational app data through SQLAlchemy.
- Profile/History APIs → Services: delegates · Routes profile and history operations into services.
- Auth → Core: uses · Relies on shared security and error handling.
- Auth → Models: uses · Reads and writes user/auth-related records.
- Services → Seed history: loads · Uses sample history data for local/demo flows.
