# gitpranav04/indivest architecture

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

- Interactive diagram: https://gitdiagram.com/gitpranav04/indivest
- Repository: https://github.com/gitpranav04/indivest

## Overview

##### Main Architectural Components
- Frontend: A React.js application under the “frontend” folder. This part handles the user interface, interactive dashboards, and routing between pages such as Login, Dashboard, and MarketData.
- Backend: A FastAPI-based server from the “backend/app” directory. This includes:
- Authentication (located in backend/app/auth)
- Various API routers (market data, portfolio, risk analysis, sentiment analysis) under backend/app/routers.
- Database connection and model definitions in backend/app/database.py and backend/app/models.
- Database: PostgreSQL (as noted in the README), which will store user data, portfolio details, market info, etc.
- ML/NLP Components: Embedded within the backend – these may involve Python libraries (Scikit-learn, NLTK, PyTorch) for risk and sentiment analysis.
- Deployment: Render deployment configurations are included (render.yaml and RENDER_DEPLOYMENT.md) to manage hosting and continuous delivery.

##### Relationships and Interactions
- The Frontend interacts with the Backend through REST APIs or possibly WebSocket connections, making use of API services under “frontend/src/services”.
- The Backend communicates with the PostgreSQL database for storage and retrieval operations.
- The Backend routes segregate responsibilities – for example, the “auth” module for user sign-in/out actions; separate routers for market data, portfolio management, risk analysis, and sentiment analysis.
- ML/NLP functionality in the backend is integrated into the risk analysis and sentiment analysis routers/models, orchestrating the processing of market data into actionable insights.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between frontend and backend functionalities.
- Modular Design: In the backend, distinct modules (auth, models, routers) support maintainability and scalability.
- Component-Based UI: The React frontend follows a component-based architecture (with separate components for layout, portfolio management, etc.).
- API-first Communication: The interaction between frontend and backend is designed around RESTful APIs.
- Deployment Ready: The repository includes Render-specific configurations, reflecting an emphasis on cloud-native deployment practices.

##### Relevant Technologies, Frameworks, and Libraries
- Frontend: React.js, with Vite as the build tool (frontend/vite.config.js), and context providers for authentication and theme.
- Backend: FastAPI (Python) for the API layer; Dependency injection is likely used as it’s common with FastAPI.
- Database: PostgreSQL.
- ML/NLP/Analytics: Scikit-learn, NLTK (possibly Finbert), and PyTorch for machine learning and natural language processing tasks.
- Deployment: Render, with associated configuration files.

##### Key Points
- Detail is essential – strive to capture every major module and data flow.
- Don't hesitate to break down the backend into its subcomponents (auth, models, routers) to expose the underlying architecture.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Subgraph
    subgraph "Frontend"
        FE["React Frontend"]:::frontend
        VITE["Build Tool (Vite)"]:::frontend
        FS["Frontend Services"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend"
        BE["FastAPI Backend Server"]:::backend
        AUTH["Authentication Module"]:::backend
        MD["Market Data Router"]:::backend
        PORTF["Portfolio Router"]:::backend
        RISK["Risk Analysis Router (with ML)"]:::backend
        SENT["Sentiment Analysis Router (with NLP)"]:::backend
        DBIF["Database Interface"]:::backend
        MODELS["Data Models & Schemas"]:::backend
    end

    %% External Database Node
    DATABASE["PostgreSQL Database"]:::database

    %% Deployment Subgraph
    subgraph "Deployment"
        RENDERCFG["Render Config File"]:::deployment
        RENDERDOC["Render Deployment Docs"]:::deployment
    end

    %% Connections between Frontend and Backend
    FE -->|"APIcalls"| BE
    %% Internal Frontend Connections
    FE --- VITE
    FE --- FS

    %% Internal Backend Connections
    BE -->|"authrequests"| AUTH
    BE -->|"marketdata"| MD
    BE -->|"portfoliorequests"| PORTF
    BE -->|"riskanalysis"| RISK
    BE -->|"sentimentanalysis"| SENT
    BE -->|"dbqueries"| DBIF
    DBIF -->|"datasync"| DATABASE
    BE --- MODELS
    DBIF --- MODELS

    %% Deployment Connections
    RENDERCFG --- FE
    RENDERCFG --- BE
    RENDERDOC --- FE
    RENDERDOC --- BE

    %% Click Events for Frontend
    click FE "https://github.com/gitpranav04/indivest/tree/main/frontend/"
    click VITE "https://github.com/gitpranav04/indivest/blob/main/frontend/vite.config.js"
    click FS "https://github.com/gitpranav04/indivest/tree/main/frontend/src/services/"

    %% Click Events for Backend
    click BE "https://github.com/gitpranav04/indivest/blob/main/backend/app/main.py"
    click AUTH "https://github.com/gitpranav04/indivest/blob/main/backend/app/auth/auth.py"
    click MD "https://github.com/gitpranav04/indivest/blob/main/backend/app/routers/market_data.py"
    click PORTF "https://github.com/gitpranav04/indivest/blob/main/backend/app/routers/portfolio.py"
    click RISK "https://github.com/gitpranav04/indivest/blob/main/backend/app/routers/risk_analysis.py"
    click SENT "https://github.com/gitpranav04/indivest/blob/main/backend/app/routers/sentiment_analysis.py"
    click DBIF "https://github.com/gitpranav04/indivest/blob/main/backend/app/database.py"
    click MODELS "https://github.com/gitpranav04/indivest/tree/main/backend/app/models/"

    %% Click Events for Deployment
    click RENDERCFG "https://github.com/gitpranav04/indivest/blob/main/render.yaml"
    click RENDERDOC "https://github.com/gitpranav04/indivest/blob/main/RENDER_DEPLOYMENT.md"

    %% Style Definitions
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px,stroke-dasharray: 5, 5;
    classDef deployment fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    
    %% Additional connection annotations for clarity
    class FE,VITE,FS frontend;
    class BE,AUTH,MD,PORTF,RISK,SENT,DBIF,MODELS backend;
    class DATABASE database;
    class RENDERCFG,RENDERDOC deployment;
```
