# joshua-id/swiss-hub architecture

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

- Interactive diagram: https://gitdiagram.com/joshua-id/swiss-hub
- Repository: https://github.com/joshua-id/swiss-hub

## Overview

#### Purpose and Entry Points
Swiss-Hub is a client-side e-learning SPA for separate student learning and admin course-management workflows. React mounts from `src/main.tsx`; `src/App.tsx` owns application routing and page composition. Vite builds the static deployment artifact, with hosting behavior configured in `vercel.json`.

#### Application Shell and Access Control
The route layer maps public, student, and admin pages, while route-level authorization is enforced by `src/components/ProtectedRoute.tsx`. Shared navigation in `src/components/Navbar.tsx` is role-aware and currently supports demo user/role switching rather than production authentication. Sign-in, sign-up, and waitlist experiences are present at `src/pages/SignInPage.tsx`, `src/pages/SignUpPage.tsx`, and `src/pages/WaitlistPage.tsx`.

#### Domain Model and Client State
The learning domain consists of users, courses, lessons, enrollments, and lesson progress, typed in `src/types/index.ts` and database-oriented types in `src/types/database.ts`. `src/store/useStore.ts` is the central Zustand state boundary: it holds current-user context and learning/admin entities, exposes course CRUD, enrollment, and completion actions, and persists client state through local storage. This allows the app to operate without a live backend.

#### Student Learning Flow
Students enter through `src/pages/StudentDashboard.tsx` or discover offerings in `src/pages/CourseCatalog.tsx`, which supports browsing, searching/filtering, enrollment, and prerequisite locking. `src/pages/CourseDetail.tsx` resolves a course’s curriculum and access/progress state. `src/pages/LessonView.tsx` presents individual lesson content, materials, sequential navigation, and completion toggling; updates feed back into store-derived course progress. `src/components/CourseCard.tsx` and `src/components/ProgressBadge.tsx` render shared enrollment and progress state.

#### Admin Course Management Flow
Admins use `src/pages/AdminDashboard.tsx` for aggregate learning/catalog metrics and `src/pages/AdminCourses.tsx` for course administration. `src/pages/CourseForm.tsx` creates or edits course metadata, including prerequisite relationships. These pages mutate the same Zustand course and lesson-facing state used by student views, creating an immediate client-side catalog update boundary.

#### API and Persistence Boundary
The repository contains an intended service abstraction in `src/api/backendService.ts` and `src/api/backend.ts`, with declarations in `src/api/backend.d.ts`. The current local/demo data source is `src/api/mockData.ts`; state persistence is browser-local rather than server-backed. Supabase client/type placeholders exist at `src/lib/supabase.ts` and `src/lib/supabase.d.ts`, but the stated target integration is a backend providing authentication, database CRUD, and file storage. Replacing mock/store-only mutations with service calls is the main production boundary.

#### Runtime, UI, and Deployment
The app runs on React 18, TypeScript, and Vite, using React Router for navigation and Zustand for state. Styling is primarily Tailwind-based with global styles in `src/index.css`; reusable modal/loading primitives include `src/components/Modal.tsx` and `src/components/LoadingSpinner.tsx`. It produces a static `dist/` build suitable for Vercel or other static hosting, while any real auth, media/video, and persistence services must be externally provisioned.

