How nazmul-islam00/courshera works
1. Overall shape
- This repository is a full-stack learning platform clone with a React single-page frontend and a Node/Express backend API.
- The backend owns authentication, course data, user profile data, and payment-related endpoints; the frontend renders the learning experience and calls the API.
2. Frontend boundary
- The frontend is built with Vite + React and packaged separately from the backend.
- In production it is served as static assets behind Nginx in the frontend Docker image.
- The app is organized by page-level routes such as Home, Category, Course Outline/Content, My Learning, Profile, Search, Quiz pages, and Payment Result.
3. Frontend state and API access
- Global app state is split into focused contexts:
- AuthContext/AuthProvider for signed-in user state and session handling.
- CheckoutContext/CheckoutProvider for checkout/payment flow state.
- frontend/src/api/api.js is the shared API client boundary between UI components and the backend.
4. Backend API structure
- The backend is an Express-style service with feature-based routes:
- auth.js and regular_auth.js for login/signup/auth flows.
- me.js for current-user/profile access.
- courses.js for course/catalog content.
- payment.js for payment and saved-card flows.
- server.js is the API entry point and wires the middleware, routes, and database layer together.
5. Authentication and authorization
- Authentication is split into multiple concerns:
- passport.js indicates Passport-based auth strategy support.
- utils/jwtGenerator.js indicates token-based sessions using JWTs.
- middleware/authorization.js protects authenticated endpoints.
- middleware/validInfo.js validates incoming auth payloads.
- smsParser.js suggests an SMS/OTP-related auth path or message parsing support, which is part of the auth boundary.
- The frontend’s ProtectedRoute and auth modal components consume this auth layer.
6. Course and content domain
- Course browsing is a major domain: home page course cards, course outline pages, course content pages, category pages, and search all revolve around course discovery and enrollment.
- The frontend includes fallback utilities like courseOutlineFallback.js and fallbackCourseImages.js, implying the UI can render even when backend content is partial or missing.
- CoursesFromBackend.jsx is the bridge component that pulls live course data into the UI.
7. Checkout and payment flow
- The checkout experience is represented both in frontend state and backend endpoints.
- Frontend checkout UI includes Checkout.jsx, saved cards, and payment result screens.
- routes/payment.js is the backend boundary for payment-related operations, likely including payment creation, confirmation, and user card/account state.
8. Quiz subsystem
- Quizzes are a largely self-contained frontend feature with dedicated layouts, headers, footers, sidebar, catalog, take page, past quizzes, and certificate page.
- frontend/src/data/quizData.js indicates at least part of the quiz content is local/static rather than fetched from the backend.
- This subsystem is separate from the course/payment flow and can be diagrammed as its own client-side feature area.
9. Data layer
- The backend uses Prisma (prisma/schema.prisma, prisma.config.ts) as the ORM boundary to the database.
- db.js likely centralizes the database connection/client instance used by the route handlers.
- sqlfiles/ddl.sql provides the raw schema definition or provisioning script for database setup outside Prisma.
10. Containerization and runtime
- The project is designed to run as two containers: one for the backend and one for the frontend.
- The backend listens on port 5000 and the frontend container serves on 80, exposed as 3000 on the host in the README examples.
- docker-compose.yml exists, but the README notes that “docker compose up is no longer supported,” so current deployment appears to be container-per-service.
11. Operational and repo tooling
- GitHub Actions includes a CI workflow and a health-check workflow, so the repo has automated validation and runtime probing.
- api_docs.yaml suggests the backend API is documented in an OpenAPI-style spec, which is useful for frontend/backend contract alignment.
12. How the main data flow works
- User enters the frontend SPA → frontend components call the API client → backend route handlers process auth/course/payment requests → middleware enforces session/authorization → Prisma/db layer reads or writes persistent data → responses return to the SPA, which updates contexts and page state.
Main entry points: App.jsx App shell · server.js Server entry · db.js Database layer · auth.js Auth routes
Components 25
Frontend SPA
React/Vite client, page routes, and UI state.
- App shell · Root client application and route assembly.
frontend/src/App.jsx - API client · Shared frontend boundary for backend requests.
frontend/src/api/api.js - Auth state · Signed-in user and session state.
frontend/src/context/auth/AuthContext.jsx - Checkout state · Payment and checkout flow state.
frontend/src/context/checkout/CheckoutContext.jsx - Protected route · Client-side access control for authenticated pages.
frontend/src/components/auth/ProtectedRoute.jsx - Course home · Home, category, search, outline, content, and learning pages centered on course discovery.
frontend/src/pages/HomePage.jsx - Backend courses · Pulls live course data into the UI.
frontend/src/components/CoursesFromBackend.jsx - Checkout UI · Frontend payment and saved-card experience.
frontend/src/components/checkout/Checkout.jsx - Payment result · Payment outcome and confirmation screen.
frontend/src/components/payment-result/PaymentResult.jsx - Profile pages · My learning, profile, and account-facing pages.
frontend/src/pages/ProfilePage.jsx - Quiz system · Self-contained quiz catalog, take flow, history, and certificate UI.
frontend/src/pages/QuizHomePage.jsx - UI fallbacks · Local fallback data for course outlines and images.
frontend/src/utils/courseOutlineFallback.js
Backend API
Express service, auth, courses, payments, and persistence.
- Server entry · Backend application bootstrap and middleware wiring.
backend/server.js - Auth routes · Login, signup, regular auth, and related session flows.
backend/routes/auth.js - Me routes · Current-user and profile endpoints.
backend/routes/me.js - Course routes · Catalog and course content endpoints.
backend/routes/courses.js - Payment routes · Payment, saved-card, and checkout endpoints.
backend/routes/payment.js - Auth middleware · Authorization and request validation gates.
backend/middleware/authorization.js - Session layer · Passport and JWT-based authentication support.
backend/passport.js - Database layer · Shared database client and ORM boundary.
backend/db.js - Prisma schema · Database model definitions for the backend.
backend/prisma/schema.prisma - SQL bootstrap · Raw SQL provisioning and schema setup script.
sqlfiles/ddl.sql
Ops & Docs
Containerization, CI, and API documentation.
- API docs · OpenAPI-style backend API description.
api_docs.yaml - CI checks · Automated validation and health-check workflows.
.github/workflows/ci.yml - Container setup · Docker images and compose-based runtime packaging.
docker-compose.yml
Connections 30
- App shell → API client: calls · UI data access goes through the shared API client.
- App shell → Auth state: uses · App-wide signed-in state and session handling.
- App shell → Checkout state: uses · Checkout state is shared across payment screens.
- App shell → Protected route: guards · Authenticated pages are wrapped by client-side protection.
- App shell → Course home: routes · Page-level course browsing and account experiences.
- Course home → Backend courses: loads · Live catalog data is bridged into course UI.
- Course home → UI fallbacks: falls back · Client uses local content when backend data is partial.
- App shell → Checkout UI: renders · Checkout screens drive the payment flow.
- Checkout UI → Payment result: finishes · Checkout transitions to payment outcome display.
- App shell → Profile pages: routes · My learning and profile pages are part of the SPA.
- App shell → Quiz system: routes · Dedicated quiz area is handled within the client.
- Server entry → Auth routes: mounts · Authentication endpoints are registered on the API.
- Server entry → Me routes: mounts · Current-user/profile endpoints are registered on the API.
- Server entry → Course routes: mounts · Catalog and course content endpoints are registered on the API.
- Server entry → Payment routes: mounts · Payment and saved-card endpoints are registered on the API.
- Auth routes → Auth middleware: protects · Authenticated actions are validated and authorized.
- Me routes → Auth middleware: protects · Profile access depends on authorization checks.
- Payment routes → Auth middleware: protects · Payment operations are constrained by auth checks.
- Auth routes → Session layer: issues · Auth flows rely on Passport and JWT support.
- Server entry → Database layer: uses · Route handlers share the database client.
- Database layer → Prisma schema: maps to · Prisma schema defines the persistent model.
- Database layer → SQL bootstrap: bootstraps · SQL scripts support database provisioning.
- Course routes → Database layer: reads/writes · Course data is served from persistence.
- Me routes → Database layer: reads/writes · User profile data is persisted here.
- Payment routes → Database layer: reads/writes · Payment and saved-card state is persisted here.
- Auth routes → Database layer: reads/writes · Auth flows create and verify user records and sessions.
- API docs → Server entry: describes · Contract documentation matches the backend surface.
- CI checks → Server entry: checks · CI and health workflows validate the service.
- Container setup → Server entry: packages · Backend is containerized as a service.
- Container setup → App shell: packages · Frontend is containerized and served as static assets.