# hemanta12/trackyourfinance architecture

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

- Interactive diagram: https://gitdiagram.com/hemanta12/trackyourfinance
- Repository: https://github.com/hemanta12/trackyourfinance

## Overview

##### Project Type and Purpose
- Full-stack web application for personal finance management.
- Frontend: React + Redux (SPA) served likely via Vercel.
- Backend: Node.js + Express REST API.
- Persistence: MySQL database.
- Authentication: JWT + Google OAuth (Passport).
- File processing: multer + custom PDF/CSV parsers.

##### File Structure & README Insights
- Top-level “frontend” and “backend” folders indicate a two-tier architecture.
- Backend follows an MVC-style layering:
– config/ (DB, multer, passport)
– routes/ → controllers/ → services/ → utils/
- Frontend organized by pages, components (analytics, forms, lists, settings), Redux slices, and shared services.
- Dockerfile and .dockerignore in backend hint at containerization capability.

##### Main Components
a. Client / User Browser (React SPA)
b. Frontend Application
– React Components & Pages
– Redux Store & Slices
– HTTP Client (Axios)
c. Backend Application (Node.js + Express)
– Middleware Layer (CORS, JWT auth, Passport Google OAuth)
– Router Layer (authRoutes, expenseRoutes, etc.)
– Controller Layer
– Service Layer (business logic: expenseService, statementService, merchantService)
– Parser Modules (csvProcessor, pdfProcessor, transactionParser)
– Utility Layer (assignCategory, dateUtils, logger)
d. File Storage (local file system via multer)
e. MySQL Database
f. External Service: Google OAuth Identity Provider

##### Relationships and Data Flows
- User interacts with React UI → dispatches Redux actions → calls api.js (Axios) → hits Express endpoints
- Express middleware validates JWT or initiates Google OAuth handshake
- Router dispatches to Controller → calls Service → interacts with MySQL via config/db.js
- File upload endpoints accept CSV/PDF → multer writes to disk → parser modules extract transactions → services persist them
- Services use utils (assignCategory, dateUtils) to augment data before saving
- Responses bubble back through controllers → HTTP → frontend → Redux state → UI
- Logs captured via utils/logger in backend

##### Architectural Patterns & Design Principles
- Layered (Controller → Service → Data Access) for separation of concerns
- MVC-style routing and controllers
- Modular parsers for extensibility (add new file types easily)
- Redux in frontend for predictable state management
- Containerization readiness (Dockerfile)

##### Detailed Checklist
[ ] Frontend Browser UI (React Components + Redux)
[ ] HTTP Client → API Server (Express)
[ ] Middleware Layer (JWT & Passport)
[ ] Router → Controller → Service → DB Access
[ ] File Upload Path → multer → parsers → services
[ ] MySQL Database schema (Users, Expenses, Income, Budgets, Categories)
[ ] External Google OAuth flow
[ ] Docker Container boundary (optional)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Container" 
        direction TB
        Browser["User Browser (React SPA)"]:::external
        Components["React Components & Pages"]:::frontend
        Store["Redux Store & Slices"]:::frontend
        HTTPClient["HTTP Client (Axios)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Container" 
        direction TB
        API["Express REST API"]:::backend
        subgraph "Middleware Layer"
            direction TB
            JWT["JWT Middleware"]:::backend
            OAuth["Passport Google OAuth"]:::backend
        end
        subgraph "Router Layer"
            direction TB
            Routes["API Routes"]:::backend
        end
        subgraph "Controller Layer"
            direction TB
            Controllers["Controllers"]:::backend
        end
        subgraph "Service Layer"
            direction TB
            Services["Business Logic Services"]:::business
        end
        subgraph "Parser Modules"
            direction TB
            Parsers["CSV/PDF/Transaction Parsers"]:::backend
        end
        subgraph "Utility Layer"
            direction TB
            Utils["Utility Modules"]:::backend
        end
        subgraph "Configuration"
            direction TB
            DBConfig["DB & App Config"]:::backend
            MulterConfig["Multer Config"]:::backend
        end
    end

    %% Data Stores & External
    subgraph "Data Stores & External" 
        direction TB
        MySQL["MySQL Database"]:::datastore
        FileStore["File Storage (Multer)"]:::datastore
        GoogleOAuth["Google OAuth Provider"]:::external
    end

    %% Connections
    Browser -->|"interacts with"| Components
    Components -->|"dispatch actions"| Store
    Store -->|"calls"| HTTPClient
    HTTPClient -->|"HTTP/HTTPS"| API
    API -->|"/routes"| JWT
    API -->|"/routes"| OAuth
    JWT -->|validates| Routes
    OAuth -->|auth flow| GoogleOAuth
    Routes -->|calls| Controllers
    Controllers -->|invokes| Services
    Services -->|uses| Parsers
    Services -->|uses| Utils
    Services -->|queries| DBConfig
    Parsers -->|reads/writes| FileStore
    Controllers -->|logs| Utils
    DBConfig -->|connects| MySQL

    %% Click Events
    click Components "https://github.com/hemanta12/trackyourfinance/tree/main/frontend/src/components/"
    click Store "https://github.com/hemanta12/trackyourfinance/blob/main/frontend/src/redux/store.js"
    click HTTPClient "https://github.com/hemanta12/trackyourfinance/blob/main/frontend/src/services/api.js"
    click API "https://github.com/hemanta12/trackyourfinance/blob/main/backend/index.js"
    click JWT "https://github.com/hemanta12/trackyourfinance/blob/main/backend/middlewares/jwtMiddleware.js"
    click OAuth "https://github.com/hemanta12/trackyourfinance/blob/main/backend/config/passport.js"
    click Routes "https://github.com/hemanta12/trackyourfinance/tree/main/backend/routes/"
    click Controllers "https://github.com/hemanta12/trackyourfinance/tree/main/backend/controllers/"
    click Services "https://github.com/hemanta12/trackyourfinance/tree/main/backend/services/"
    click Parsers "https://github.com/hemanta12/trackyourfinance/tree/main/backend/parsers/"
    click Utils "https://github.com/hemanta12/trackyourfinance/tree/main/backend/utils/"
    click MulterConfig "https://github.com/hemanta12/trackyourfinance/blob/main/backend/config/multerConfig.js"
    click DBConfig "https://github.com/hemanta12/trackyourfinance/blob/main/backend/config/db.js"
    click GoogleOAuth "https://github.com/hemanta12/trackyourfinance/blob/main/backend/config/passport.js"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0288D1,stroke-width:1px
    classDef backend fill:#E8F5E9,stroke:#43A047,stroke-width:1px
    classDef business fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
    classDef datastore fill:#FFE0B2,stroke:#FB8C00,stroke-width:1px
    classDef external fill:#ECEFF1,stroke:#607D8B,stroke-width:1px
```
