# blurxr/ctcdevbryanchen architecture

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

- Interactive diagram: https://gitdiagram.com/blurxr/ctcdevbryanchen
- Repository: https://github.com/blurxr/ctcdevbryanchen

## Overview

Feeding Brennen is a Next.js starter for tracking restaurants, visits, and dining spend. The visible user workflow is a request to the home page, which fetches the restaurant list through the app’s HTTP API and renders it. Restaurant reads are implemented; write endpoints remain TODOs. The README describes the broader tracking scope, while sampled source shows visit types and seed data but not visit-facing routes or screens, so those are represented as limited data-layer capabilities. Edges reflect shown calls or README statements.

Main entry points: [`client/db/pool.ts`](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/pool.ts) (Connection pool), [`client/app/api/restaurants/route.ts`](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/api/restaurants/route.ts) (Restaurant routes), [`client/app/api/restaurants/[id]/route.ts`](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/api/restaurants/%5Bid%5D/route.ts) (Restaurant detail), [`client/db/migrations/001_create_tables.sql`](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/migrations/001_create_tables.sql) (Restaurant and visit schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Web interface"]
  node_home["Restaurant list<br/>[page.tsx]"]
  node_layout["App shell<br/>[layout.tsx]"]
  node_api_client["API fetch client<br/>[apiClient.ts]"]
end

subgraph group_api["Restaurant API"]
  node_restaurant_routes["Restaurant routes<br/>[route.ts]"]
  node_restaurant_detail["Restaurant detail<br/>[route.ts]"]
  node_health["Health route<br/>[route.ts]"]
  node_errors["Error mapper<br/>[errors.ts]"]
end

subgraph group_data["Database access"]
  node_types["API data mappers<br/>[types.ts]"]
  node_pool["Connection pool<br/>[pool.ts]"]
  node_schema["Restaurant and visit schema"]
end

subgraph group_operations["Data setup"]
  node_migrator["Migration runner<br/>[migrate.ts]"]
  node_seed["Sample data seeder<br/>[seed.ts]"]
end

node_visitor(("User"))
node_postgres[("PostgreSQL")]

node_visitor -->|"views"| node_home
node_home -->|"fetches list"| node_api_client
node_api_client -->|"HTTP GET"| node_restaurant_routes
node_restaurant_routes -->|"queries"| node_pool
node_restaurant_detail -->|"queries"| node_pool
node_restaurant_routes -->|"maps rows"| node_types
node_restaurant_detail -->|"maps rows"| node_types
node_restaurant_routes -->|"handles failures"| node_errors
node_restaurant_detail -->|"handles failures"| node_errors
node_pool -->|"connects"| node_postgres
node_migrator -->|"runs SQL"| node_pool
node_seed -->|"writes sample data"| node_pool
node_migrator -->|"loads migration"| node_schema
node_schema -.->|"defines tables"| node_postgres
node_seed -.->|"seeds restaurants and visits"| node_schema

click node_home "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/page.tsx"
click node_layout "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/layout.tsx"
click node_api_client "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/lib/apiClient.ts"
click node_restaurant_routes "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/api/restaurants/route.ts"
click node_restaurant_detail "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/api/restaurants/%5Bid%5D/route.ts"
click node_health "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/api/health/route.ts"
click node_errors "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/lib/errors.ts"
click node_types "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/lib/types.ts"
click node_pool "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/pool.ts"
click node_schema "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/migrations/001_create_tables.sql"
click node_migrator "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/migrate.ts"
click node_seed "https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/seed.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_home,node_layout,node_api_client,node_visitor toneBlue
class node_restaurant_routes,node_restaurant_detail,node_health,node_errors,node_postgres toneAmber
class node_types,node_pool,node_schema toneMint
class node_migrator,node_seed toneRose
```

## Components

### Web interface

- [Restaurant list](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/page.tsx): `client/app/page.tsx`
- [App shell](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/layout.tsx): `client/app/layout.tsx`
- [API fetch client](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/lib/apiClient.ts): `client/lib/apiClient.ts`

### Restaurant API

- [Restaurant routes](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/api/restaurants/route.ts): `client/app/api/restaurants/route.ts`
- [Restaurant detail](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/api/restaurants/%5Bid%5D/route.ts): `client/app/api/restaurants/[id]/route.ts`
- [Health route](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/app/api/health/route.ts): `client/app/api/health/route.ts`
- [Error mapper](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/lib/errors.ts): `client/lib/errors.ts`

### Database access

- [API data mappers](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/lib/types.ts): `client/lib/types.ts`
- [Connection pool](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/pool.ts): `client/db/pool.ts`
- [Restaurant and visit schema](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/migrations/001_create_tables.sql): `client/db/migrations/001_create_tables.sql`

### Data setup

- [Migration runner](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/migrate.ts): `client/db/migrate.ts`
- [Sample data seeder](https://github.com/blurxr/ctcdevbryanchen/blob/main/client/db/seed.ts): `client/db/seed.ts`

### Other components

- **User**
- **PostgreSQL**

## Connections

- User → Restaurant list: views (evidence: `README.md`)
- Restaurant list → API fetch client: fetches list (evidence: `client/app/page.tsx`)
- API fetch client → Restaurant routes: HTTP GET (evidence: `client/lib/apiClient.ts`)
- Restaurant routes → Connection pool: queries (evidence: `client/app/api/restaurants/route.ts`)
- Restaurant detail → Connection pool: queries (evidence: `client/app/api/restaurants/[id]/route.ts`)
- Restaurant routes → API data mappers: maps rows (evidence: `client/app/api/restaurants/route.ts`)
- Restaurant detail → API data mappers: maps rows (evidence: `client/app/api/restaurants/[id]/route.ts`)
- Restaurant routes → Error mapper: handles failures (evidence: `client/app/api/restaurants/route.ts`)
- Restaurant detail → Error mapper: handles failures (evidence: `client/app/api/restaurants/[id]/route.ts`)
- Connection pool → PostgreSQL: connects (evidence: `client/db/pool.ts`)
- Migration runner → Connection pool: runs SQL (evidence: `client/db/migrate.ts`)
- Sample data seeder → Connection pool: writes sample data (evidence: `client/db/seed.ts`)
- Migration runner → Restaurant and visit schema: loads migration (evidence: `client/db/migrate.ts`)
- Restaurant and visit schema → PostgreSQL: defines tables
- Sample data seeder → Restaurant and visit schema: seeds restaurants and visits
