# sahoo-tech/health-connect architecture

> Architecture diagram of the GitHub repository sahoo-tech/health-connect, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sahoo-tech/health-connect
- Repository: https://github.com/sahoo-tech/health-connect

## Overview

1. **Repository shape**
   - This is a two-part monorepo:
     - `health-connect`: a Next.js frontend application.
     - `health-connect-api`: a separate Express/TypeScript backend API.
   - The split is a hard architectural boundary: the frontend renders UI and calls the API over HTTP/JSON; the backend owns booking logic and state.

2. **Frontend subsystem (`health-connect`)**
   - Uses the Next.js App Router structure under `src/app`.
   - Main user-facing surfaces are:
     - public/marketing pages like home and about,
     - authentication (`/login`),
     - requester flows (`/requester/...`),
     - admin flows (`/admin/...`).
   - This suggests two distinct user roles: requester and admin.

3. **Frontend page-level domains**
   - Requester area includes booking creation, booking detail, and requester dashboard.
   - Admin area includes a dashboard and booking detail views.
   - The routing structure implies role-based navigation and separate views over the same underlying booking data.

4. **Frontend shared UI layer**
   - `src/components` contains reusable UI elements such as:
     - `Header`, `StatusBadge`, `Toast`,
     - `SlotPicker` for availability selection,
     - visual/interaction helpers like `AnimatedBackground`, `CursorEffect`.
   - These are presentation concerns only; they do not appear to own business state.

5. **Frontend service/integration layer**
   - `src/lib/api.ts` is the client-side API adapter used to talk to the backend.
   - `src/lib/types.ts` defines frontend-side data contracts.
   - This isolates network calls and shared shapes from page components, which is important for diagramming the UI-to-API boundary.

6. **Backend subsystem (`health-connect-api`)**
   - The API is organized as an Express app in TypeScript.
   - `src/index.ts` is the main server entrypoint, with route modules under `src/routes`.
   - `api/index.ts` and `vercel.json` indicate a deployment wrapper for serverless/hosted API entry, likely optimized for Vercel-style deployment.

7. **Backend domain modules**
   - Route modules are split by responsibility:
     - `auth.ts` for authentication/authorization,
     - `slots.ts` for availability lookup,
     - `bookings.ts` for booking creation and retrieval,
     - `admin.ts` for administrative operations.
   - This is the clearest place to draw backend subdomains: identity, availability, booking management, and admin control.

8. **Backend state and persistence boundary**
   - `src/store.ts` indicates an in-memory store rather than a database-backed persistence layer.
   - That means bookings/slots/state are maintained inside the API process, so the system is stateless at the HTTP contract level but not durable across process restarts.
   - For an architecture diagram, this should be shown as “in-memory application state” rather than an external datastore.

9. **Primary data flow**
   - A requester/admin page renders in the Next.js app.
   - The page/component calls the backend through `lib/api.ts`.
   - The backend routes request to the relevant domain module.
   - Domain logic reads/writes the in-memory store and returns JSON.
   - The frontend maps the response into UI state, e.g. slot lists, booking details, badges, and toasts.

10. **Booking lifecycle**
   - The booking flow centers on availability discovery and reservation:
     - fetch slots,
     - select a slot,
     - submit a booking,
     - retrieve booking detail/status.
   - Both requester and admin views likely read from the same booking model, but requester can initiate bookings while admin manages or reviews them.

11. **Authentication/authorization boundary**
   - `auth.ts` suggests the backend controls login/session or token validation.
   - The presence of separate admin routes implies role-based access control is enforced server-side, not just by hiding pages in the frontend.
   - The login page in the frontend is therefore a gateway into role-specific sections.

12. **Deployment/runtime implications**
   - Frontend: Next.js/React application, likely deployed as a web app with static and server-rendered routes.
   - Backend: Express API with TypeScript, deployable independently from the frontend.
   - The repo’s config files and deployment notes suggest the two services are intended to be deployed separately and integrated over a configured API base URL.

