# priyanshu9898/expense-tracker-app architecture

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

- Interactive diagram: https://gitdiagram.com/priyanshu9898/expense-tracker-app
- Repository: https://github.com/priyanshu9898/expense-tracker-app

## Overview

##### Project Type and Purpose
- This is a full-stack MERN application for tracking and managing user expenses.
- Users interact via a React single-page application; the backend exposes a RESTful API (Node.js + Express); data is persisted in MongoDB; authentication uses JWT.

##### File Structure
- frontend/: React app
- public/: static HTML, manifest, robots.txt
- src/Pages/Auth, Avatar, Home: UI pages and forms
- src/components: reusable widgets (progress bars, spinner)
- src/utils/ApiRequest.js: API calls
- backend/: Express server
- Routers: route definitions (userRouter.js, Transactions.js)
- controllers: business logic (userController, transactionController)
- models: Mongoose schemas (UserSchema, TransactionModel)
- DB/Database.js: MongoDB connection setup
- app.js: main Express app with middleware (JWT auth)

##### README for Insights
- Confirms MERN stack, JWT-based auth, AWS Amplify hosting for frontend, Render for backend, CI/CD pipelines.
- Lists major features: user sign-up/login, CRUD on expenses/categories, dashboards with charts.

a. Components to include:
- User’s Browser (React SPA)
- Frontend Hosting (AWS Amplify)
- HTTP/S Client (Axios calls via ApiRequest.js)
- Backend API (Express server on Render)
– Routers → Controllers → Models → Database Layer
- Authentication Middleware (JWT verification)
- MongoDB (Atlas)
- External Libraries (tsparticles, react-datepicker)
- CI/CD Pipeline (GitHub → AWS/Render)
b. Interactions / Data Flows:
1. User → React UI (login, form submit)
2. React → HTTP requests → Express endpoints
3. Express JWT middleware validates token → controllers
4. Controllers call Mongoose models → MongoDB
5. DB responds → controllers → routers → React
6. React renders updated UI (charts, tables)
c. Architectural Patterns:
- Layered Architecture (Presentation → API → Service/Controller → Data)
- MVC-like in backend (Routers = C, Models = M, Controllers = V/logic)
- Client-server separation, RESTful API
d. Key Technologies:
- Backend: Node.js, Express.js, JWT, Mongoose
- Database: MongoDB Atlas
- Deployment: AWS Amplify (frontend), Render (backend)
- CI/CD: GitHub Actions or similar

