# scorpyy10/split-web-app architecture

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

- Interactive diagram: https://gitdiagram.com/scorpyy10/split-web-app
- Repository: https://github.com/scorpyy10/split-web-app

## Overview

##### Main Components Identification
- Frontend Client: The “client” folder contains the React application that uses Material UI for the interface and Chart.js for analytics. This part will include components (under src/components), layouts, routing (client/src/routes.js), API calls (client/src/api) and helper functions.
- Backend Server: The server-side code is primarily in the root (files like app.js) and also in directories such as “routes” (userRouter, expenseRouter, groupRouter), “model” for schema definitions, “helper” functions (logging, API authentication) and configuration files.
- Database: The README and configuration setup mention MongoDB (MongoDB Atlas), which the backend accesses via Mongoose.
- External Services: There is utilization of JWT for authentication and possibly external asset services (like Gravitar for profile pictures).

##### Analyzing the File Structure
- Client directory represents the frontend “React” application and has its own package.json, public assets, and source code.
- The backend’s core entry point is app.js, with routes, models, and logging utilities kept at the top and in separate directories.
- API endpoints are defined in the “routes” directory. Middleware and helper functions for logging, authentication, and validations are in “helper.”
- The “model” directory defines the schema for MongoDB documents.
- There is a clear separation of concerns: UI components, API services on the client, and route handlers/business logic on the server.

##### Key Relationships and Data Flow
- The user interacts with the React frontend which sends API requests (HTTP) to the Express backend.
- The backend processes these requests, uses Mongoose to interface with MongoDB, and handles logic including JWT-based authentication.
- Data travels from the client to the server and vice versa, with specific endpoints for operations on users, expenses, and group-related data.

##### Architectural Patterns and Technologies
- MVC-like separation: Frontend components (views/controllers) and backend routes/models.
- RESTful API design is apparent in the “routes” directory.
- Modern authentication using JWT and data encryption with bcryptjs in the backend.
- Use of Material UI and Chart.js gives the client a component-based, data-driven approach.
- Dependency injection and modular design are suggested by the dedicated folders for helpers, models, and services.

## Diagram (Mermaid)

```mermaid
graph TD
  %% Frontend Subgraph
  subgraph "Frontend (React + Material UI)"
    FE["React Client"]
    CMP["Components (client/src/components)"]
    LAYOUTS["Layouts (client/src/layouts)"]
    API["API (client/src/api)"]
    SVCS["Services (client/src/services)"]
    THEME["Theme (client/src/theme)"]
    ASSETS["Assets (client/public)"]
  end

  %% Backend Subgraph
  subgraph "Backend (Express + Mongoose)"
    ES["Express Server (app.js)"]
    
    subgraph "API Endpoints"
      ER["Expense Router (routes/expenseRouter.js)"]
      GR["Group Router (routes/groupRouter.js)"]
      UR["User Router (routes/userRouter.js)"]
    end

    %% Helper Utilities Subgraph
    subgraph "Helper Utilities"
      API_AUTH["API Authentication (helper/apiAuthentication.js)"]
      LOGGER["Logger (helper/logger.js)"]
      REQ_LOG["Request Logger (helper/requestLogger.js)"]
      VALID["Validation (helper/validation.js)"]
      SPLIT["Split Utility (helper/split.js)"]
    end

    MODELS["Data Models (model/schema.js)"]
  end

  %% Infrastructure & External Services Subgraph
  subgraph "Infrastructure & External Services"
    DB["MongoDB (Atlas)"]
    EXT["External Services (JWT & Gravitar)"]
  end

  %% Frontend Relations
  FE --> CMP
  FE --> LAYOUTS
  FE --> API
  FE --> SVCS
  FE --> THEME
  FE --> ASSETS
  API -->|"API_Call"| ES
  SVCS -->|"Services_Call"| ES

  %% Backend Relations
  ES -->|"Routes"| ER
  ES -->|"Routes"| GR
  ES -->|"Routes"| UR
  ES -->|"Uses_Schema"| MODELS
  ES -->|"Utilizes"| API_AUTH
  ES -->|"Utilizes"| LOGGER
  ES -->|"Utilizes"| REQ_LOG
  ES -->|"Utilizes"| VALID
  ES -->|"Utilizes"| SPLIT
  ES -->|"Mongoose"| DB
  ES -->|"Auth/Profile"| EXT

  %% Styling classes
  class FE,CMP,LAYOUTS,API,SVCS,THEME,ASSETS frontend
  class ES,ER,GR,UR,MODELS backend
  class API_AUTH,LOGGER,REQ_LOG,VALID,SPLIT helper
  class DB,EXT infra

click FE "https://github.com/scorpyy10/split-web-app/tree/main/client/"
click CMP "https://github.com/scorpyy10/split-web-app/tree/main/client/src/components"
click LAYOUTS "https://github.com/scorpyy10/split-web-app/tree/main/client/src/layouts"
click API "https://github.com/scorpyy10/split-web-app/tree/main/client/src/api"
click SVCS "https://github.com/scorpyy10/split-web-app/tree/main/client/src/services"
click THEME "https://github.com/scorpyy10/split-web-app/tree/main/client/src/theme"
click ASSETS "https://github.com/scorpyy10/split-web-app/tree/main/client/public"
click ES "https://github.com/scorpyy10/split-web-app/blob/main/app.js"
click ER "https://github.com/scorpyy10/split-web-app/blob/main/routes/expenseRouter.js"
click GR "https://github.com/scorpyy10/split-web-app/blob/main/routes/groupRouter.js"
click UR "https://github.com/scorpyy10/split-web-app/blob/main/routes/userRouter.js"
click MODELS "https://github.com/scorpyy10/split-web-app/blob/main/model/schema.js"
click API_AUTH "https://github.com/scorpyy10/split-web-app/blob/main/helper/apiAuthentication.js"
click LOGGER "https://github.com/scorpyy10/split-web-app/blob/main/helper/logger.js"
click REQ_LOG "https://github.com/scorpyy10/split-web-app/blob/main/helper/requestLogger.js"
click VALID "https://github.com/scorpyy10/split-web-app/blob/main/helper/validation.js"
click SPLIT "https://github.com/scorpyy10/split-web-app/blob/main/helper/split.js"

classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
classDef helper fill:#F4A460,stroke:#000,stroke-width:1px
classDef infra fill:#D3D3D3,stroke:#000,stroke-width:1px
```
