# frank5ive/personal-finance-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/frank5ive/personal-finance-tracker
- Repository: https://github.com/frank5ive/personal-finance-tracker

## Overview

##### Component Breakdown

a. Client Layer:
- Subdivide into main functional blocks:
- Authentication (LoginModal, SignUpModal)
- Dashboard Components (ChartsSection, OverviewCards)
- Transaction Management
- Settings Management
- Service Layer (API integration services)

b. Application Layer:
- API Routes (group by functionality)
- Controllers
- Middleware (especially Auth)
- Clear separation between:
- Business Logic (Controllers)
- Authentication/Authorization
- Data Access Layer (Models)

c. Data Layer:
- MySQL Database
- File Storage (for CSV data and reports)

##### Connections and Data Flow

- Frontend-Backend communication via REST API
- Backend-Database interactions
- Authentication flow
- ML service integration

##### Specific Implementation Details

Frontend Section:
**Web Client**
- Public Components
- Landing Page
- Protected Components
- Dashboard
- Transaction Management
- Settings
- Service Layer
- API Services

Backend Section:
**Express Server**
- API Routes
- Controllers
- Models
- Middleware
- Utils

ML Service Section:
**Python ML Service**
- Data Processing
- Prediction Generation

##### Additional Elements

- JWT Authentication flow
- External services integration points
- Data backup/export functionality
- Notification system

##### Technical Details

- Node.js/Express backend
- React frontend
- MySQL database
- JWT authentication
- Python ML service
- RESTful API endpoints

##### Notes Section

A small notes section indicating:
- Security implementations
- Scalability considerations
- Key technical dependencies
- Database schema references

Remember to:
- Use consistent styling
- Related components
- Clear boundaries between systems
- Version information
- Important configuration notes

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#4A90E2,color:white
    classDef backend fill:#45B7AF,color:white
    classDef database fill:#FF8C00,color:white
    classDef ml fill:#9B59B6,color:white
    classDef security fill:#E74C3C,color:white
    classDef service fill:#2ECC71,color:white

    %% Client Layer
    subgraph ClientLayer
        Browser["Web Browser"]
        subgraph FrontendComponents
            Auth["Authentication Components"]:::frontend
            DashboardComp["Dashboard Components"]:::frontend
            TransactionComp["Transaction Management"]:::frontend
            SettingsComp["Settings Management"]:::frontend
            ServiceLayer["Service Layer"]:::frontend
        end
    end

    %% Application Layer
    subgraph ApplicationLayer
        ExpressServer["Express.js Server"]
        
        subgraph APIRoutes
            AuthRoutes["Auth Routes"]:::backend
            TransRoutes["Transaction Routes"]:::backend
            CategoryRoutes["Category Routes"]:::backend
            UserRoutes["User Routes"]:::backend
            NotifRoutes["Notification Routes"]:::backend
        end
        
        subgraph Controllers
            AuthController["Auth Controller"]:::backend
            TransController["Transaction Controller"]:::backend
            UserController["User Controller"]:::backend
        end
        
        subgraph Middleware
            AuthMiddleware["Auth Middleware"]:::security
        end
        
        subgraph MLService
            PythonML["Trend Predictor"]:::ml
        end
    end

    %% Data Layer
    subgraph DataLayer
        MySQL[(MySQL Database)]:::database
        
        subgraph Models
            UserModel["User Model"]:::backend
            TransModel["Transaction Model"]:::backend
            CategoryModel["Category Model"]:::backend
            NotifModel["Notification Model"]:::backend
        end
    end

    %% Connections
    Auth --> ServiceLayer
    DashboardComp --> ServiceLayer
    TransactionComp --> ServiceLayer
    SettingsComp --> ServiceLayer
    
    ServiceLayer --> APIRoutes
    
    APIRoutes --> Controllers
    Controllers --> Models
    Models --> MySQL
    
    Controllers --> PythonML
    PythonML --> MySQL
    
    AuthRoutes --> AuthMiddleware

    %% Click Events
    click Auth "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/frontend/personal-finance-tracker-frontend/src/components/LoginModal.js"
    click DashboardComp "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/frontend/personal-finance-tracker-frontend/src/components/Dashboard/Dashboard.js"
    click TransactionComp "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/frontend/personal-finance-tracker-frontend/src/components/AddTransaction/AddTransaction.js"
    click SettingsComp "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/frontend/personal-finance-tracker-frontend/src/components/Settings/ProfileSettings.js"
    click ServiceLayer "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/frontend/personal-finance-tracker-frontend/src/Services/api.js"
    click AuthRoutes "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/routes/authRoutes.js"
    click TransRoutes "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/routes/transactionRoutes.js"
    click CategoryRoutes "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/routes/categoryRoutes.js"
    click UserRoutes "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/routes/userRoutes.js"
    click NotifRoutes "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/routes/notificationRoutes.js"
    click AuthController "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/controllers/authController.js"
    click TransController "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/controllers/transactionController.js"
    click UserController "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/controllers/userController.js"
    click AuthMiddleware "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/middlewares/authMiddleware.js"
    click PythonML "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/python_script/trend_predictor.py"
    click UserModel "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/models/User.js"
    click TransModel "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/models/Transaction.js"
    click CategoryModel "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/models/Category.js"
    click NotifModel "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/src/models/Notification.js"
    click MySQL "https://github.com/Frank5ive/Personal-Finance-Tracker/blob/master/backend/Database/databaseSchema.sql"
```
