# yassir003/cashy architecture

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

- Interactive diagram: https://gitdiagram.com/yassir003/cashy
- Repository: https://github.com/yassir003/cashy

## Overview

##### Project type and purpose
- This is a full-stack mobile application (“CASHY”) for personal finance management.
- The `client/` directory holds a React Native (Expo) front end; the `server/` directory holds an Express.js REST API with MongoDB storage and JWT authentication.

##### File structure
- Top-level directories:
- client/ (React Native app)
- server/ (Node/Express backend)
- client/ substructure:
- app/ (screens, navigation entry point)
- components/ (UI and modal dialogs)
- contexts/ (React Contexts for Auth, Budget, Categories, Transactions)
- lib/api.ts (REST API wrappers)
- server/ substructure (classic MVC):
- routes/ (HTTP endpoints)
- controllers/ (business logic)
- models/ (Mongoose schemas)
- middleware/ (JWT auth guard)
- index.js (app bootstrap)
- Configuration files: `.env`, `package.json`, TS config in client.

##### Extract architecture details from README
- Client: React Native + React Navigation + Victory charts.
- Server: Express.js + MongoDB + JWT authentication.
- Typical use cases: user registration/login, CRUD on budgets/categories/expenses, analytics.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client
    subgraph "Mobile Client" 
        direction TB
        Navigation["Navigation & Screens"]:::client
        Components["UI Components"]:::client
        subgraph "Contexts"
            direction TB
            AuthContext["AuthContext"]:::client
            BudgetContext["BudgetContext"]:::client
            CategoriesContext["CategoriesContext"]:::client
            TransactionContext["TransactionContext"]:::client
        end
        API["API Layer"]:::client
    end

    %% Server API
    subgraph "Server API"
        direction TB
        Env[".env Config"]:::backend
        Index["server/index.js"]:::backend
        subgraph "Routes"
            direction TB
            UserRoute["userRoute.js"]:::backend
            BudgetRoute["budgetRoute.js"]:::backend
            CategoryRoute["categoryRoute.js"]:::backend
            ExpenseRoute["expenseRoute.js"]:::backend
        end
        Middleware["authMiddleware.js"]:::backend
        subgraph "Controllers"
            direction TB
            UserController["userController.js"]:::backend
            BudgetController["budgetController.js"]:::backend
            CategoryController["categoryController.js"]:::backend
            ExpenseController["expenseController.js"]:::backend
        end
        subgraph "Models"
            direction TB
            UserModel["userModel.js"]:::db
            BudgetModel["budgetModel.js"]:::db
            CategoryModel["categoryModel.js"]:::db
            ExpenseModel["expenseModel.js"]:::db
        end
    end

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

    %% Data Flows
    Navigation --> API
    Components --> API
    AuthContext --> API
    BudgetContext --> API
    CategoriesContext --> API
    TransactionContext --> API

    API -->|HTTP Request| UserRoute
    API -->|HTTP Request| BudgetRoute
    API -->|HTTP Request| CategoryRoute
    API -->|HTTP Request| ExpenseRoute

    UserRoute --> Middleware
    BudgetRoute --> Middleware
    CategoryRoute --> Middleware
    ExpenseRoute --> Middleware

    Middleware --> UserController
    Middleware --> BudgetController
    Middleware --> CategoryController
    Middleware --> ExpenseController

    UserController --> UserModel
    BudgetController --> BudgetModel
    CategoryController --> CategoryModel
    ExpenseController --> ExpenseModel

    UserModel --> DB
    BudgetModel --> DB
    CategoryModel --> DB
    ExpenseModel --> DB

    %% Click Events
    click Navigation "https://github.com/yassir003/cashy/tree/main/client/app/screens/"
    click Components "https://github.com/yassir003/cashy/tree/main/client/components/"
    click AuthContext "https://github.com/yassir003/cashy/blob/main/client/contexts/AuthContext.tsx"
    click BudgetContext "https://github.com/yassir003/cashy/blob/main/client/contexts/BudgetContext.tsx"
    click CategoriesContext "https://github.com/yassir003/cashy/blob/main/client/contexts/CategoriesContext.tsx"
    click TransactionContext "https://github.com/yassir003/cashy/blob/main/client/contexts/TransactionContext.tsx"
    click API "https://github.com/yassir003/cashy/blob/main/client/lib/api.ts"
    click UserRoute "https://github.com/yassir003/cashy/blob/main/server/routes/userRoute.js"
    click BudgetRoute "https://github.com/yassir003/cashy/blob/main/server/routes/budgetRoute.js"
    click CategoryRoute "https://github.com/yassir003/cashy/blob/main/server/routes/categoryRoute.js"
    click ExpenseRoute "https://github.com/yassir003/cashy/blob/main/server/routes/expenseRoute.js"
    click Middleware "https://github.com/yassir003/cashy/blob/main/server/middleware/authMiddleware.js"
    click UserController "https://github.com/yassir003/cashy/blob/main/server/controllers/userController.js"
    click BudgetController "https://github.com/yassir003/cashy/blob/main/server/controllers/budgetController.js"
    click CategoryController "https://github.com/yassir003/cashy/blob/main/server/controllers/categoryController.js"
    click ExpenseController "https://github.com/yassir003/cashy/blob/main/server/controllers/expenseController.js"
    click UserModel "https://github.com/yassir003/cashy/blob/main/server/models/userModel.js"
    click BudgetModel "https://github.com/yassir003/cashy/blob/main/server/models/budgetModel.js"
    click CategoryModel "https://github.com/yassir003/cashy/blob/main/server/models/categoryModel.js"
    click ExpenseModel "https://github.com/yassir003/cashy/blob/main/server/models/expenseModel.js"
    click Index "https://github.com/yassir003/cashy/blob/main/server/index.js"
    click Env "https://github.com/yassir003/cashy/blob/main/server/.env"

    %% Styles
    classDef client fill:#cce5ff,stroke:#4da3ff,color:#000;
    classDef backend fill:#d4edda,stroke:#66bb6a,color:#000;
    classDef db fill:#ffe5b4,stroke:#ff9800,color:#000;
```
