# tahayparker/vacansee architecture

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

- Interactive diagram: https://gitdiagram.com/tahayparker/vacansee
- Repository: https://github.com/tahayparker/vacansee

## Overview

1. **Overall shape**
   - `vacansee` is a single Next.js application using the Pages Router, with the frontend, API layer, and auth flows living in one repo.
   - The runtime boundary is mostly “browser app” vs “Next.js serverless/API routes” vs “offline/maintenance scripts.”

2. **Primary user-facing app**
   - Pages under `src/pages` implement the main experience: room availability, room search, timetable graphs, profile, docs, legal/about, and auth screens.
   - The app is styled with Tailwind CSS and a local component library in `src/components/ui`, plus higher-level site components like header/footer, onboarding, loading states, and graph/visualization UI.

3. **Client-side state and UX**
   - Several reusable hooks manage browser concerns such as debouncing, local storage persistence, form persistence, room search, and auth gating.
   - `TimeFormatContext` and preference hooks suggest user settings are handled on the client and persisted locally where appropriate.

4. **API boundary**
   - `src/pages/api` contains the backend endpoints used by the UI: current/soon availability, availability checks, room listings, schedule data, and auth callback handling.
   - These routes form the server-facing contract for the app and are the main bridge between the browser UI and persisted timetable data.

5. **Business logic layer**
   - `src/services` centralizes room and timetable logic, including room combinations, room lookup/availability logic, and time computations.
   - This layer sits between API routes and the database, keeping the route handlers thinner and making room-availability logic reusable across endpoints/pages.

6. **Persistence and database**
   - Prisma is the data access layer (`prisma/schema.prisma`, migrations, `src/lib/prisma.ts`), and the database is PostgreSQL hosted on Supabase.
   - The repo’s schema/migrations indicate timetable and room data are normalized in the DB, with the app reading that source for live availability and schedule views.

7. **Authentication and authorization**
   - Supabase is also used for auth (`src/lib/supabase/client.ts`, `src/lib/supabase/server.ts`), with a login page, callback endpoint, middleware, and a `useRequireAuth` hook.
   - Protected areas appear to include profile-related or user-specific routes, with `unauthorized` and auth middleware shaping access boundaries.

8. **Timetable ingestion pipeline**
   - The repo includes standalone Python scripts under `scripts/` for scraping the timetable site, generating schedule data, updating room data, and uploading updates.
   - This is an external data-ingestion subsystem, separate from the web app runtime, and is responsible for turning the source timetable into database-ready data.

9. **Automation and operations**
   - GitHub Actions workflows handle daily timetable updates, Supabase pings, CodeQL scanning, and Next.js-related checks/builds.
   - The update workflow is a key operational dependency: scrape latest timetable data, update the DB, generate `public/scheduleData.json`, and commit the refreshed artifacts.

10. **Offline/PWA layer**
   - The app is configured as a PWA with `public/manifest.json`, `public/sw.js`, `public/offline.html`, install prompt UI, and service-worker caching support.
   - This creates a browser-side resilience layer for static assets and fallback behavior, which is architecturally separate from the live API/database path.

11. **Static/public assets**
   - `public/classes.csv`, `public/scheduleData.json`, fonts, and icons are part of the deployed asset set and likely used for room/timetable rendering or fallbacks.
   - These assets matter because some schedule presentation appears to be pre-generated rather than always computed live.

12. **Deployment boundary**
   - The app is designed for Vercel deployment, so the Next.js app and API routes are expected to run in a serverless/edge-friendly hosting model.
   - Long-running or scheduled work is intentionally pushed out of the app runtime into GitHub Actions and scripts, keeping the web tier lean.

