This document provides a high-level overview of the Coding for MBA application architecture.
- Framework: React 19 + Vite 7
- Language: TypeScript 5.9
- State Management: Zustand (for progress and global state)
- Routing: React Router (HashRouter)
- Styling: Vanilla CSS + CSS Variables (Design System)
- Testing: Vitest (Unit) + Playwright (E2E)
- Deployment: GitHub Pages
The application loads curriculum content (Markdown files) using Vite's import.meta.glob feature. This allows us to:
- Load all lesson and phase markdown files at build time.
- Parse Frontmatter metadata (day, title, difficulty) using a custom parser.
- Expose immutable accessors (
getAllLessons,getLesson,getAllPhases) to the rest of the app. - Cache the parsed content for performance.
We use react-markdown to render lesson content. The renderer is customized to:
- Sanitize HTML output using
rehype-sanitize. - Support GitHub Flavored Markdown (GFM).
- Render custom interactive components for specific markdown patterns:
- Code Blocks: Enhanced with
CodePlaygroundorSyntaxHighlighter. - Exercises: Parsed from
### Exerciseheaders and rendered asExerciseWidget. - Mastery Checks: Parsed from
<details>blocks and rendered asMasteryCheckwidgets. - Glossary: Automatically detects key terms and wraps them in tooltips.
- Code Blocks: Enhanced with
The application includes a browser-based Python environment using Pyodide.
- Execution: Python code runs entirely in the browser (WebAssembly).
- Security:
- We use
src/utils/codeSecurity.tsto validate user code before execution. - Dangerous imports (
os,sys,subprocess) and functions (exec,eval) are restricted. - Direct access to the JavaScript DOM (
import js) is blocked.
- We use
- Performance: Pyodide is loaded lazily and cached.
We use Zustand to manage user progress and application state.
- Persistence: Progress (completed lessons, XP) is persisted to
localStorage. - Synchronization: The store syncs state across tabs using storage events.
- HashRouter: We use hash-based routing (
/#/lesson/1) to ensure compatibility with GitHub Pages. - Sidebar: The
Sidebarcomponent dynamically generates navigation based on the loaded phases and lessons. - Day Tokens: Lessons are identified by "Day Tokens" (e.g.,
1,36B) allowing for flexible curriculum expansion without renumbering everything.
See CONTRIBUTING.md for a breakdown of the project structure.