13. **What is not present**
   - No database, message queue, search service, or external integration appears in the tree.
   - No background worker or scheduled job subsystem is visible.
   - So the architecture is intentionally simple: UI + HTTP API + in-memory store.

14. **How to draw it**
   - Draw two top-level boxes: “Next.js Frontend” and “Express API.”
   - Inside the frontend, separate public pages, requester pages, admin pages, and shared UI/lib.
   - Inside the backend, separate route modules and a shared in-memory store.
   - Show the frontend calling the backend via `lib/api.ts`, and the backend routes reading/writing `store.ts`.

Main entry points: [`health-connect/src/lib/api.ts`](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/lib/api.ts) (API Client), [`health-connect-api/src/index.ts`](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/index.ts) (Server Entry), [`health-connect-api/src/routes/bookings.ts`](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/bookings.ts) (Bookings Routes), [`health-connect-api/src/routes/admin.ts`](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/admin.ts) (Admin Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Next.js Frontend"]
  node_fe_home["Home<br/>page<br/>[page.tsx]"]
  node_fe_about["About<br/>page<br/>[page.tsx]"]
  node_fe_login["Login<br/>page<br/>[page.tsx]"]
  node_fe_req_dash["Requester Dash<br/>page<br/>[page.tsx]"]
  node_fe_req_book["Book Slot<br/>page<br/>[page.tsx]"]
  node_fe_req_detail["Booking Detail<br/>page<br/>[page.tsx]"]
  node_fe_admin_dash["Admin Dash<br/>page<br/>[page.tsx]"]
  node_fe_admin_detail["Admin Detail<br/>page<br/>[page.tsx]"]
  node_fe_header["Header<br/>ui<br/>[Header.tsx]"]
  node_fe_slot_picker["Slot Picker<br/>ui<br/>[SlotPicker.tsx]"]
  node_fe_status_badge["Status Badge<br/>ui<br/>[StatusBadge.tsx]"]
  node_fe_toast["Toast<br/>ui<br/>[Toast.tsx]"]
  node_fe_api["API Client<br/>adapter<br/>[api.ts]"]
  node_fe_types["Client Types<br/>contracts<br/>[types.ts]"]
end

subgraph group_backend["Express API"]
  node_be_entry["Server Entry<br/>[index.ts]"]
  node_be_auth["Auth Routes<br/>route module<br/>[auth.ts]"]
  node_be_slots["Slots Routes<br/>route module<br/>[slots.ts]"]
  node_be_bookings["Bookings Routes<br/>route module<br/>[bookings.ts]"]
  node_be_admin["Admin Routes<br/>route module<br/>[admin.ts]"]
  node_be_store[("In-Memory Store<br/>state<br/>[store.ts]")]
  node_be_types["API Types<br/>contracts<br/>[types.ts]"]
  node_be_vercel["API Wrapper<br/>deployment<br/>[index.ts]"]
end

node_fe_home -->|"uses"| node_fe_header
node_fe_about -->|"uses"| node_fe_header
node_fe_login -->|"uses"| node_fe_header
node_fe_req_dash -->|"calls"| node_fe_api
node_fe_req_book -->|"uses"| node_fe_slot_picker
node_fe_req_book -->|"calls"| node_fe_api
node_fe_req_detail -->|"uses"| node_fe_status_badge
node_fe_req_detail -->|"calls"| node_fe_api
node_fe_admin_dash -->|"calls"| node_fe_api
node_fe_admin_detail -->|"uses"| node_fe_status_badge
node_fe_admin_detail -->|"calls"| node_fe_api
node_fe_api -->|"uses"| node_fe_types
node_fe_api -->|"http/json"| node_be_vercel
node_be_vercel -->|"loads"| node_be_entry
node_be_entry -->|"mounts"| node_be_auth
node_be_entry -->|"mounts"| node_be_slots
node_be_entry -->|"mounts"| node_be_bookings
node_be_entry -->|"mounts"| node_be_admin
node_be_auth -->|"uses"| node_be_types
node_be_slots -->|"uses"| node_be_types
node_be_bookings -->|"uses"| node_be_types
node_be_admin -->|"uses"| node_be_types
node_be_auth -->|"reads/writes"| node_be_store
node_be_slots -->|"reads"| node_be_store
node_be_bookings -->|"reads/writes"| node_be_store
node_be_admin -->|"reads/writes"| node_be_store
node_fe_login -->|"gateway"| node_be_auth
node_fe_req_book -->|"availability"| node_be_slots
node_fe_req_book -->|"reserve"| node_be_bookings
node_fe_req_detail -->|"detail"| node_be_bookings
node_fe_admin_dash -->|"manage"| node_be_admin
node_fe_admin_detail -->|"review"| node_be_admin

click node_fe_home "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/page.tsx"
click node_fe_about "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/about/page.tsx"
click node_fe_login "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/login/page.tsx"
click node_fe_req_dash "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/requester/dashboard/page.tsx"
click node_fe_req_book "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/requester/book/page.tsx"
click node_fe_req_detail "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/requester/booking/[id]/page.tsx"
click node_fe_admin_dash "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/admin/dashboard/page.tsx"
click node_fe_admin_detail "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/admin/booking/[id]/page.tsx"
click node_fe_header "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/components/Header.tsx"
click node_fe_slot_picker "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/components/SlotPicker.tsx"
click node_fe_status_badge "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/components/StatusBadge.tsx"
click node_fe_toast "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/components/Toast.tsx"
click node_fe_api "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/lib/api.ts"
click node_fe_types "https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/lib/types.ts"
click node_be_entry "https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/index.ts"
click node_be_auth "https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/auth.ts"
click node_be_slots "https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/slots.ts"
click node_be_bookings "https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/bookings.ts"
click node_be_admin "https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/admin.ts"
click node_be_store "https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/store.ts"
click node_be_types "https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/types.ts"
click node_be_vercel "https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/api/index.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_fe_home,node_fe_about,node_fe_login,node_fe_req_dash,node_fe_req_book,node_fe_req_detail,node_fe_admin_dash,node_fe_admin_detail,node_fe_header,node_fe_slot_picker,node_fe_status_badge,node_fe_toast,node_fe_api,node_fe_types toneBlue
class node_be_entry,node_be_auth,node_be_slots,node_be_bookings,node_be_admin,node_be_store,node_be_types,node_be_vercel toneAmber
```

## Components

### Next.js Frontend

React app with public, requester, and admin flows.

- [Home](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/page.tsx): page · Public landing page. · `health-connect/src/app/page.tsx`
- [About](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/about/page.tsx): page · Public about page. · `health-connect/src/app/about/page.tsx`
- [Login](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/login/page.tsx): page · Authentication entry page. · `health-connect/src/app/login/page.tsx`
- [Requester Dash](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/requester/dashboard/page.tsx): page · Requester dashboard and booking overview. · `health-connect/src/app/requester/dashboard/page.tsx`
- [Book Slot](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/requester/book/page.tsx): page · Requester booking creation flow. · `health-connect/src/app/requester/book/page.tsx`
- [Booking Detail](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/requester/booking/[id]/page.tsx): page · Requester booking detail view. · `health-connect/src/app/requester/booking/[id]/page.tsx`
- [Admin Dash](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/admin/dashboard/page.tsx): page · Admin dashboard and oversight view. · `health-connect/src/app/admin/dashboard/page.tsx`
- [Admin Detail](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/app/admin/booking/[id]/page.tsx): page · Admin booking detail view. · `health-connect/src/app/admin/booking/[id]/page.tsx`
- [Header](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/components/Header.tsx): ui · Shared top-level navigation. · `health-connect/src/components/Header.tsx`
- [Slot Picker](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/components/SlotPicker.tsx): ui · Availability selection control. · `health-connect/src/components/SlotPicker.tsx`
- [Status Badge](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/components/StatusBadge.tsx): ui · Booking/status display component. · `health-connect/src/components/StatusBadge.tsx`
- [Toast](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/components/Toast.tsx): ui · Transient user feedback component. · `health-connect/src/components/Toast.tsx`
- [API Client](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/lib/api.ts): adapter · Frontend HTTP adapter for backend calls. · `health-connect/src/lib/api.ts`
- [Client Types](https://github.com/sahoo-tech/health-connect/blob/main/health-connect/src/lib/types.ts): contracts · Frontend data contracts and shared shapes. · `health-connect/src/lib/types.ts`

### Express API

TypeScript HTTP API with route modules and in-memory state.

- [Server Entry](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/index.ts): server · Express application bootstrap. · `health-connect-api/src/index.ts`
- [Auth Routes](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/auth.ts): route module · Authentication and authorization endpoints. · `health-connect-api/src/routes/auth.ts`
- [Slots Routes](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/slots.ts): route module · Availability lookup endpoints. · `health-connect-api/src/routes/slots.ts`
- [Bookings Routes](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/bookings.ts): route module · Booking creation and retrieval endpoints. · `health-connect-api/src/routes/bookings.ts`
- [Admin Routes](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/routes/admin.ts): route module · Administrative operations and oversight endpoints. · `health-connect-api/src/routes/admin.ts`
- [In-Memory Store](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/store.ts): state · Application state for slots and bookings. · `health-connect-api/src/store.ts`
- [API Types](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/src/types.ts): contracts · Backend domain types and response shapes. · `health-connect-api/src/types.ts`
- [API Wrapper](https://github.com/sahoo-tech/health-connect/blob/main/health-connect-api/api/index.ts): deployment · Serverless entry wrapper for hosted deployment. · `health-connect-api/api/index.ts`

## Connections

- Home → Header: uses · Shared page chrome.
- About → Header: uses · Shared page chrome.
- Login → Header: uses · Shared page chrome.
- Requester Dash → API Client: calls · Loads requester data over HTTP.
- Book Slot → Slot Picker: uses · Selects available time slots.
- Book Slot → API Client: calls · Fetches slots and submits bookings.
- Booking Detail → Status Badge: uses · Shows booking state.
- Booking Detail → API Client: calls · Loads booking details.
- Admin Dash → API Client: calls · Fetches admin overview data.
- Admin Detail → Status Badge: uses · Shows booking state.
- Admin Detail → API Client: calls · Loads booking details.
- API Client → Client Types: uses · Shares client-side contracts.
- API Client → API Wrapper: http/json · Frontend talks to backend over HTTP.
- API Wrapper → Server Entry: loads · Hosted wrapper forwards to server entry.
- Server Entry → Auth Routes: mounts · Registers auth routes.
- Server Entry → Slots Routes: mounts · Registers slot routes.
- Server Entry → Bookings Routes: mounts · Registers booking routes.
- Server Entry → Admin Routes: mounts · Registers admin routes.
- Auth Routes → API Types: uses · Uses shared API types.
- Slots Routes → API Types: uses · Uses shared API types.
- Bookings Routes → API Types: uses · Uses shared API types.
- Admin Routes → API Types: uses · Uses shared API types.
- Auth Routes → In-Memory Store: reads/writes · Auth-related state access.
- Slots Routes → In-Memory Store: reads · Reads availability from memory.
- Bookings Routes → In-Memory Store: reads/writes · Creates and fetches bookings.
- Admin Routes → In-Memory Store: reads/writes · Admin state access.
- Login → Auth Routes: gateway · Login leads into server-side auth flow.
- Book Slot → Slots Routes: availability · Booking flow begins with slot lookup.
- Book Slot → Bookings Routes: reserve · Booking flow submits reservations.
- Booking Detail → Bookings Routes: detail · Requester booking detail comes from booking API.
- Admin Dash → Admin Routes: manage · Admin dashboard depends on admin endpoints.
- Admin Detail → Admin Routes: review · Admin detail view depends on admin endpoints.