Main entry points: [`src/store/useStore.ts`](https://github.com/joshua-id/swiss-hub/blob/master/src/store/useStore.ts) (Zustand store), [`src/App.tsx`](https://github.com/joshua-id/swiss-hub/blob/master/src/App.tsx) (App routes), [`src/pages/CourseCatalog.tsx`](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/CourseCatalog.tsx) (Course catalog), [`src/components/ProtectedRoute.tsx`](https://github.com/joshua-id/swiss-hub/blob/master/src/components/ProtectedRoute.tsx) (Protected routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Client Runtime"]
  node_vite{{"Vite build<br/>build tool"}}
  node_main["React entry<br/>React bootstrap<br/>[main.tsx]"]
  node_app["App routes<br/>route composition<br/>[App.tsx]"]
  node_protected_route["Protected routes<br/>route authorization<br/>[ProtectedRoute.tsx]"]
  node_navbar["Role-aware navigation<br/>shared UI<br/>[Navbar.tsx]"]
  node_access_pages["Access pages<br/>[SignInPage.tsx]"]
  node_static_host{{"Static hosting<br/>deployment target<br/>[vercel.json]"}}
end

subgraph group_student["Student Learning"]
  node_student_dashboard["Student dashboard<br/>student page"]
  node_catalog["Course catalog<br/>student page<br/>[CourseCatalog.tsx]"]
  node_course_detail["Course detail<br/>student page<br/>[CourseDetail.tsx]"]
  node_lesson_view["Lesson view<br/>student page<br/>[LessonView.tsx]"]
  node_student_ui["Course &amp; progress UI<br/>shared UI<br/>[CourseCard.tsx]"]
end

subgraph group_admin["Admin Management"]
  node_admin_dashboard["Admin dashboard<br/>admin page<br/>[AdminDashboard.tsx]"]
  node_admin_courses["Course administration<br/>admin page<br/>[AdminCourses.tsx]"]
  node_course_form["Course editor<br/>admin form<br/>[CourseForm.tsx]"]
end

subgraph group_data["State &amp; Data Boundary"]
  node_store[("Zustand store<br/>client state boundary<br/>[useStore.ts]")]
  node_domain_types["Learning domain types<br/>TypeScript models<br/>[index.ts]"]
  node_mock_data[("Demo data<br/>local data source<br/>[mockData.ts]")]
  node_local_storage[("Browser local storage<br/>client persistence")]
  node_backend_service["Backend service abstraction<br/>intended API boundary<br/>[backendService.ts]"]
  node_supabase["Supabase placeholder<br/>external integration stub<br/>[supabase.ts]"]
end

node_vite -->|"builds"| node_main
node_vite -->|"deploys dist"| node_static_host
node_main -->|"mounts"| node_app
node_app -->|"guards routes with"| node_protected_route
node_app -->|"renders"| node_navbar
node_app -->|"routes to"| node_access_pages
node_protected_route -->|"authorizes"| node_student_dashboard
node_protected_route -->|"authorizes"| node_admin_dashboard
node_app -->|"routes to"| node_catalog
node_catalog -->|"opens course"| node_course_detail
node_course_detail -->|"opens lesson"| node_lesson_view
node_catalog -->|"uses"| node_student_ui
node_student_dashboard -->|"reads learning state"| node_store
node_catalog -->|"enrolls through"| node_store
node_course_detail -->|"reads access and progress"| node_store
node_lesson_view -->|"updates completion"| node_store
node_admin_dashboard -->|"reads metrics"| node_store
node_admin_courses -->|"edits via"| node_course_form
node_course_form -->|"mutates catalog"| node_store
node_store -->|"models"| node_domain_types
node_store -->|"initializes from"| node_mock_data
node_store -->|"persists to"| node_local_storage
node_store -.->|"future service calls"| node_backend_service
node_backend_service -.->|"target integration"| node_supabase

click node_main "https://github.com/joshua-id/swiss-hub/blob/master/src/main.tsx"
click node_app "https://github.com/joshua-id/swiss-hub/blob/master/src/App.tsx"
click node_protected_route "https://github.com/joshua-id/swiss-hub/blob/master/src/components/ProtectedRoute.tsx"
click node_navbar "https://github.com/joshua-id/swiss-hub/blob/master/src/components/Navbar.tsx"
click node_access_pages "https://github.com/joshua-id/swiss-hub/blob/master/src/pages/SignInPage.tsx"
click node_student_dashboard "https://github.com/joshua-id/swiss-hub/blob/master/src/pages/StudentDashboard.tsx"
click node_catalog "https://github.com/joshua-id/swiss-hub/blob/master/src/pages/CourseCatalog.tsx"
click node_course_detail "https://github.com/joshua-id/swiss-hub/blob/master/src/pages/CourseDetail.tsx"
click node_lesson_view "https://github.com/joshua-id/swiss-hub/blob/master/src/pages/LessonView.tsx"
click node_student_ui "https://github.com/joshua-id/swiss-hub/blob/master/src/components/CourseCard.tsx"
click node_admin_dashboard "https://github.com/joshua-id/swiss-hub/blob/master/src/pages/AdminDashboard.tsx"
click node_admin_courses "https://github.com/joshua-id/swiss-hub/blob/master/src/pages/AdminCourses.tsx"
click node_course_form "https://github.com/joshua-id/swiss-hub/blob/master/src/pages/CourseForm.tsx"
click node_store "https://github.com/joshua-id/swiss-hub/blob/master/src/store/useStore.ts"
click node_domain_types "https://github.com/joshua-id/swiss-hub/blob/master/src/types/index.ts"
click node_mock_data "https://github.com/joshua-id/swiss-hub/blob/master/src/api/mockData.ts"
click node_backend_service "https://github.com/joshua-id/swiss-hub/blob/master/src/api/backendService.ts"
click node_supabase "https://github.com/joshua-id/swiss-hub/blob/master/src/lib/supabase.ts"
click node_static_host "https://github.com/joshua-id/swiss-hub/blob/master/vercel.json"

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_vite,node_main,node_app,node_protected_route,node_navbar,node_access_pages,node_static_host toneBlue
class node_student_dashboard,node_catalog,node_course_detail,node_lesson_view,node_student_ui toneAmber
class node_admin_dashboard,node_admin_courses,node_course_form toneMint
class node_store,node_domain_types,node_mock_data,node_local_storage,node_backend_service,node_supabase toneRose
```

## Components

### Client Runtime

- **Vite build**: build tool · Builds the static deployment artifact.
- [React entry](https://github.com/joshua-id/swiss-hub/blob/master/src/main.tsx): React bootstrap · `src/main.tsx`
- [App routes](https://github.com/joshua-id/swiss-hub/blob/master/src/App.tsx): route composition · Composes public, student, and admin pages. · `src/App.tsx`
- [Protected routes](https://github.com/joshua-id/swiss-hub/blob/master/src/components/ProtectedRoute.tsx): route authorization · Enforces route-level role access. · `src/components/ProtectedRoute.tsx`
- [Role-aware navigation](https://github.com/joshua-id/swiss-hub/blob/master/src/components/Navbar.tsx): shared UI · Supports demo user and role switching. · `src/components/Navbar.tsx`
- [Access pages](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/SignInPage.tsx): sign-in / sign-up / waitlist · `src/pages/SignInPage.tsx`
- [Static hosting](https://github.com/joshua-id/swiss-hub/blob/master/vercel.json): deployment target · Vercel serves the built SPA. · `vercel.json`

### Student Learning

- [Student dashboard](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/StudentDashboard.tsx): student page · `src/pages/StudentDashboard.tsx`
- [Course catalog](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/CourseCatalog.tsx): student page · Browses, filters, enrolls, and applies prerequisite locks. · `src/pages/CourseCatalog.tsx`
- [Course detail](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/CourseDetail.tsx): student page · Resolves curriculum, access, and progress. · `src/pages/CourseDetail.tsx`
- [Lesson view](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/LessonView.tsx): student page · Presents content and records lesson completion. · `src/pages/LessonView.tsx`
- [Course & progress UI](https://github.com/joshua-id/swiss-hub/blob/master/src/components/CourseCard.tsx): shared UI · `src/components/CourseCard.tsx`

### Admin Management

- [Admin dashboard](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/AdminDashboard.tsx): admin page · Shows catalog and learning metrics. · `src/pages/AdminDashboard.tsx`
- [Course administration](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/AdminCourses.tsx): admin page · `src/pages/AdminCourses.tsx`
- [Course editor](https://github.com/joshua-id/swiss-hub/blob/master/src/pages/CourseForm.tsx): admin form · Creates or edits metadata and prerequisites. · `src/pages/CourseForm.tsx`

### State & Data Boundary

- [Zustand store](https://github.com/joshua-id/swiss-hub/blob/master/src/store/useStore.ts): client state boundary · Owns user context, entities, CRUD, enrollment, and completion actions. · `src/store/useStore.ts`
- [Learning domain types](https://github.com/joshua-id/swiss-hub/blob/master/src/types/index.ts): TypeScript models · Defines users, courses, lessons, enrollments, and progress. · `src/types/index.ts`
- [Demo data](https://github.com/joshua-id/swiss-hub/blob/master/src/api/mockData.ts): local data source · `src/api/mockData.ts`
- **Browser local storage**: client persistence
- [Backend service abstraction](https://github.com/joshua-id/swiss-hub/blob/master/src/api/backendService.ts): intended API boundary · Production replacement for mock and store-only mutations. · `src/api/backendService.ts`
- [Supabase placeholder](https://github.com/joshua-id/swiss-hub/blob/master/src/lib/supabase.ts): external integration stub · Reserved for auth, database CRUD, and file storage. · `src/lib/supabase.ts`

## Connections

- Vite build → React entry: builds
- Vite build → Static hosting: deploys dist
- React entry → App routes: mounts
- App routes → Protected routes: guards routes with
- App routes → Role-aware navigation: renders
- App routes → Access pages: routes to
- Protected routes → Student dashboard: authorizes
- Protected routes → Admin dashboard: authorizes
- App routes → Course catalog: routes to
- Course catalog → Course detail: opens course
- Course detail → Lesson view: opens lesson
- Course catalog → Course & progress UI: uses
- Student dashboard → Zustand store: reads learning state
- Course catalog → Zustand store: enrolls through
- Course detail → Zustand store: reads access and progress
- Lesson view → Zustand store: updates completion
- Admin dashboard → Zustand store: reads metrics
- Course administration → Course editor: edits via
- Course editor → Zustand store: mutates catalog
- Zustand store → Learning domain types: models
- Zustand store → Demo data: initializes from
- Zustand store → Browser local storage: persists to
- Zustand store → Backend service abstraction: future service calls
- Backend service abstraction → Supabase placeholder: target integration