Main entry points: [`src/pages`](https://github.com/tahayparker/vacansee/tree/main/src/pages) (Pages), [`src/pages/api`](https://github.com/tahayparker/vacansee/tree/main/src/pages/api) (API routes), [`src/lib/prisma.ts`](https://github.com/tahayparker/vacansee/blob/main/src/lib/prisma.ts) (Prisma client), [`.github/workflows/update-timetable.yml`](https://github.com/tahayparker/vacansee/blob/main/.github/workflows/update-timetable.yml) (GitHub Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Browser app"]
  node_n1["Pages<br/>Next.js routes"]
  node_n2["UI kit<br/>component library"]
  node_n3["Hooks & state<br/>client state"]
  node_n4(("Prefs context<br/>client context"))
  node_n11["Auth pages<br/>login flow<br/>[login.tsx]"]
end

subgraph group_g2["Server API"]
  node_n5["API routes<br/>server routes"]
  node_n6["Middleware<br/>auth boundary<br/>[middleware.ts]"]
  node_n7["Services<br/>business logic"]
  node_n18["Config<br/>[next.config.ts]"]
end

subgraph group_g3["Data & auth"]
  node_n8[("Prisma client<br/>db access<br/>[prisma.ts]")]
  node_n9[("Schema<br/>[schema.prisma]")]
  node_n10["Supabase auth<br/>auth client/server"]
end

subgraph group_g4["Ops & ingestion"]
  node_n15["Scrapers<br/>python pipeline"]
  node_n16["Update jobs<br/>automation<br/>[update_rooms.py]"]
  node_n17["GitHub Actions<br/>ci/cd"]
end

subgraph group_g5["Public assets"]
  node_n12["PWA layer<br/>offline support<br/>[sw.js]"]
  node_n13["Schedule data<br/>generated asset<br/>[scheduleData.json]"]
  node_n14["Static assets<br/>public assets"]
end

node_n1 -->|"renders with"| node_n2
node_n1 -->|"uses hooks"| node_n3
node_n1 -->|"reads prefs"| node_n4
node_n1 -->|"calls"| node_n5
node_n1 -->|"navigates to"| node_n11
node_n5 -->|"delegates"| node_n7
node_n5 -->|"queries"| node_n8
node_n7 -->|"reads via"| node_n8
node_n8 -->|"maps to"| node_n9
node_n10 -->|"supports"| node_n11
node_n6 -->|"guards"| node_n10
node_n11 -->|"is shaped by"| node_n6
node_n12 -->|"caches"| node_n14
node_n12 -->|"serves"| node_n13
node_n15 -->|"generates"| node_n13
node_n16 -->|"refreshes"| node_n13
node_n17 -->|"runs"| node_n15
node_n17 -->|"runs"| node_n16
node_n17 -->|"updates"| node_n8
node_n18 -->|"configures"| node_n1
node_n18 -->|"configures"| node_n5

click node_n1 "https://github.com/tahayparker/vacansee/tree/main/src/pages"
click node_n2 "https://github.com/tahayparker/vacansee/tree/main/src/components"
click node_n3 "https://github.com/tahayparker/vacansee/tree/main/src/hooks"
click node_n4 "https://github.com/tahayparker/vacansee/blob/main/src/contexts/TimeFormatContext.tsx"
click node_n5 "https://github.com/tahayparker/vacansee/tree/main/src/pages/api"
click node_n6 "https://github.com/tahayparker/vacansee/blob/main/src/middleware.ts"
click node_n7 "https://github.com/tahayparker/vacansee/tree/main/src/services"
click node_n8 "https://github.com/tahayparker/vacansee/blob/main/src/lib/prisma.ts"
click node_n9 "https://github.com/tahayparker/vacansee/blob/main/prisma/schema.prisma"
click node_n10 "https://github.com/tahayparker/vacansee/tree/main/src/lib/supabase"
click node_n11 "https://github.com/tahayparker/vacansee/blob/main/src/pages/auth/login.tsx"
click node_n12 "https://github.com/tahayparker/vacansee/blob/main/public/sw.js"
click node_n13 "https://github.com/tahayparker/vacansee/blob/main/public/scheduleData.json"
click node_n14 "https://github.com/tahayparker/vacansee/tree/main/public"
click node_n15 "https://github.com/tahayparker/vacansee/blob/main/scripts/scrape_timetable.py"
click node_n16 "https://github.com/tahayparker/vacansee/blob/main/scripts/update_rooms.py"
click node_n17 "https://github.com/tahayparker/vacansee/blob/main/.github/workflows/update-timetable.yml"
click node_n18 "https://github.com/tahayparker/vacansee/blob/main/next.config.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_n1,node_n2,node_n3,node_n4,node_n11 toneBlue
class node_n5,node_n6,node_n7,node_n18 toneAmber
class node_n8,node_n9,node_n10 toneMint
class node_n15,node_n16,node_n17 toneRose
class node_n12,node_n13,node_n14 toneIndigo
```

## Components

### Browser app

Next.js pages, reusable UI, and client-side state

- [Pages](https://github.com/tahayparker/vacansee/tree/main/src/pages): Next.js routes · Main user-facing pages for rooms, availability, graphs, auth, docs, and legal content · `src/pages`
- [UI kit](https://github.com/tahayparker/vacansee/tree/main/src/components): component library · Reusable UI primitives and site-level components shared across pages · `src/components`
- [Hooks & state](https://github.com/tahayparker/vacansee/tree/main/src/hooks): client state · Browser persistence, debouncing, room search, and auth-gating hooks · `src/hooks`
- [Prefs context](https://github.com/tahayparker/vacansee/blob/main/src/contexts/TimeFormatContext.tsx): client context · Time-format and user preference state for the browser experience · `src/contexts/TimeFormatContext.tsx`
- [Auth pages](https://github.com/tahayparker/vacansee/blob/main/src/pages/auth/login.tsx): login flow · Login, callback, and unauthorized screens for protected access · `src/pages/auth/login.tsx`

### Server API

Route handlers, middleware, and server-side integration points

- [API routes](https://github.com/tahayparker/vacansee/tree/main/src/pages/api): server routes · Availability, room, schedule, and auth callback endpoints used by the UI · `src/pages/api`
- [Middleware](https://github.com/tahayparker/vacansee/blob/main/src/middleware.ts): auth boundary · Request-time access control and route shaping · `src/middleware.ts`
- [Services](https://github.com/tahayparker/vacansee/tree/main/src/services): business logic · Room combinations, room lookup, availability, and time calculations · `src/services`
- [Config](https://github.com/tahayparker/vacansee/blob/main/next.config.ts): app config · Next.js, Tailwind, Prisma, and deployment configuration · `next.config.ts`

### Data & auth

Database schema, Prisma access, and Supabase auth

- [Prisma client](https://github.com/tahayparker/vacansee/blob/main/src/lib/prisma.ts): db access · Shared Prisma client used by server code · `src/lib/prisma.ts`
- [Schema](https://github.com/tahayparker/vacansee/blob/main/prisma/schema.prisma): database schema · Prisma schema and migrations for timetable and room data · `prisma/schema.prisma`
- [Supabase auth](https://github.com/tahayparker/vacansee/tree/main/src/lib/supabase): auth client/server · Supabase client and server helpers for login and session handling · `src/lib/supabase`

### Ops & ingestion

Scripts and automation that refresh timetable data

- [Scrapers](https://github.com/tahayparker/vacansee/blob/main/scripts/scrape_timetable.py): python pipeline · Timetable scraping and authenticated collection scripts · `scripts/scrape_timetable.py`
- [Update jobs](https://github.com/tahayparker/vacansee/blob/main/scripts/update_rooms.py): automation · Schedule generation, room updates, and upload scripts · `scripts/update_rooms.py`
- [GitHub Actions](https://github.com/tahayparker/vacansee/blob/main/.github/workflows/update-timetable.yml): ci/cd · Daily updates, checks, and Supabase ping workflows · `.github/workflows/update-timetable.yml`

### Public assets

Prebuilt assets and offline/PWA files served to browsers

- [PWA layer](https://github.com/tahayparker/vacansee/blob/main/public/sw.js): offline support · Manifest, service worker, and offline fallback for installable browser use · `public/sw.js`
- [Schedule data](https://github.com/tahayparker/vacansee/blob/main/public/scheduleData.json): generated asset · Precomputed timetable data consumed by the app and update pipeline · `public/scheduleData.json`
- [Static assets](https://github.com/tahayparker/vacansee/tree/main/public): public assets · Fonts, CSVs, icons, and other deployed browser assets · `public`

## Connections

- Pages → UI kit: renders with · Pages compose reusable site and UI components
- Pages → Hooks & state: uses hooks · Pages depend on client-side state and browser helpers
- Pages → Prefs context: reads prefs · Time display and user preferences flow into pages
- Pages → API routes: calls · Browser pages consume server API endpoints
- Pages → Auth pages: navigates to · Auth-related pages are part of the user flow
- API routes → Services: delegates · Route handlers keep business logic in services
- API routes → Prisma client: queries · API routes access data through Prisma
- Services → Prisma client: reads via · Room and timetable logic is backed by the database layer
- Prisma client → Schema: maps to · Prisma client is generated from the schema and migrations
- Supabase auth → Auth pages: supports · Supabase auth underpins login and callback handling
- Middleware → Supabase auth: guards · Middleware helps enforce auth/session boundaries
- Auth pages → Middleware: is shaped by · Protected routes are controlled at request time
- PWA layer → Static assets: caches · Service worker and offline mode rely on public assets
- PWA layer → Schedule data: serves · Offline and installable app behavior may use generated schedule data
- Scrapers → Schedule data: generates · Scraping pipeline produces timetable data artifacts
- Update jobs → Schedule data: refreshes · Update scripts regenerate schedule data and related outputs
- GitHub Actions → Scrapers: runs · Automated workflows execute scraping and update steps
- GitHub Actions → Update jobs: runs · Workflows also drive room updates and uploads
- GitHub Actions → Prisma client: updates · Automation may push refreshed data through the app stack
- Config → Pages: configures · Framework config shapes how pages are built and deployed
- Config → API routes: configures · Next.js configuration affects serverless route behavior
