How lethinkj/marvel-slice works
Purpose and Runtime
Marvel Slice is a React/Vite education and LMS content site with a public catalog, dynamic CMS pages, submission/chat features, and a separate admin dashboard. It runs as a Vite SPA, deployed to Vercel with SPA rewrites; Supabase supplies PostgreSQL, REST access, and Storage. Entry/bootstrap paths: src/main.jsx, src/App.jsx, vercel.json.
Application Routing Boundary
src/App.jsx separates public routes from /admin/*. Public pages cover home, courses and course detail, services/training, blog, career/contact, legal, upcoming classes, and dynamic navigation pages. The admin router, auth provider, protected layout, and editor routes are centered in src/admin/Admin.jsx, src/admin/context/AuthContext.jsx, and src/admin/layout/AdminLayout.jsx.
Public Content Delivery
Public page components compose DB-backed content into reusable site chrome and sections. Home renders configurable sections; course detail renders course metadata and related content; NavPage resolves arbitrary navigation-backed pages. Shared navigation/footer fetch settings and navigation tree data. Key paths: src/pages/Home.jsx, src/pages/CourseDetail.jsx, src/pages/NavPage.jsx, src/components/layout/Header.jsx, src/components/ui/SectionRenderer.jsx.
Data Access and Content Model
The browser connects directly to Supabase through a client configured from Vite environment variables. React Query-oriented hooks encapsulate fetch/mutation behavior for courses, blog, services, training, nav, and site data. The relational schema supports CMS settings/navigation, course relations/tags, blog relations, submissions, chat, services, training, jobs, and legal content. Core paths: src/lib/supabaseClient.js, src/hooks/useSupabase.js, src/hooks/useBlog.js, schema.sql, supabase/migrations.
Administrative CMS
The admin application manages both structured entities and page-section JSON/content: courses, blog, nav, home, services, training, careers, media, site settings, and inbound submissions. It relies on a client-side email/password hash check against admin profiles and persists its session in localStorage; this is an explicit security boundary rather than Supabase Auth. Representative paths: src/admin/pages/CourseEditor.jsx, src/admin/pages/HomePageEditor.jsx, src/admin/pages/BlogPostEditor.jsx, src/admin/pages/MediaLibrary.jsx, src/admin/components/ImageUploader.jsx.
User Interaction and Server Endpoints
Most writes go from the SPA directly to Supabase. Form/contact and career submission flows additionally use Vercel serverless API handlers, separating email/reply or submission-side behavior from the static SPA. Embedded chat and job-application UI are client features backed by corresponding Supabase tables/migrations. Paths: api/submit-contact.js, api/submit-career.js, api/admin-reply.js, src/components/chat/ChatWidget.jsx, src/components/apply/JobApplyModal.jsx.
Data Provisioning and Migration Assets
Database setup is rooted in the main SQL schema plus incremental Supabase migrations. JSON exports and scripts provide development/restore/seed pipelines, especially for course and page content; they are operational inputs rather than production runtime sources. Paths: schema.sql, services-schema.sql, training-schema.sql, scripts/seed-all.js, data/courses/courses_raw.json.
Main entry points: Home.jsx Public pages · supabaseClient.js Supabase browser client · App.jsx Application router · Admin.jsx Admin application
Components 22
Public SPA
- Vite SPA bootstrap
src/main.jsx - Application router · Separates public routes from /admin/*.
src/App.jsx - Public pages · Catalog, course, service, blog, legal, and contact experiences.
src/pages/Home.jsx - Course detail
src/pages/CourseDetail.jsx - Dynamic navigation page
src/pages/NavPage.jsx - Site chrome & sections · Fetches navigation/settings and renders configurable sections.
src/components/layout/Header.jsx - Section renderer
src/components/ui/SectionRenderer.jsx - Chat & job application
src/components/chat/ChatWidget.jsx
Admin CMS
- Admin application · Protected editor routes under /admin/*.
src/admin/Admin.jsx - Admin session check · Profiles-based email/password hash check persisted in localStorage.
src/admin/context/AuthContext.jsx - Protected admin layout
src/admin/layout/AdminLayout.jsx - Structured content editors · Courses, home sections, blog, navigation, services, training, and settings.
src/admin/pages/CourseEditor.jsx - Media management
src/admin/pages/MediaLibrary.jsx - Image uploader
src/admin/components/ImageUploader.jsx
Data & Hosting
- Supabase browser client · Configured from Vite environment variables.
src/lib/supabaseClient.js - Query & mutation hooks · Encapsulate CMS reads and direct browser writes.
src/hooks/useSupabase.js - Supabase platform · Hosts CMS, content relations, submissions, chat, jobs, and media.
- Submission API handlers · Handles contact, career, and admin-reply side behavior.
api/submit-contact.js - Vercel deployment · Serves the SPA with rewrite support.
vercel.json
Provisioning
- Base database schema
schema.sql - Incremental migrations
supabase/migrations - Seed & restore pipeline · Development content import from JSON exports.
scripts/seed-all.js
Connections 26
- Vite SPA bootstrap → Application router: boots
- Application router → Public pages: public routes
- Application router → Admin application: /admin/*
- Public pages → Course detail: course route
- Public pages → Dynamic navigation page: dynamic route
- Public pages → Site chrome & sections: composes
- Public pages → Section renderer: renders sections
- Public pages → Chat & job application: embeds
- Site chrome & sections → Query & mutation hooks: settings & navigation
- Public pages → Query & mutation hooks: content reads
- Chat & job application → Supabase browser client: chat/job writes
- Query & mutation hooks → Supabase browser client: uses
- Supabase browser client → Supabase platform: REST & Storage
- Admin application → Admin session check: checks session
- Admin application → Protected admin layout: protects
- Protected admin layout → Structured content editors: hosts
- Protected admin layout → Media management: hosts
- Media management → Image uploader: uses
- Structured content editors → Supabase browser client: CMS reads/writes
- Image uploader → Supabase platform: uploads media
- Public pages → Submission API handlers: contact/career submits
- Submission API handlers → Supabase platform: submission operations
- Vercel deployment → Vite SPA bootstrap: serves
- Base database schema → Supabase platform: provisions base model
- Incremental migrations → Supabase platform: evolves schema
- Seed & restore pipeline → Supabase platform: development imports