# karthikreddy-7/infytrade architecture

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

- Interactive diagram: https://gitdiagram.com/karthikreddy-7/infytrade
- Repository: https://github.com/karthikreddy-7/infytrade

## Overview

##### Project type and purpose
- From the README and file‐tree we see InfyTrade is a full-stack, containerized web trading platform.
- Frontend: a ReactJS SPA with ChartJS visualizations and TailwindCSS/DaisyUI.
- Backend: a NestJS monolith (modularized by feature: Users, Stocks, Portfolios, MLmodels, etc.), backed by PostgreSQL.
- Auxiliary service: a NodeJS cron job to fetch stock prices into the database.

##### File structure
- Top-level directories:
- frontend/infytradefe – React app, public assets, API wrappers, Redux store, components.
- backend/pms – NestJS application, composed of modules (Community, Dashboards, MLmodels, …), TypeORM entities, DTOs, controllers and services, plus Dockerfile and docker-compose.yml.
- backend/stock-price-cron – standalone NodeJS cron job.
- Configuration and infra: Dockerfiles, docker-compose.yml under backend/pms, .env in frontend, tsconfig, ESLint/Prettier, Gitignore.
- The NestJS app defines controllers→services→entities per feature; the React app organizes reusable UI components and Redux for state management.

##### Key insights from README
- Emphasis on real-time analytics, multiple dashboards, community & marketplace, custom & pre-defined ML models.
- Tech stack calls out React/ChartJS/Tailwind for FE, NestJS+Postgres for BE, Docker for containerization, cron job for data ingestion.

a. Main components (high-level):
- Users (Browser / ReactJS SPA)
- API Gateway / Backend Service (NestJS monolith)
- Database (PostgreSQL)
- Stock-Price Cron Worker (NodeJS)
- External Data Providers (stock/forex/crypto APIs)
- (Optional) ML Execution Engine or Jupyter-style Editor module

b. Relationships & data flows:
1. Browser → HTTP(S) → API Gateway
2. API Gateway routes requests by module (Users, Stocks, Portfolios, MLmodels, etc.).
3. Services → TypeORM → PostgreSQL
4. Cron Worker → External APIs → PostgreSQL
5. MLmodels module reads raw data → runs computation → writes results back → frontend queries for visualization.

c. Architectural patterns & design principles:
- Layered architecture (Controller → Service → Repository/Entity).
- Modularization by feature (NestJS modules).
- Single SPA with Redux for state, thunks for async API calls.
- Containerization: each service (frontend, backend, cron, DB) in its own Docker container; orchestrated via docker-compose.

d. Key technologies & frameworks:
- Frontend: React, Redux, ChartJS, TailwindCSS
- Backend: NestJS, TypeORM, PostgreSQL
- Data ingestion: Node cron job
- Infra: Docker, docker-compose

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Containers
    subgraph "Frontend (ReactJS SPA)"
        direction TB
        Frontend["ReactJS SPA"]:::frontend
        Redux["Redux Store & API Wrappers"]:::frontend
        API["API Wrappers"]:::frontend
        Analytics["Charting Components"]:::frontend
        DashboardUI["Dashboard Components"]:::frontend
        Marketplace["Marketplace UI"]:::frontend
        CommunityUI["Community UI"]:::frontend
        OrderModals["Order Modals"]:::frontend
        PortfolioViews["Portfolio Views"]:::frontend
    end

    subgraph "Backend (NestJS Monolith)"
        direction TB
        BECore["NestJS App Entry"]:::backend
        Users["Users Module"]:::backend
        Stocks["Stocks Module"]:::backend
        Portfolios["Portfolios Module"]:::backend
        MLmodels["MLmodels Module"]:::backend
        Community["Community Module"]:::backend
        Dashboards["Dashboards Module"]:::backend
        Rankings["Rankings Module"]:::backend
        Widgets["Widgets Module"]:::backend
        Holdings["Holdings Module"]:::backend
        Threads["Threads Module"]:::backend
        Dockerfile["Dockerfile"]:::backend
        Compose["docker-compose.yml"]:::backend
    end

    DB["PostgreSQL Database"]:::db
    Cron["Stock-Price Cron Worker"]:::aux
    External["External Market Data APIs"]:::external

    %% Data Flows
    Frontend -->|"HTTP(S)"| BECore
    BECore -->|"TypeORM"| DB
    Cron -->|"Fetch Prices"| External
    Cron -->|"Write Data"| DB
    BECore -->|"Optional Real-Time Calls"| External

    %% Click Events
    click Frontend "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe"
    click Redux "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe/src/redux"
    click API "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe/src/api"
    click Analytics "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe/src/components/analytics"
    click DashboardUI "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe/src/components/dashboard"
    click Marketplace "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe/src/components/marketplace"
    click CommunityUI "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe/src/components/community"
    click OrderModals "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe/src/components/orderModel"
    click PortfolioViews "https://github.com/karthikreddy-7/infytrade/tree/main/frontend/infytradefe/src/components/portfolio"
    click BECore "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src"
    click Dockerfile "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/Dockerfile"
    click Compose "https://github.com/karthikreddy-7/infytrade/blob/main/backend/pms/docker-compose.yml"
    click Users "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/Users"
    click Stocks "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/Stocks"
    click Portfolios "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/Portfolios"
    click MLmodels "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/MLmodels"
    click Community "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/Community"
    click Dashboards "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/Dashboards"
    click Rankings "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/Rankings"
    click Widgets "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/Widgets"
    click Holdings "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/holdings"
    click Threads "https://github.com/karthikreddy-7/infytrade/tree/main/backend/pms/src/threads"
    click Cron "https://github.com/karthikreddy-7/infytrade/blob/main/backend/stock-price-cron/cron-job.js"
    click DB "https://github.com/karthikreddy-7/infytrade/blob/main/backend/pms/docker-compose.yml"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0275d8,stroke-width:1px
    classDef backend fill:#DFF2D8,stroke:#5cb85c,stroke-width:1px
    classDef db fill:#FFE6CC,stroke:#f0ad4e,stroke-width:1px
    classDef aux fill:#FFF4CC,stroke:#f0ad4e,stroke-width:1px
    classDef external fill:#F0F0F0,stroke:#6c757d,stroke-width:1px
```
