# clement127001/todo_assignment architecture

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

- Interactive diagram: https://gitdiagram.com/clement127001/todo_assignment
- Repository: https://github.com/clement127001/todo_assignment

## Overview

ZipTrrip is a full-stack TODO application. Users register or log in, then use the React client to create, list, inspect, update, and delete their own TODOs. The backend validates requests, authenticates protected operations with JWTs, enforces user ownership, and persists users and TODOs with Mongoose. The graph includes the principal client and API stages plus validation and error handling. Client-to-API details are documented at product level; unsampled client wiring is not inferred.

Main entry points: [`server/src/app.ts`](https://github.com/clement127001/todo_assignment/blob/main/server/src/app.ts) (Express app), [`client/src/App.tsx`](https://github.com/clement127001/todo_assignment/blob/main/client/src/App.tsx) (Client application), [`server/src/router/auth.ts`](https://github.com/clement127001/todo_assignment/blob/main/server/src/router/auth.ts) (Auth routes), [`server/src/router/todo.ts`](https://github.com/clement127001/todo_assignment/blob/main/server/src/router/todo.ts) (TODO routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_web["Client application<br/>[App.tsx]"]
  node_auth_ui["Auth screens"]
  node_todo_ui["TODO screens"]
  node_todo_hooks["TODO data hooks"]
  node_login_state["Login state<br/>[LoginProvider.tsx]"]
end

subgraph group_api["API runtime"]
  node_server_start["Server startup<br/>[server.ts]"]
  node_app["Express app<br/>[app.ts]"]
  node_auth_router["Auth routes<br/>[auth.ts]"]
  node_todo_router["TODO routes<br/>[todo.ts]"]
  node_health["Health route<br/>[health.ts]"]
end

subgraph group_domain["Auth and TODO domain"]
  node_auth_middleware["JWT middleware<br/>[authentication.ts]"]
  node_auth_controller["Auth controller<br/>[auth.ts]"]
  node_todo_controller["TODO controller<br/>[todo.ts]"]
  node_todo_access["Ownership checks<br/>[todo.ts]"]
  node_user_model[("User model<br/>[user.ts]")]
  node_todo_model[("TODO model<br/>[todo.ts]")]
end

subgraph group_platform["Validation and persistence"]
  node_user_schema["User validation<br/>[user.schema.ts]"]
  node_todo_schema["TODO validation<br/>[todo.schema.ts]"]
  node_validate["Request validator<br/>[validate.ts]"]
  node_error_handler["Error handling<br/>[error-handler.ts]"]
  node_db_config["Database config<br/>[db.ts]"]
  node_env["Environment config<br/>[env.ts]"]
end

node_user(("User"))
node_mongo[("MongoDB")]

node_user -->|"uses"| node_web
node_web -->|"offers authentication"| node_auth_ui
node_web -->|"offers TODO management"| node_todo_ui
node_todo_ui -.->|"loads and changes TODOs"| node_todo_hooks
node_auth_ui -.->|"stores authentication"| node_login_state
node_web -->|"sends API requests"| node_app
node_app -->|"routes auth requests"| node_auth_router
node_app -->|"routes protected requests"| node_todo_router
node_app -->|"routes health checks"| node_health
node_app -->|"handles errors"| node_error_handler
node_app -->|"protects TODO routes"| node_auth_middleware
node_auth_router -->|"validates requests"| node_validate
node_auth_router -->|"uses schema"| node_user_schema
node_auth_router -->|"dispatches auth"| node_auth_controller
node_todo_router -->|"validates requests"| node_validate
node_todo_router -->|"uses schema"| node_todo_schema
node_todo_router -->|"dispatches TODO operations"| node_todo_controller
node_auth_middleware -->|"attaches user context"| node_todo_controller
node_auth_controller -->|"reads and creates users"| node_user_model
node_todo_controller -->|"performs TODO operations"| node_todo_model
node_todo_controller -->|"checks ownership"| node_todo_access
node_todo_access -->|"checks user-owned TODO"| node_todo_model
node_server_start -->|"starts"| node_app
node_server_start -->|"connects database"| node_db_config
node_db_config -->|"reads settings"| node_env
node_user_model -->|"persists users"| node_mongo
node_todo_model -->|"persists TODOs"| node_mongo
node_error_handler -->|"returns error response"| node_user

click node_web "https://github.com/clement127001/todo_assignment/blob/main/client/src/App.tsx"
click node_auth_ui "https://github.com/clement127001/todo_assignment/tree/main/client/src/components/auth"
click node_todo_ui "https://github.com/clement127001/todo_assignment/tree/main/client/src/components/todo"
click node_todo_hooks "https://github.com/clement127001/todo_assignment/tree/main/client/src/hooks"
click node_login_state "https://github.com/clement127001/todo_assignment/blob/main/client/src/contexts/LoginProvider.tsx"
click node_server_start "https://github.com/clement127001/todo_assignment/blob/main/server/src/server.ts"
click node_app "https://github.com/clement127001/todo_assignment/blob/main/server/src/app.ts"
click node_auth_router "https://github.com/clement127001/todo_assignment/blob/main/server/src/router/auth.ts"
click node_todo_router "https://github.com/clement127001/todo_assignment/blob/main/server/src/router/todo.ts"
click node_health "https://github.com/clement127001/todo_assignment/blob/main/server/src/router/health.ts"
click node_auth_middleware "https://github.com/clement127001/todo_assignment/blob/main/server/src/middlewares/authentication.ts"
click node_auth_controller "https://github.com/clement127001/todo_assignment/blob/main/server/src/controller/auth.ts"
click node_todo_controller "https://github.com/clement127001/todo_assignment/blob/main/server/src/controller/todo.ts"
click node_todo_access "https://github.com/clement127001/todo_assignment/blob/main/server/src/utils/todo.ts"
click node_user_model "https://github.com/clement127001/todo_assignment/blob/main/server/src/models/user.ts"
click node_todo_model "https://github.com/clement127001/todo_assignment/blob/main/server/src/models/todo.ts"
click node_user_schema "https://github.com/clement127001/todo_assignment/blob/main/server/src/modules/user/user.schema.ts"
click node_todo_schema "https://github.com/clement127001/todo_assignment/blob/main/server/src/modules/todo/todo.schema.ts"
click node_validate "https://github.com/clement127001/todo_assignment/blob/main/server/src/utils/validate.ts"
click node_error_handler "https://github.com/clement127001/todo_assignment/blob/main/server/src/middlewares/error-handler.ts"
click node_db_config "https://github.com/clement127001/todo_assignment/blob/main/server/src/config/db.ts"
click node_env "https://github.com/clement127001/todo_assignment/blob/main/server/src/config/env.ts"

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_web,node_auth_ui,node_todo_ui,node_todo_hooks,node_login_state,node_user toneBlue
class node_server_start,node_app,node_auth_router,node_todo_router,node_health,node_mongo toneAmber
class node_auth_middleware,node_auth_controller,node_todo_controller,node_todo_access,node_user_model,node_todo_model toneMint
class node_user_schema,node_todo_schema,node_validate,node_error_handler,node_db_config,node_env toneRose
```

## Components

### React client

- [Client application](https://github.com/clement127001/todo_assignment/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Auth screens](https://github.com/clement127001/todo_assignment/tree/main/client/src/components/auth): `client/src/components/auth`
- [TODO screens](https://github.com/clement127001/todo_assignment/tree/main/client/src/components/todo): `client/src/components/todo`
- [TODO data hooks](https://github.com/clement127001/todo_assignment/tree/main/client/src/hooks): `client/src/hooks`
- [Login state](https://github.com/clement127001/todo_assignment/blob/main/client/src/contexts/LoginProvider.tsx): `client/src/contexts/LoginProvider.tsx`

### API runtime

- [Server startup](https://github.com/clement127001/todo_assignment/blob/main/server/src/server.ts): `server/src/server.ts`
- [Express app](https://github.com/clement127001/todo_assignment/blob/main/server/src/app.ts): `server/src/app.ts`
- [Auth routes](https://github.com/clement127001/todo_assignment/blob/main/server/src/router/auth.ts): `server/src/router/auth.ts`
- [TODO routes](https://github.com/clement127001/todo_assignment/blob/main/server/src/router/todo.ts): `server/src/router/todo.ts`
- [Health route](https://github.com/clement127001/todo_assignment/blob/main/server/src/router/health.ts): `server/src/router/health.ts`

### Auth and TODO domain

- [JWT middleware](https://github.com/clement127001/todo_assignment/blob/main/server/src/middlewares/authentication.ts): `server/src/middlewares/authentication.ts`
- [Auth controller](https://github.com/clement127001/todo_assignment/blob/main/server/src/controller/auth.ts): `server/src/controller/auth.ts`
- [TODO controller](https://github.com/clement127001/todo_assignment/blob/main/server/src/controller/todo.ts): `server/src/controller/todo.ts`
- [Ownership checks](https://github.com/clement127001/todo_assignment/blob/main/server/src/utils/todo.ts): `server/src/utils/todo.ts`
- [User model](https://github.com/clement127001/todo_assignment/blob/main/server/src/models/user.ts): `server/src/models/user.ts`
- [TODO model](https://github.com/clement127001/todo_assignment/blob/main/server/src/models/todo.ts): `server/src/models/todo.ts`

### Validation and persistence

- [User validation](https://github.com/clement127001/todo_assignment/blob/main/server/src/modules/user/user.schema.ts): `server/src/modules/user/user.schema.ts`
- [TODO validation](https://github.com/clement127001/todo_assignment/blob/main/server/src/modules/todo/todo.schema.ts): `server/src/modules/todo/todo.schema.ts`
- [Request validator](https://github.com/clement127001/todo_assignment/blob/main/server/src/utils/validate.ts): `server/src/utils/validate.ts`
- [Error handling](https://github.com/clement127001/todo_assignment/blob/main/server/src/middlewares/error-handler.ts): `server/src/middlewares/error-handler.ts`
- [Database config](https://github.com/clement127001/todo_assignment/blob/main/server/src/config/db.ts): `server/src/config/db.ts`
- [Environment config](https://github.com/clement127001/todo_assignment/blob/main/server/src/config/env.ts): `server/src/config/env.ts`

### Other components

- **User**
- **MongoDB**

## Connections

- User → Client application: uses
- Client application → Auth screens: offers authentication
- Client application → TODO screens: offers TODO management
- TODO screens → TODO data hooks: loads and changes TODOs
- Auth screens → Login state: stores authentication
- Client application → Express app: sends API requests
- Express app → Auth routes: routes auth requests (evidence: `server/src/app.ts`)
- Express app → TODO routes: routes protected requests (evidence: `server/src/app.ts`)
- Express app → Health route: routes health checks (evidence: `server/src/app.ts`)
- Express app → Error handling: handles errors (evidence: `server/src/app.ts`)
- Express app → JWT middleware: protects TODO routes (evidence: `server/src/app.ts`)
- Auth routes → Request validator: validates requests (evidence: `server/src/router/auth.ts`)
- Auth routes → User validation: uses schema (evidence: `server/src/router/auth.ts`)
- Auth routes → Auth controller: dispatches auth (evidence: `server/src/router/auth.ts`)
- TODO routes → Request validator: validates requests (evidence: `server/src/router/todo.ts`)
- TODO routes → TODO validation: uses schema (evidence: `server/src/router/todo.ts`)
- TODO routes → TODO controller: dispatches TODO operations (evidence: `server/src/router/todo.ts`)
- JWT middleware → TODO controller: attaches user context
- Auth controller → User model: reads and creates users (evidence: `server/src/controller/auth.ts`)
- TODO controller → TODO model: performs TODO operations (evidence: `server/src/controller/todo.ts`)
- TODO controller → Ownership checks: checks ownership (evidence: `server/src/controller/todo.ts`)
- Ownership checks → TODO model: checks user-owned TODO (evidence: `server/src/utils/todo.ts`)
- Server startup → Express app: starts (evidence: `server/src/server.ts`)
- Server startup → Database config: connects database (evidence: `server/src/server.ts`)
- Database config → Environment config: reads settings (evidence: `server/src/config/db.ts`)
- User model → MongoDB: persists users
- TODO model → MongoDB: persists TODOs
- Error handling → User: returns error response