##### Essential Details
- Middleware layer for JWT token verification.
- Environment variables (MONGO_URL, PORT).
- Configuration module (Database.js) initializing the DB connection.
- Core endpoints (e.g., POST /api/auth/login, GET /api/transactions).
- Use of third-party libraries where they affect architecture (tsparticles for UI effect).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "React App (Browser)" 
        direction TB
        SPA["React SPA<br/>(App.js)"]:::frontend
        subgraph "Public Assets" 
            direction TB
            IndexHTML["index.html"]:::frontend
            Manifest["manifest.json"]:::frontend
            Robots["robots.txt"]:::frontend
        end
        APIClient["ApiRequest.js<br/>(Axios Client)"]:::frontend
        subgraph "Pages"
            direction TB
            Login["Login.js"]:::frontend
            Register["Register.js"]:::frontend
            AvatarPage["setAvatar.js"]:::frontend
            subgraph "Home Dashboard"
                direction TB
                HomePage["Home.js"]:::frontend
                ActionBox["ActionBox.js"]:::frontend
                Analytics["Analytics.js"]:::frontend
                CardBox["CardBox.js"]:::frontend
                ModelForm["ModelForm.js"]:::frontend
                TableData["TableData.js"]:::frontend
            end
        end
        subgraph "Components"
            direction TB
            CircularPB["CircularProgressBar.js"]:::frontend
            LinePB["LineProgressBar.js"]:::frontend
            Spinner["Spinner.js"]:::frontend
            Particle["Particle.js"]:::frontend
            Header["Header.js"]:::frontend
        end
    end

    %% Deployment & CI/CD
    Amplify["AWS Amplify"]:::external
    Render["Render.com<br/>(Express Host)"]:::external
    CICD["GitHub Actions"]:::external

    %% Backend Layer
    subgraph "Express API" 
        direction TB
        App["app.js"]:::backend
        AuthMW["JWT Middleware"]:::backend
        subgraph "Routers"
            direction TB
            UserRouter["userRouter.js"]:::backend
            TxRouter["Transactions.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            UserCtrl["userController.js"]:::backend
            TxCtrl["transactionController.js"]:::backend
        end
        subgraph "Models"
            direction TB
            UserModel["UserSchema.js"]:::backend
            TxModel["TransactionModel.js"]:::backend
        end
        DBConn["Database.js<br/>(MongoDB Conn)"]:::backend
    end

    %% Database
    MongoDB["MongoDB Atlas"]:::db

    %% Connections
    SPA -->|uses| APIClient
    SPA -->|renders| Pages
    SPA -->|imports| Components
    SPA -->|hosts on| Amplify
    Amplify -->|deploys| SPA
    APIClient -->|HTTP/S JSON| App
    App -->|uses| AuthMW
    App -->|routes to| UserRouter
    App -->|routes to| TxRouter
    UserRouter -->|calls| UserCtrl
    TxRouter -->|calls| TxCtrl
    UserCtrl -->|queries| UserModel
    TxCtrl -->|queries| TxModel
    DBConn -->|connects| MongoDB
    UserModel -->|via Mongoose| DBConn
    TxModel -->|via Mongoose| DBConn
    App -->|connects| DBConn
    App -->|hosts on| Render
    CICD -->|builds & deploys| Amplify
    CICD -->|builds & deploys| Render

    %% Click Events
    click SPA "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/App.js"
    click IndexHTML "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/public/index.html"
    click Manifest "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/public/manifest.json"
    click Robots "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/public/robots.txt"
    click APIClient "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/utils/ApiRequest.js"
    click Login "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Auth/Login.js"
    click Register "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Auth/Register.js"
    click AvatarPage "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Avatar/setAvatar.js"
    click HomePage "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Home/Home.js"
    click ActionBox "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Home/ActionBox.js"
    click Analytics "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Home/Analytics.js"
    click CardBox "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Home/CardBox.js"
    click ModelForm "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Home/ModelForm.js"
    click TableData "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/Pages/Home/TableData.js"
    click CircularPB "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/components/CircularProgressBar.js"
    click LinePB "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/components/LineProgressBar.js"
    click Spinner "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/components/Spinner.js"
    click Particle "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/components/Particle.js"
    click Header "https://github.com/priyanshu9898/expense-tracker-app/blob/main/frontend/src/components/Header.js"
    click App "https://github.com/priyanshu9898/expense-tracker-app/blob/main/backend/app.js"
    click DBConn "https://github.com/priyanshu9898/expense-tracker-app/blob/main/backend/DB/Database.js"
    click UserRouter "https://github.com/priyanshu9898/expense-tracker-app/blob/main/backend/Routers/userRouter.js"
    click TxRouter "https://github.com/priyanshu9898/expense-tracker-app/blob/main/backend/Routers/Transactions.js"
    click UserCtrl "https://github.com/priyanshu9898/expense-tracker-app/blob/main/backend/controllers/userController.js"
    click TxCtrl "https://github.com/priyanshu9898/expense-tracker-app/blob/main/backend/controllers/transactionController.js"
    click UserModel "https://github.com/priyanshu9898/expense-tracker-app/blob/main/backend/models/UserSchema.js"
    click TxModel "https://github.com/priyanshu9898/expense-tracker-app/blob/main/backend/models/TransactionModel.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0366d6,color:#000;
    classDef backend fill:#d4edda,stroke:#28a745,color:#000;
    classDef db fill:#fff3cd,stroke:#856404,color:#000;
    classDef external fill:#e2e3e5,stroke:#6f42c1,color:#000;
```
