# jvinix/comp229.f2026.004-codeexamples architecture

> Architecture diagram of the GitHub repository jvinix/comp229.f2026.004-codeexamples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jvinix/comp229.f2026.004-codeexamples
- Repository: https://github.com/jvinix/comp229.f2026.004-codeexamples

## Overview

This repository is a COMP229 code-example application with a React frontend and Express/Mongoose backend. The main user workflow is signing up or signing in, then browsing projects and using authenticated routes to add, edit, or delete projects; public project listing is also available. The graph includes routing, authorization, API access, persistence, and the main page branches. Evidence is limited to the README and sampled/indexed files, so unsampled controller and view links are omitted where their wiring is not shown.

Main entry points: [`backend/config/express.js`](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/config/express.js) (Express application), [`frontend/src/mainRouter.jsx`](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/mainRouter.jsx) (Page routes), [`backend/app/controllers/auth.js`](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/controllers/auth.js) (Authentication), [`frontend/src/components/auth/Signin.jsx`](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/auth/Signin.jsx) (Sign-in and signup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_react_app["React app<br/>[App.jsx]"]
  node_page_routes["Page routes<br/>[mainRouter.jsx]"]
  node_project_pages["Project pages<br/>[Projects.jsx]"]
  node_auth_views["Sign-in and signup<br/>[Signin.jsx]"]
  node_auth_state["Auth state<br/>[auth-helper.js]"]
  node_private_route["Private route<br/>[PrivateRoute.jsx]"]
  node_project_views["Project management views"]
  node_project_form["Project form<br/>[ProjectForm.jsx]"]
  node_project_api["Project API client<br/>[api-project.js]"]
  node_user_api["User API client<br/>[api-user.js]"]
end

subgraph group_backend["API and domain"]
  node_api_server["Express application<br/>[express.js]"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_project_routes["Project routes<br/>[projects.js]"]
  node_user_routes["User routes<br/>[users.js]"]
  node_auth_controller["Authentication<br/>[auth.js]"]
  node_project_controller["Project operations<br/>[projects.js]"]
  node_user_controller["User operations<br/>[users.js]"]
  node_backend_server["HTTP server<br/>[server.js]"]
end

subgraph group_storage["Persistence"]
  node_project_model[("Project model<br/>[projects.js]")]
  node_user_model[("User model<br/>[users.js]")]
  node_db_config["Database connection<br/>[db.js]"]
end

node_visitor(("Visitor"))
node_mongo[("MongoDB")]

node_visitor -->|"opens"| node_react_app
node_react_app -->|"renders"| node_page_routes
node_page_routes -->|"routes to"| node_project_pages
node_page_routes -->|"routes to"| node_auth_views
node_page_routes -->|"guards routes"| node_private_route
node_private_route -->|"checks session"| node_auth_state
node_auth_views -->|"submits credentials"| node_user_api
node_auth_views -->|"stores token"| node_auth_state
node_page_routes -->|"routes to"| node_project_views
node_project_views -->|"renders"| node_project_form
node_project_views -->|"requests projects"| node_project_api
node_project_api -->|"gets token"| node_auth_state
node_project_api -->|"calls REST API"| node_api_server
node_user_api -.->|"calls REST API"| node_api_server
node_backend_server -->|"connects"| node_db_config
node_backend_server -->|"serves"| node_api_server
node_db_config -->|"connects"| node_mongo
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_project_routes
node_api_server -->|"mounts"| node_user_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_project_routes -->|"dispatches"| node_project_controller
node_project_routes -->|"validates token"| node_auth_controller
node_user_routes -->|"dispatches"| node_user_controller
node_user_routes -->|"validates token"| node_auth_controller
node_auth_controller -->|"finds account"| node_user_model
node_project_controller -->|"reads and writes"| node_project_model
node_project_controller -->|"checks admin"| node_user_model
node_project_model -.->|"persists records"| node_mongo
node_user_model -.->|"persists accounts"| node_mongo

click node_react_app "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/App.jsx"
click node_page_routes "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/mainRouter.jsx"
click node_project_pages "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/Pages/Projects.jsx"
click node_auth_views "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/auth/Signin.jsx"
click node_auth_state "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/auth/auth-helper.js"
click node_private_route "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/auth/PrivateRoute.jsx"
click node_project_views "https://github.com/jvinix/comp229.f2026.004-codeexamples/tree/main/frontend/src/components/projects"
click node_project_form "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/projects/ProjectForm.jsx"
click node_project_api "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/datasource/api-project.js"
click node_user_api "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/datasource/api-user.js"
click node_api_server "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/config/express.js"
click node_auth_routes "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/routers/auth.js"
click node_project_routes "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/routers/projects.js"
click node_user_routes "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/routers/users.js"
click node_auth_controller "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/controllers/auth.js"
click node_project_controller "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/controllers/projects.js"
click node_user_controller "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/controllers/users.js"
click node_project_model "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/models/projects.js"
click node_user_model "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/models/users.js"
click node_backend_server "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/server.js"
click node_db_config "https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/config/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_react_app,node_page_routes,node_project_pages,node_auth_views,node_auth_state,node_private_route,node_project_views,node_project_form,node_project_api,node_user_api toneBlue
class node_api_server,node_auth_routes,node_project_routes,node_user_routes,node_auth_controller,node_project_controller,node_user_controller,node_backend_server,node_mongo toneAmber
class node_project_model,node_user_model,node_db_config toneMint
class node_visitor toneIndigo
```

## Components

### Web interface

- [React app](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Page routes](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/mainRouter.jsx): `frontend/src/mainRouter.jsx`
- [Project pages](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/Pages/Projects.jsx): `frontend/src/Pages/Projects.jsx`
- [Sign-in and signup](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/auth/Signin.jsx): `frontend/src/components/auth/Signin.jsx`
- [Auth state](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/auth/auth-helper.js): `frontend/src/components/auth/auth-helper.js`
- [Private route](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/auth/PrivateRoute.jsx): `frontend/src/components/auth/PrivateRoute.jsx`
- [Project management views](https://github.com/jvinix/comp229.f2026.004-codeexamples/tree/main/frontend/src/components/projects): `frontend/src/components/projects`
- [Project form](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/components/projects/ProjectForm.jsx): `frontend/src/components/projects/ProjectForm.jsx`
- [Project API client](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/datasource/api-project.js): `frontend/src/datasource/api-project.js`
- [User API client](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/frontend/src/datasource/api-user.js): `frontend/src/datasource/api-user.js`

### API and domain

- [Express application](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/config/express.js): `backend/config/express.js`
- [Auth routes](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/routers/auth.js): `backend/app/routers/auth.js`
- [Project routes](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/routers/projects.js): `backend/app/routers/projects.js`
- [User routes](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/routers/users.js): `backend/app/routers/users.js`
- [Authentication](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/controllers/auth.js): `backend/app/controllers/auth.js`
- [Project operations](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/controllers/projects.js): `backend/app/controllers/projects.js`
- [User operations](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/controllers/users.js): `backend/app/controllers/users.js`
- [HTTP server](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/server.js): `backend/server.js`

### Persistence

- [Project model](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/models/projects.js): `backend/app/models/projects.js`
- [User model](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/app/models/users.js): `backend/app/models/users.js`
- [Database connection](https://github.com/jvinix/comp229.f2026.004-codeexamples/blob/main/backend/config/db.js): `backend/config/db.js`

### Other components

- **Visitor**
- **MongoDB**

## Connections

- Visitor → React app: opens
- React app → Page routes: renders (evidence: `frontend/src/App.jsx`)
- Page routes → Project pages: routes to (evidence: `frontend/src/mainRouter.jsx`)
- Page routes → Sign-in and signup: routes to (evidence: `frontend/src/mainRouter.jsx`)
- Page routes → Private route: guards routes (evidence: `frontend/src/mainRouter.jsx`)
- Private route → Auth state: checks session (evidence: `frontend/src/components/auth/PrivateRoute.jsx`)
- Sign-in and signup → User API client: submits credentials (evidence: `frontend/src/components/auth/Signin.jsx`)
- Sign-in and signup → Auth state: stores token (evidence: `frontend/src/components/auth/Signin.jsx`)
- Page routes → Project management views: routes to (evidence: `frontend/src/mainRouter.jsx`)
- Project management views → Project form: renders (evidence: `frontend/src/components/projects/AddProject.jsx`)
- Project management views → Project API client: requests projects (evidence: `frontend/src/components/projects/ListProjects.jsx`)
- Project API client → Auth state: gets token (evidence: `frontend/src/datasource/api-project.js`)
- Project API client → Express application: calls REST API (evidence: `frontend/src/datasource/api-project.js`)
- User API client → Express application: calls REST API
- HTTP server → Database connection: connects (evidence: `backend/server.js`)
- HTTP server → Express application: serves (evidence: `backend/server.js`)
- Database connection → MongoDB: connects (evidence: `backend/config/db.js`)
- Express application → Auth routes: mounts (evidence: `backend/config/express.js`)
- Express application → Project routes: mounts (evidence: `backend/config/express.js`)
- Express application → User routes: mounts (evidence: `backend/config/express.js`)
- Auth routes → Authentication: dispatches (evidence: `backend/app/routers/auth.js`)
- Project routes → Project operations: dispatches (evidence: `backend/app/routers/projects.js`)
- Project routes → Authentication: validates token (evidence: `backend/app/routers/projects.js`)
- User routes → User operations: dispatches (evidence: `backend/app/routers/users.js`)
- User routes → Authentication: validates token (evidence: `backend/app/routers/users.js`)
- Authentication → User model: finds account (evidence: `backend/app/controllers/auth.js`)
- Project operations → Project model: reads and writes (evidence: `backend/app/controllers/projects.js`)
- Project operations → User model: checks admin (evidence: `backend/app/controllers/projects.js`)
- Project model → MongoDB: persists records
- User model → MongoDB: persists accounts
