# swamini-jadhav/finiq architecture

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

- Interactive diagram: https://gitdiagram.com/swamini-jadhav/finiq
- Repository: https://github.com/swamini-jadhav/finiq

## Overview

##### Project type and purpose
- FinIQ is a full-stack MERN application augmented by a separate Flask-based ML microservice.
- Purpose: provide authenticated users with stock price forecasts (LSTM), news sentiment analysis, AI chatbot insights, and an interactive dashboard.

##### File structure
- Top-level folders:
- backend/ – Node.js + Express REST API, MongoDB models, Passport JWT auth, business logic & routing
- frontend/ – React single-page app, TailwindCSS, React Router, Chart.js, Axios calls to backend
- ml-service/ – Flask microservice exposing LSTM prediction, sentiment analysis & chatbot endpoints
- Key patterns:
- MVC-style in backend (models/, routes/, middleware/)
- “context” pattern in React for auth state
- Microservice architecture: ML algorithms isolated in Flask container
- Config & deployment files: package.json in each service, requirements.txt for ml-service, .gitignore

##### README for additional insights
- Auth: signup/signin with JWT issued by backend
- ML Service:
- LSTM network (PyTorch) for 60-day lookback price forecasting
- TextBlob + NewsAPI for sentiment scoring
- Chatbot logic in chatbot.py
- Dashboard: real-time Chart.js visualizations
- External dependencies: MongoDB Atlas (or self-hosted), NewsAPI

