# fazeelian/track-my-cash architecture

> Architecture diagram of the GitHub repository fazeelian/track-my-cash, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fazeelian/track-my-cash
- Repository: https://github.com/fazeelian/track-my-cash

## Overview

##### Project type and purpose
- This is a two-tier full-stack web application (“Track My Cash”) for personal finance management.
- The **client** is a React (TypeScript + Vite) single-page app with two main UI domains: the public/company-facing landing pages and the authenticated/admin dashboard.
- The **server** is an Express.js (TypeScript) REST API that handles authentication (JWT), CRUD operations for transactions, goals, notifications, and integrates with a database and an email service (via Nodemailer).

##### File structure
- Top-level directories:
- **client/** – React SPA with `src/components`, `src/views`, `src/services` (axios wrappers for REST endpoints), `src/lib` (hooks, types, utils), and styling under `src/assets`.
- **server/** – Express app with `src/routes` (defines REST endpoints), `src/controllers` (business-logic handlers), `src/models` (ORM or schema definitions), `src/middleware` (auth, validation), and `src/config` (DB, CORS, email).
- Architectural pattern on the server is MVC/Router-Controller-Model. The client follows a component-driven design with context/services for state and network calls.

##### README for additional insights
- The README confirms usage of JWT authentication, financial entities (transactions, goals, notifications), a dashboard with charts, and email notifications (e.g., progress/inactivity alerts).

##### Thoroughness
- Middleware chain before controllers.
- Two distinct client domains (public vs. admin) consuming the same API.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["User Browser"]:::external
        SPA["React SPA"]:::frontend
        Browser -->|Load SPA| SPA
        SPA --> Router["Router.tsx"]:::frontend

        subgraph "Public/Company Views"
            PVViews["HomeView.tsx & Auth Views"]:::frontend
            PVComp["Company Components"]:::frontend
            PVStyle["Company Styles"]:::frontend
        end
        SPA --> PVViews
        SPA --> PVComp
        SPA --> PVStyle

        subgraph "Admin Dashboard"
            ADViews["Admin Views"]:::frontend
            ADComp["Admin Components"]:::frontend
            ADStyle["Admin Styles"]:::frontend
        end
        SPA --> ADViews
        SPA --> ADComp
        SPA --> ADStyle

        subgraph "Client-Side Services"
            AuthSvc["Auth Service"]:::frontend
            TransSvc["Transactions Service"]:::frontend
            GoalSvc["Goals Service"]:::frontend
            NotifSvc["Notifications Service"]:::frontend
            CashySvc["CashyBot Service"]:::frontend
            AdminSvc["Admin Service"]:::frontend
        end
        SPA --> AuthSvc
        SPA --> TransSvc
        SPA --> GoalSvc
        SPA --> NotifSvc
        SPA --> CashySvc
        SPA --> AdminSvc

        Axios["Axios Config"]:::frontend
        Lib["Shared Types, Hooks & Utils"]:::frontend
        SPA --> Axios
        SPA --> Lib
    end

    %% Backend API Server
    subgraph "Backend API Server"
        Entry["server.ts / index.ts"]:::api
        SPA -->|HTTP + JWT| Entry

        Entry --> Routes["API Routes"]:::api
        subgraph "Express API Internals"
            Routes --> Middleware["Middleware"]:::api
            Middleware --> Controllers["Controllers"]:::api
            Controllers --> Models["Models"]:::api
        end

        Controllers --> DB["Database"]:::db
        Controllers --> EmailCfg["Nodemailer Config"]:::external
        EmailCfg --> EmailTpl["Auth Email Templates"]:::external
    end

    %% Click Events
    click SPA "https://github.com/fazeelian/track-my-cash/blob/main/client/src/main.tsx"
    click Router "https://github.com/fazeelian/track-my-cash/blob/main/client/src/Router.tsx"
    click PVViews "https://github.com/fazeelian/track-my-cash/tree/main/client/src/views"
    click PVComp "https://github.com/fazeelian/track-my-cash/tree/main/client/src/components/company"
    click PVStyle "https://github.com/fazeelian/track-my-cash/tree/main/client/src/assets/css/components/company"
    click ADViews "https://github.com/fazeelian/track-my-cash/tree/main/client/src/views/admin"
    click ADComp "https://github.com/fazeelian/track-my-cash/tree/main/client/src/components/admin"
    click ADStyle "https://github.com/fazeelian/track-my-cash/tree/main/client/src/assets/css/components/admin"
    click AuthSvc "https://github.com/fazeelian/track-my-cash/blob/main/client/src/services/auth/context.ts"
    click TransSvc "https://github.com/fazeelian/track-my-cash/blob/main/client/src/services/transactions/api.ts"
    click GoalSvc "https://github.com/fazeelian/track-my-cash/blob/main/client/src/services/goals/api.ts"
    click NotifSvc "https://github.com/fazeelian/track-my-cash/blob/main/client/src/services/notifications/api.ts"
    click CashySvc "https://github.com/fazeelian/track-my-cash/blob/main/client/src/services/cashybot/api.ts"
    click AdminSvc "https://github.com/fazeelian/track-my-cash/blob/main/client/src/services/admin/api.ts"
    click Axios "https://github.com/fazeelian/track-my-cash/blob/main/client/src/config/axios.ts"
    click Lib "https://github.com/fazeelian/track-my-cash/tree/main/client/src/lib"
    click Entry "https://github.com/fazeelian/track-my-cash/blob/main/server/src/index.ts"
    click Routes "https://github.com/fazeelian/track-my-cash/tree/main/server/src/routes"
    click Middleware "https://github.com/fazeelian/track-my-cash/tree/main/server/src/middleware"
    click Controllers "https://github.com/fazeelian/track-my-cash/tree/main/server/src/controllers"
    click Models "https://github.com/fazeelian/track-my-cash/tree/main/server/src/models"
    click DB "https://github.com/fazeelian/track-my-cash/blob/main/server/src/config/db.ts"
    click EmailCfg "https://github.com/fazeelian/track-my-cash/blob/main/server/src/config/nodemailer.ts"
    click EmailTpl "https://github.com/fazeelian/track-my-cash/blob/main/server/src/emails/AuthEmail.ts"

    %% Styles
    classDef frontend fill:#E8F4FC,stroke:#0366D6,stroke-width:1px
    classDef api fill:#F5F5F5,stroke:#333,stroke-width:1px
    classDef db fill:#E6F4EA,stroke:#2E8B57,stroke-width:1px
    classDef external fill:#FFF4E5,stroke:#D97706,stroke-width:1px
```
