# samuel-chow-demon/cst1206_final_expenseapp architecture

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

- Interactive diagram: https://gitdiagram.com/samuel-chow-demon/cst1206_final_expenseapp
- Repository: https://github.com/samuel-chow-demon/cst1206_final_expenseapp

## Overview

##### Project type and purpose
- This is a full-stack, single-page/ multi-page web application for expense tracking.
- The backend is a Node.js + Express REST API that handles user and expense data, and the frontend is a set of static HTML/JavaScript pages that call the API to display and manipulate data.

##### File structure
- Top level
– app.js: entry point for the Express server
– package.json / package-lock.json: Node.js dependencies and scripts
– module_constant.js, browser_constant.js: shared constants for module IDs or API paths
- Directories
– controllers/: business logic for “user” and “expense” resources
– routes/: Express router definitions mapping HTTP endpoints to controller actions
– models/: data schema definitions for users and expenses (ORM or ODM)
– frontend/: all static UI files (HTML, JS, assets/images). Files like home.js, dashboard.js implement AJAX calls to the API.
- No explicit “config” folder, so assume environment variables (e.g. DATABASE_URL) are read in app.js or module_constant.js.

## Diagram (Mermaid)

```mermaid
graph TB
  %% Frontend Tier
  subgraph "Frontend Tier"
    Browser["Web Browser"]:::frontend
    StaticServer["Static Asset Server / CDN"]:::frontend
    subgraph "frontend/"
      Index["index.html"]:::frontend
      HomeHTML["home.html"]:::frontend
      AccountHTML["account.html"]:::frontend
      SignupHTML["signup.html"]:::frontend
      HomeJS["home.js"]:::frontend
      DashboardJS["dashboard.js"]:::frontend
      AddExpenseJS["addexpense.js"]:::frontend
      AccountJS["account.js"]:::frontend
      ScriptJS["script.js"]:::frontend
      HomeCheckJS["homeCheckToken.js"]:::frontend
      UtilityJS["utility.js"]:::frontend
      BrowserConst["browser_constant.js"]:::frontend
      Assets["assets/img/"]:::frontend
    end
  end

  %% Backend Tier
  subgraph "Backend Tier"
    subgraph "API Layer"
      App["app.js"]:::backend
      ModuleConst["module_constant.js"]:::backend
    end
    subgraph "Routing"
      UserRoute["userRoute.js"]:::backend
      ExpenseRoute["expenseRoute.js"]:::backend
    end
    subgraph "Controllers"
      UserCtrl["userController.js"]:::backend
      ExpenseCtrl["expenseController.js"]:::backend
    end
    subgraph "Data Models"
      UserModel["user.js"]:::data
      ExpenseModel["expense.js"]:::data
    end
    DB["Database (MongoDB/PostgreSQL)"]:::data
    ExtService["External Services"]:::external
  end

  %% Flows
  Browser -->|"GET HTML/JS/CSS"| StaticServer
  StaticServer --> Index
  StaticServer --> HomeHTML
  StaticServer --> AccountHTML
  StaticServer --> SignupHTML
  StaticServer --> HomeJS
  StaticServer --> DashboardJS
  StaticServer --> AddExpenseJS
  StaticServer --> AccountJS
  StaticServer --> ScriptJS
  StaticServer --> HomeCheckJS
  StaticServer --> UtilityJS
  StaticServer --> BrowserConst
  StaticServer --> Assets

  Browser -->|"AJAX/Fetch JSON"| App
  App --> ModuleConst
  App --> UserRoute
  App --> ExpenseRoute

  UserRoute --> UserCtrl
  ExpenseRoute --> ExpenseCtrl

  UserCtrl --> UserModel
  ExpenseCtrl --> ExpenseModel

  UserModel --> DB
  ExpenseModel --> DB

  App --> ExtService

  %% Click Events
  click Index "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/index.html"
  click HomeHTML "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/home.html"
  click AccountHTML "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/account.html"
  click SignupHTML "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/signup.html"
  click HomeJS "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/home.js"
  click DashboardJS "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/dashboard.js"
  click AddExpenseJS "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/addexpense.js"
  click AccountJS "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/account.js"
  click ScriptJS "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/script.js"
  click HomeCheckJS "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/homeCheckToken.js"
  click UtilityJS "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/utility.js"
  click BrowserConst "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/frontend/browser_constant.js"
  click Assets "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/tree/main/frontend/assets/img/"
  click App "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/app.js"
  click ModuleConst "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/module_constant.js"
  click UserRoute "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/routes/userRoute.js"
  click ExpenseRoute "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/routes/expenseRoute.js"
  click UserCtrl "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/controllers/userController.js"
  click ExpenseCtrl "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/controllers/expenseController.js"
  click UserModel "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/models/user.js"
  click ExpenseModel "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/models/expense.js"
  click ExtService "https://github.com/samuel-chow-demon/cst1206_final_expenseapp/blob/main/package.json"

  %% Styles
  classDef frontend fill:#B3CDE0,stroke:#03396C,color:#03396C
  classDef backend fill:#C7E9C0,stroke:#006400,color:#006400
  classDef data fill:#FBB4AE,stroke:#B22222,color:#B22222
  classDef external fill:#D9D9D9,stroke:#696969,color:#696969
```
