# rithvikreddybasani/sharepurse architecture

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

- Interactive diagram: https://gitdiagram.com/rithvikreddybasani/sharepurse
- Repository: https://github.com/rithvikreddybasani/sharepurse

## Overview

##### Project type and purpose
- This is a full-stack MERN (MongoDB, Express, React, Node.js) web application called SharePurse. Its goal is to let multiple users create/join groups, track shared expenses, view analytics, and settle balances.

##### File structure
- Top-level: two folders, **client/** and **server/**
- client/: a React single-page application
– src/:
- App.js & index.js (entry points)
- api/: Axios setups
- services/: business-logic wrappers around REST calls (auth, expenses, groups)
- components/: UI components (dashboard, expense, groups, login, register, profile)
- layouts/: high-level page scaffolding (sidebar, navbar)
- theme/: Material-UI overrides, Tailwind config
- utils/: helper functions
- server/: an Express API
– index.js (server setup, middleware, JWT auth)
– routes/: REST routers for users, expenses, groups
– model/:
- schema.js (Mongoose schemas)
- components/ (model classes for expense, group, user)
- helper/ (authentication, validation, logging, split logic)
– vercel.json (deployment config)

##### README
- Confirms MERN stack, JWT authentication, MongoDB Atlas, React+Redux, Axios, Material-UI, Chart.js.
- Features: group expense tracking, analytics graphs, user management.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Side
    subgraph "Client (React SPA)"
        direction TB
        UI["React SPA (Browser UI Layer)"]:::frontend
        AppEntry["App.js & index.js"]:::frontend
        Redux["Redux Store"]:::frontend
        API["Axios API Layer"]:::frontend
        subgraph "Services (Business Logic Wrappers)"
            direction TB
            AuthService["Auth Service"]:::frontend
            ExpenseService["Expense Service"]:::frontend
            GroupService["Group Service"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            DashboardComp["Dashboard Components"]:::frontend
            ExpenseComp["Expense Components"]:::frontend
            GroupsComp["Groups Components"]:::frontend
            LoginComp["Login Components"]:::frontend
            RegisterComp["Register Components"]:::frontend
            ProfileComp["Profile Components"]:::frontend
        end
        subgraph "Layouts & Theme"
            direction TB
            Layouts["Layouts (Sidebar, Navbar)"]:::frontend
            ThemeConfig["Theme Config & Tailwind"]:::frontend
        end
        Utils["Utility Functions"]:::frontend

        UI -->|renders| AppEntry
        AppEntry -->|initializes| Redux
        Redux -->|dispatches actions| API
        API -->|calls| AuthService
        API -->|calls| ExpenseService
        API -->|calls| GroupService
        AuthService -->|used by| UI
        ExpenseService -->|used by| UI
        GroupService -->|used by| UI
        UI -->|uses| DashboardComp
        UI -->|uses| ExpenseComp
        UI -->|uses| GroupsComp
        UI -->|uses| LoginComp
        UI -->|uses| RegisterComp
        UI -->|uses| ProfileComp
        UI -->|wraps in| Layouts
        UI -->|styled by| ThemeConfig
        UI -->|calls helpers| Utils
    end

    %% Server Side
    subgraph "Server (Express API)"
        direction TB
        Entry["Express Server Entry"]:::backend
        subgraph "Middleware Chain"
            direction TB
            AuthMd["JWT Authentication Middleware"]:::backend
            LoggerMd["Request Logging Middleware"]:::backend
            ValidationMd["Input Validation Middleware"]:::backend
        end
        subgraph "Routers (Controllers)"
            direction TB
            UserRouter["User REST Router"]:::backend
            ExpenseRouter["Expense REST Router"]:::backend
            GroupRouter["Group REST Router"]:::backend
        end
        subgraph "Helper Modules"
            direction TB
            AuthHelper["Authentication Helper"]:::backend
            LoggerHelper["Logger Helper"]:::backend
            RequestLogger["Request Logger"]:::backend
            ValidationHelper["Validation Helper"]:::backend
            SplitHelper["Split Logic Helper"]:::backend
        end
        subgraph "Models"
            direction TB
            Schema["Mongoose Schemas"]:::backend
            UserModel["User Model"]:::backend
            ExpenseModel["Expense Model"]:::backend
            GroupModel["Group Model"]:::backend
        end

        Entry -->|uses| AuthMd
        AuthMd -->|then| LoggerMd
        LoggerMd -->|then| ValidationMd
        ValidationMd -->|routes to| UserRouter
        ValidationMd -->|routes to| ExpenseRouter
        ValidationMd -->|routes to| GroupRouter
        UserRouter -->|calls| AuthHelper
        UserRouter -->|calls| RequestLogger
        UserRouter -->|calls| ValidationHelper
        UserRouter -->|calls| SplitHelper
        ExpenseRouter -->|calls| SplitHelper
        GroupRouter -->|calls| SplitHelper
        AuthHelper -->|uses| Schema
        RequestLogger -->|logs via| LoggerHelper
        ValidationHelper -->|validates via| Schema
        SplitHelper -->|calculates using| Schema
        Schema -->|defines| UserModel
        Schema -->|defines| ExpenseModel
        Schema -->|defines| GroupModel
        UserModel -->|CRUD| MongoDB
        ExpenseModel -->|CRUD| MongoDB
        GroupModel -->|CRUD| MongoDB
    end

    %% Database
    MongoDB[(MongoDB Atlas)]:::database

    %% External Services
    JWTService["JWT Service"]:::external
    Gravatar["Gravatar"]:::external

    %% Cross connections
    AuthMd -->|verifies/ issues token| JWTService
    AuthHelper -->|issues token| JWTService
    ProfileComp -->|fetch avatar| Gravatar

    %% Connections between Client and Server
    API -->|HTTP requests| Entry
    Entry -->|HTTP responses| API

    %% Click Events
    click UI "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/"
    click AppEntry "https://github.com/rithvikreddybasani/sharepurse/blob/master/client/src/App.js"
    click AppEntry "https://github.com/rithvikreddybasani/sharepurse/blob/master/client/src/index.js"
    click API "https://github.com/rithvikreddybasani/sharepurse/blob/master/client/src/api/index.js"
    click AuthService "https://github.com/rithvikreddybasani/sharepurse/blob/master/client/src/services/auth.js"
    click ExpenseService "https://github.com/rithvikreddybasani/sharepurse/blob/master/client/src/services/expenseServices.js"
    click GroupService "https://github.com/rithvikreddybasani/sharepurse/blob/master/client/src/services/groupServices.js"
    click DashboardComp "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/components/dashboard/"
    click ExpenseComp "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/components/expense/"
    click GroupsComp "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/components/groups/"
    click LoginComp "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/components/login/"
    click RegisterComp "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/components/register/"
    click ProfileComp "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/components/profile/"
    click Layouts "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/layouts/dashboard/"
    click Layouts "https://github.com/rithvikreddybasani/sharepurse/blob/master/client/src/layouts/LogoOnlyLayout.jsx"
    click ThemeConfig "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/theme/"
    click ThemeConfig "https://github.com/rithvikreddybasani/sharepurse/blob/master/client/src/tailwind.config.js"
    click Utils "https://github.com/rithvikreddybasani/sharepurse/tree/master/client/src/utils/"
    click Entry "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/index.js"
    click UserRouter "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/routes/userRouter.js"
    click ExpenseRouter "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/routes/expenseRouter.js"
    click GroupRouter "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/routes/groupRouter.js"
    click Schema "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/schema.js"
    click UserModel "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/components/user.js"
    click ExpenseModel "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/components/expense.js"
    click GroupModel "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/components/group.js"
    click AuthHelper "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/helper/apiAuthentication.js"
    click LoggerHelper "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/helper/logger.js"
    click RequestLogger "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/helper/requestLogger.js"
    click ValidationHelper "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/helper/validation.js"
    click SplitHelper "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/model/helper/split.js"
    click MongoDB "https://github.com/rithvikreddybasani/sharepurse/blob/master/server/vercel.json"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#2196F3,stroke-width:1px
    classDef backend fill:#E8F5E9,stroke:#4CAF50,stroke-width:1px
    classDef database fill:#FFF3E0,stroke:#FB8C00,stroke-width:1px
    classDef external fill:#F3E5F5,stroke:#9C27B0,stroke-dasharray: 5 5,stroke-width:1px
```
