# shijake/ece1724_project architecture

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

- Interactive diagram: https://gitdiagram.com/shijake/ece1724_project
- Repository: https://github.com/shijake/ece1724_project

## Overview

This repository is a stock-watch project with an Express REST backend and a React frontend. The backend exposes authenticated per-user watch management, price-history JSON/CSV responses, and generated API documentation. Its visible watch workflow validates requests, accesses PostgreSQL through Prisma, and serializes watch results. The checked-in React app is still the Vite starter counter, not a stock-watch client. No sampled source shows price polling, alert delivery, or frontend-to-API calls, so those links and capabilities are not inferred.

Main entry points: [`express/src/app.ts`](https://github.com/shijake/ece1724_project/blob/main/express/src/app.ts) (Express app), [`express/src/watches/routes.ts`](https://github.com/shijake/ece1724_project/blob/main/express/src/watches/routes.ts) (Watch routes), [`express/src/openapi.ts`](https://github.com/shijake/ece1724_project/blob/main/express/src/openapi.ts) (API documentation), [`express/src/db.ts`](https://github.com/shijake/ece1724_project/blob/main/express/src/db.ts) (Prisma client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API runtime"]
  node_app["Express app<br/>[app.ts]"]
  node_auth["User guard<br/>[auth.ts]"]
  node_errors["Error handling<br/>[errors.ts]"]
  node_openapi["API documentation<br/>[openapi.ts]"]
end

subgraph group_watch["Watch domain"]
  node_routes["Watch routes<br/>[routes.ts]"]
  node_schemas["Watch validation<br/>[schemas.ts]"]
  node_serialize["Watch response<br/>[serialize.ts]"]
end

subgraph group_persistence["Persistence"]
  node_prisma["Prisma client<br/>[db.ts]"]
  node_postgres[("PostgreSQL<br/>[schema.prisma]")]
end

node_user(("API caller"))
node_react["Starter frontend<br/>[App.tsx]"]

node_user -->|"sends requests"| node_app
node_app -->|"guards watches"| node_auth
node_app -->|"mounts routes"| node_routes
node_app -->|"builds docs"| node_openapi
node_app -->|"handles failures"| node_errors
node_routes -->|"validates input"| node_schemas
node_routes -->|"queries data"| node_prisma
node_routes -->|"formats watches"| node_serialize
node_routes -->|"throws errors"| node_errors
node_openapi -->|"reuses schemas"| node_schemas
node_prisma -.->|"persists records"| node_postgres

click node_app "https://github.com/shijake/ece1724_project/blob/main/express/src/app.ts"
click node_auth "https://github.com/shijake/ece1724_project/blob/main/express/src/auth.ts"
click node_errors "https://github.com/shijake/ece1724_project/blob/main/express/src/errors.ts"
click node_openapi "https://github.com/shijake/ece1724_project/blob/main/express/src/openapi.ts"
click node_routes "https://github.com/shijake/ece1724_project/blob/main/express/src/watches/routes.ts"
click node_schemas "https://github.com/shijake/ece1724_project/blob/main/express/src/watches/schemas.ts"
click node_serialize "https://github.com/shijake/ece1724_project/blob/main/express/src/watches/serialize.ts"
click node_prisma "https://github.com/shijake/ece1724_project/blob/main/express/src/db.ts"
click node_postgres "https://github.com/shijake/ece1724_project/blob/main/express/prisma/schema.prisma"
click node_react "https://github.com/shijake/ece1724_project/blob/main/react/my-app/src/App.tsx"

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_app,node_auth,node_errors,node_openapi,node_react toneBlue
class node_routes,node_schemas,node_serialize toneAmber
class node_prisma,node_postgres,node_user toneMint
```

## Components

### API runtime

- [Express app](https://github.com/shijake/ece1724_project/blob/main/express/src/app.ts): `express/src/app.ts`
- [User guard](https://github.com/shijake/ece1724_project/blob/main/express/src/auth.ts): `express/src/auth.ts`
- [Error handling](https://github.com/shijake/ece1724_project/blob/main/express/src/errors.ts): `express/src/errors.ts`
- [API documentation](https://github.com/shijake/ece1724_project/blob/main/express/src/openapi.ts): `express/src/openapi.ts`

### Watch domain

- [Watch routes](https://github.com/shijake/ece1724_project/blob/main/express/src/watches/routes.ts): `express/src/watches/routes.ts`
- [Watch validation](https://github.com/shijake/ece1724_project/blob/main/express/src/watches/schemas.ts): `express/src/watches/schemas.ts`
- [Watch response](https://github.com/shijake/ece1724_project/blob/main/express/src/watches/serialize.ts): `express/src/watches/serialize.ts`

### Persistence

- [Prisma client](https://github.com/shijake/ece1724_project/blob/main/express/src/db.ts): `express/src/db.ts`
- [PostgreSQL](https://github.com/shijake/ece1724_project/blob/main/express/prisma/schema.prisma): `express/prisma/schema.prisma`

### Other components

- **API caller**
- [Starter frontend](https://github.com/shijake/ece1724_project/blob/main/react/my-app/src/App.tsx): `react/my-app/src/App.tsx`

## Connections

- API caller → Express app: sends requests (evidence: `express/src/app.ts`)
- Express app → User guard: guards watches (evidence: `express/src/app.ts`)
- Express app → Watch routes: mounts routes (evidence: `express/src/app.ts`)
- Express app → API documentation: builds docs (evidence: `express/src/app.ts`)
- Express app → Error handling: handles failures (evidence: `express/src/app.ts`)
- Watch routes → Watch validation: validates input (evidence: `express/src/watches/routes.ts`)
- Watch routes → Prisma client: queries data (evidence: `express/src/watches/routes.ts`)
- Watch routes → Watch response: formats watches (evidence: `express/src/watches/routes.ts`)
- Watch routes → Error handling: throws errors (evidence: `express/src/watches/routes.ts`)
- API documentation → Watch validation: reuses schemas (evidence: `express/src/openapi.ts`)
- Prisma client → PostgreSQL: persists records
