# narenkram/steadfast-monorepo architecture

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

- Interactive diagram: https://gitdiagram.com/narenkram/steadfast-monorepo
- Repository: https://github.com/narenkram/steadfast-monorepo

## Overview

##### High-Level Architecture Overview

a. Frontend (steadfast-app)
b. Backend API (steadfast-api)
c. WebSocket Services (steadfast-websocket)

A. Client Layer:
- Two themes (Light/Dark mode) indication
- Main UI components mentioned in screenshots (Settings, LTP Range Bar, Trading Keys, Broker Management)

B. Server Layer:
- Steadfast-api in the middle
- RESTful API endpoints
- Broker integration interfaces

C. Real-time Layer:
- Steadfast-websocket at the bottom
- Two separate WebSocket servers:
- Flattrade WebSocket (Port 8765)
- Shoonya WebSocket (Port 8766)

##### Connection and Data Flow

- Frontend to Backend API communication (HTTP/HTTPS)
- Frontend to WebSocket connections (WS/WSS)
- Backend API to Broker services
- WebSocket services to market data providers

##### Additional Elements

Include:
- Port numbers (5173, 3000, 8765, 8766)
- Technology stack indicators (Node.js, Python)
- Security layer representations
- Data persistence layers (if any)

##### Notes Section

A notes section indicating:
- System requirements
- Critical dependencies
- Security warnings
- Version differences

##### Broker integration points

Remember to indicate that this is the open-source version and may have differences from the premium version available at steadfastapp.in.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Components
    subgraph Client["Client Layer"]
        Frontend["Frontend Application\n(steadfast-app)"]:::frontend
        ThemeLight["Light Theme"]:::ui
        ThemeDark["Dark Theme"]:::ui
        Settings["Settings Panel"]:::ui
        LTPRange["LTP Range Bar"]:::ui
        TradingKeys["Trading Keys"]:::ui
        BrokerMgmt["Broker Management"]:::ui
    end

    subgraph Server["Server Layer"]
        API["Backend API\n(steadfast-api)"]:::backend
        APIEndpoints["RESTful Endpoints"]:::api
        BrokerIntegration["Broker Integration\nInterface"]:::integration
    end

    subgraph Realtime["Real-time Layer"]
        WSService["WebSocket Services\n(steadfast-websocket)"]:::websocket
        FlattradeWS["Flattrade WS\n(Port 8765)"]:::ws
        ShoonyaWS["Shoonya WS\n(Port 8766)"]:::ws
    end

    %% External Services
    ExternalBrokers["External Brokers"]:::external
    MarketData["Market Data Providers"]:::external

    %% Connections
    Frontend --> |HTTP/HTTPS| API
    Frontend --> |WS/WSS| WSService
    API --> |Integration| ExternalBrokers
    WSService --> |Real-time Data| MarketData
    
    %% UI Component Relations
    Frontend --> ThemeLight
    Frontend --> ThemeDark
    Frontend --> Settings
    Frontend --> LTPRange
    Frontend --> TradingKeys
    Frontend --> BrokerMgmt

    %% Server Component Relations
    API --> APIEndpoints
    API --> BrokerIntegration
    WSService --> FlattradeWS
    WSService --> ShoonyaWS

    %% Legend
    subgraph Legend
        L1["Frontend Component"]:::frontend
        L2["Backend Service"]:::backend
        L3["WebSocket Service"]:::websocket
        L4["External Service"]:::external
        L5["UI Component"]:::ui
    end

    %% Click Events
    click Frontend "https://github.com/narenkram/steadfast-monorepo/tree/main/steadfast-app"
    click API "https://github.com/narenkram/steadfast-monorepo/tree/main/steadfast-api"
    click WSService "https://github.com/narenkram/steadfast-monorepo/tree/main/steadfast-websocket"

    %% Styles
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef websocket fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef external fill:#757575,stroke:#424242,color:white
    classDef ui fill:#03A9F4,stroke:#0277BD,color:white
    classDef ws fill:#7B1FA2,stroke:#4A148C,color:white
    classDef api fill:#66BB6A,stroke:#2E7D32,color:white
    classDef integration fill:#81C784,stroke:#2E7D32,color:white
```
