How joshua-id/swiss-hub works
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: useStore.ts Zustand store · App.tsx App routes · CourseCatalog.tsx Course catalog · ProtectedRoute.tsx Protected routes
Components 21
Client Runtime
- Vite build · Builds the static deployment artifact.
- React entry
src/main.tsx - App routes · Composes public, student, and admin pages.
src/App.tsx - Protected routes · Enforces route-level role access.
src/components/ProtectedRoute.tsx - Role-aware navigation · Supports demo user and role switching.
src/components/Navbar.tsx - Access pages
src/pages/SignInPage.tsx - Static hosting · Vercel serves the built SPA.
vercel.json
Student Learning
- Student dashboard
src/pages/StudentDashboard.tsx - Course catalog · Browses, filters, enrolls, and applies prerequisite locks.
src/pages/CourseCatalog.tsx - Course detail · Resolves curriculum, access, and progress.
src/pages/CourseDetail.tsx - Lesson view · Presents content and records lesson completion.
src/pages/LessonView.tsx - Course & progress UI
src/components/CourseCard.tsx
Admin Management
- Admin dashboard · Shows catalog and learning metrics.
src/pages/AdminDashboard.tsx - Course administration
src/pages/AdminCourses.tsx - Course editor · Creates or edits metadata and prerequisites.
src/pages/CourseForm.tsx
State & Data Boundary
- Zustand store · Owns user context, entities, CRUD, enrollment, and completion actions.
src/store/useStore.ts - Learning domain types · Defines users, courses, lessons, enrollments, and progress.
src/types/index.ts - Demo data
src/api/mockData.ts - Browser local storage
- Backend service abstraction · Production replacement for mock and store-only mutations.
src/api/backendService.ts - Supabase placeholder · Reserved for auth, database CRUD, and file storage.
src/lib/supabase.ts
Connections 24
- 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