# darshan1606/expense-task architecture

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

- Interactive diagram: https://gitdiagram.com/darshan1606/expense-task
- Repository: https://github.com/darshan1606/expense-task

## Overview

##### Project type and purpose
- This is a full-stack web application for tracking expenses (client: React SPA; server: Node/Express REST API; DB: PostgreSQL).
- The README describes setup steps for the Postgres schema, server env, and client env.

##### File structure
- Top-level folders:
- client/ – React front-end (components, routes, services, store, views)
- server/ – Express back-end (routes, controllers, services, models, middleware, validations)
- Architectural patterns:
- Front-end: component-based UI, client-side routing, Redux store, service layer for API calls
- Back-end: MVC-style layering (routes → controllers → services → models), JWT auth middleware
- Config & deployment:
- server/.env for DB & JWT secrets
- client/.env for server URL & build mode

##### README for additional insights
- SQL schema: categories, users, expenses tables with foreign keys
- Environment variables: Postgres config, JWT secret, admin credentials
- npm scripts: start server & client

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        UI["UI Components"]:::client
        Routing["Routing Layer"]:::client
        ClientService["Service Layer (API Calls)"]:::client
        Store["State Store (Redux)"]:::client
        ValidationsClient["Validation Schemas"]:::client
        Views["Views (Pages/Containers)"]:::client
        EntryClient["Client Entry & Config"]:::client
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        EntryServer["API Gateway (Express)"]:::server
        Middleware["Auth Middleware"]:::server
        Routes["Routes"]:::server
        Controllers["Controllers"]:::server
        ServerServices["Server Services"]:::server
        Models["Server Models"]:::server
        DBConfig["DB Configuration"]:::server
        Constants["Environment Constants"]:::server
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DB["PostgreSQL Database"]:::db
        Tables["Tables: categories, users, expenses"]:::db
    end

    %% Data Flow
    UI -->|"renders & events"| Routing
    Routing -->|"calls"| ClientService
    ClientService -->|"HTTP Request"| EntryServer
    EntryServer -->|calls| Middleware
    Middleware -->|forwards| Routes
    Routes -->|delegates to| Controllers
    Controllers -->|uses| ServerServices
    ServerServices -->|accesses| Models
    Models -->|queries| DB
    DB -->|results| Models
    Models -->|returns| ServerServices
    ServerServices -->|returns| Controllers
    Controllers -->|responds| EntryServer
    EntryServer -->|"HTTP Response"| ClientService
    ClientService -->|dispatches| Store
    Store -->|updates| UI

    %% Click Events for Presentation
    click UI "https://github.com/darshan1606/expense-task/tree/main/client/src/components/"
    click Routing "https://github.com/darshan1606/expense-task/tree/main/client/src/routes/"
    click ClientService "https://github.com/darshan1606/expense-task/blob/main/client/src/services/api.js"
    click Store "https://github.com/darshan1606/expense-task/blob/main/client/src/store/index.js"
    click ValidationsClient "https://github.com/darshan1606/expense-task/blob/main/client/src/validations/loginSchema.js"
    click Views "https://github.com/darshan1606/expense-task/tree/main/client/src/views/"
    click EntryClient "https://github.com/darshan1606/expense-task/blob/main/client/src/index.js"

    %% Click Events for Application
    click EntryServer "https://github.com/darshan1606/expense-task/blob/main/server/index.js"
    click Routes "https://github.com/darshan1606/expense-task/blob/main/server/routes/index.js"
    click Middleware "https://github.com/darshan1606/expense-task/blob/main/server/middleware/authMiddleware.js"
    click Controllers "https://github.com/darshan1606/expense-task/blob/main/server/controller/authController.js"
    click ServerServices "https://github.com/darshan1606/expense-task/blob/main/server/services/authService.js"
    click Models "https://github.com/darshan1606/expense-task/blob/main/server/models/userModel.js"
    click DBConfig "https://github.com/darshan1606/expense-task/blob/main/server/config/db.js"
    click Constants "https://github.com/darshan1606/expense-task/blob/main/server/constants/env.constant.js"

    %% Click Events for Data Layer
    click Tables "https://github.com/darshan1606/expense-task/blob/main/server/config/db.js"

    classDef client fill:#D0E8FF,stroke:#000
    classDef server fill:#D0FFD0,stroke:#000
    classDef db fill:#FFE8A0,stroke:#000
```