a. Main components
- Web Client (React SPA)
- API Server (Node.js/Express)
- ML Microservice (Flask)
- Database (MongoDB)
- External Services (NewsAPI, optional yfinance endpoint)
- End user/browser
b. Relationships & data flows
1. Browser ↔️ React app (user actions, routing)
2. React → Express API (Axios calls to /auth, /chatbot, /ml)
3. Express API ↔️ MongoDB (Mongoose CRUD for users & historical data)
4. Express API → Flask ML Service endpoints (HTTP REST: /predict, /sentiment, /chat)
5. Flask ML Service ↔️ External APIs (NewsAPI, yfinance)
6. Flask returns ML results → Express → React
c. Architectural patterns
- Microservices: decoupled ML logic in its own container
- MVC in backend: Models, Routes (Controllers), Middleware
- JWT-based stateless auth
- Context API in React for global state (AuthContext)
d. Key technologies
- Frontend: React.js, TailwindCSS, Chart.js, Axios, React Router
- Backend: Node.js, Express, Mongoose, Passport.js, JWT
- ML Service: Flask, PyTorch, TextBlob, yfinance, NewsAPI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Frontend Layer
    EndUser("End User"):::user
    Browser("Browser"):::frontend
    WebClient("Web Client (React SPA)"):::frontend
    EntryPoint("React App Entry Point"):::frontend
    AppComponent("React Routing & Main Component"):::frontend
    AuthCtx("Auth Context (global auth state)"):::frontend
    APIUtil("API Utility (Axios calls)"):::frontend
    Dashboard("Dashboard Page"):::frontend
    LoginPage("Login Page"):::frontend
    RegisterPage("Register Page"):::frontend
    ChatbotUI("Chatbot UI Component"):::frontend
    NewsCard("News Sentiment Card Component"):::frontend
    PredChart("Stock Prediction Chart Component"):::frontend

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        APIServer("API Server (Node.js/Express)"):::backend
        ServerEntry("Server Entry Point"):::backend
        AuthRoutes("Authentication Routes"):::backend
        ChatbotRoutes("Chatbot Routes"):::backend
        MLProxyRoutes("ML Proxy Routes"):::backend
        UserModel("User Model (Mongoose)"):::backend
        PassportConfig("JWT Passport Configuration"):::backend
        AuthMiddleware("Auth Middleware"):::backend
        Database[(MongoDB)]:::database
    end

    %% ML Microservice Layer
    subgraph "ML Microservice"
        direction TB
        FlaskService("ML Service (Flask)"):::ml
        FlaskApp("Flask App & REST Endpoints"):::ml
        LSTMModel("LSTM Prediction Logic"):::ml
        SentimentLogic("Sentiment Analysis Logic"):::ml
        ChatbotLogic("Chatbot Logic"):::ml
    end

    %% External Services
    subgraph "External Services"
        direction TB
        NewsAPI("NewsAPI"):::external
        YFinance("yfinance API"):::external
    end

    %% Connections
    EndUser -->|"interacts via"| Browser
    Browser -->|"loads"| WebClient
    WebClient -->|"bootstraps via"| EntryPoint
    EntryPoint -->|"renders"| AppComponent
    AppComponent --> AuthCtx
    AppComponent --> APIUtil
    AppComponent --> Dashboard
    AppComponent --> LoginPage
    AppComponent --> RegisterPage
    AppComponent --> ChatbotUI
    AppComponent --> NewsCard
    AppComponent --> PredChart

    APIUtil -->|"HTTP/JSON"| APIServer
    AuthRoutes -->|"issues JWT"| PassportConfig
    APIServer -->|"uses"| ServerEntry
    APIServer --> AuthRoutes
    APIServer --> ChatbotRoutes
    APIServer --> MLProxyRoutes
    APIServer --> UserModel
    APIServer --> AuthMiddleware
    APIServer --> Database
    MLProxyRoutes -->|"forwards to"| FlaskApp
    FlaskApp --> LSTMModel
    FlaskApp --> SentimentLogic
    FlaskApp --> ChatbotLogic
    SentimentLogic --> NewsAPI
    LSTMModel --> YFinance
    FlaskApp --> APIServer

    APIServer -->|"responds JSON"| APIUtil
    APIUtil -->|"updates UI"| AppComponent

    %% Click Events
    click WebClient "https://github.com/swamini-jadhav/finiq/tree/main/frontend/"
    click EntryPoint "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/index.js"
    click AppComponent "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/App.js"
    click AuthCtx "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/context/AuthContext.js"
    click APIUtil "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/utils/api.js"
    click Dashboard "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/pages/Dashboard.js"
    click LoginPage "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/pages/Login.js"
    click RegisterPage "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/pages/Register.js"
    click ChatbotUI "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/components/Chatbot.js"
    click NewsCard "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/components/NewsCard.js"
    click PredChart "https://github.com/swamini-jadhav/finiq/blob/main/frontend/src/components/PredictionChart.js"
    click APIServer "https://github.com/swamini-jadhav/finiq/tree/main/backend/"
    click ServerEntry "https://github.com/swamini-jadhav/finiq/blob/main/backend/server.js"
    click AuthRoutes "https://github.com/swamini-jadhav/finiq/blob/main/backend/routes/auth.js"
    click ChatbotRoutes "https://github.com/swamini-jadhav/finiq/blob/main/backend/routes/chatbot.js"
    click MLProxyRoutes "https://github.com/swamini-jadhav/finiq/blob/main/backend/routes/ml.js"
    click UserModel "https://github.com/swamini-jadhav/finiq/blob/main/backend/models/User.js"
    click PassportConfig "https://github.com/swamini-jadhav/finiq/blob/main/backend/config/passport.js"
    click AuthMiddleware "https://github.com/swamini-jadhav/finiq/blob/main/backend/middleware/auth.js"
    click FlaskService "https://github.com/swamini-jadhav/finiq/tree/main/ml-service/"
    click FlaskApp "https://github.com/swamini-jadhav/finiq/blob/main/ml-service/app.py"
    click LSTMModel "https://github.com/swamini-jadhav/finiq/blob/main/ml-service/lstm_model.py"
    click SentimentLogic "https://github.com/swamini-jadhav/finiq/blob/main/ml-service/sentiment_analysis.py"
    click ChatbotLogic "https://github.com/swamini-jadhav/finiq/blob/main/ml-service/chatbot.py"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef ml fill:#FFF3E0,stroke:#E65100,color:#BF360C
    classDef database fill:#FCE4EC,stroke:#880E4F,color:#AD1457
    classDef external fill:#ECEFF1,stroke:#37474F,color:#263238
    classDef user fill:#FFFFFF,stroke:#000000,color:#000000,stroke-dasharray: 2 2
```
