How sai-pratham05/code-mania works
Project Type and Purpose
• Code-Mania is a single-page application (SPA) built in React.
• It provides a playground for writing, theming, and compiling code in 40+ languages via the external Judge0 API (hosted through RapidAPI).
File Structure
• public/: Static assets and HTML shell (index.html, manifest.json, demo image).
• src/:
– components/: UI building blocks (CodeEditorWindow, LanguagesDropdown, ThemeDropdown, CustomInput, OutputWindow, Landing, Footer).
– constants/: Configs for styles, languages, and statuses.
– hooks/: Custom React hooks (useKeyPress).
– lib/: Theme-definition logic (defineTheme.js).
– utils/: General helpers (API calls, debounce, etc.).
– App.js & index.js: App orchestration and mount point.
• tailwind.config.js & postcss.config.js: Styling pipeline.
• package.json/lock & .env (for RapidAPI keys): Dependency and configuration.
Key Insights from README
• UI rendered entirely in the browser using React + Monaco Editor.
• Communication with remote Judge0 service over HTTP (compile/execute).
• Theming handled via Tailwind CSS + customStyles.
• Notifications via React-Toastify.
Main Architectural Components
a. Browser / User
b. React SPA
– UI Layer: Components (Editor, Dropdowns, Buttons, Windows)
– State & Theme Layer: App state, contexts, custom hooks
– Utils & API Layer: HTTP client calling Judge0 endpoints, environment config
c. External Service
– Judge0 compilation engine (via RapidAPI gateway)
d. Optional Dev/Build Tools
– Node.js dev server (npm start)
– Build pipeline (webpack via Create React App)
Interactions & Data Flow
1. User enters code / selects language & theme in CodeEditorWindow.
2. App state updates (useState, custom hooks).
3. On “Compile” click, UI triggers API call in utils/general.js → Judge0 (RapidAPI).
4. Judge0 processes code, returns JSON (stdout, stderr, status).
5. App receives response → OutputWindow & OutputDetails render result/status.
6. Notifications (success/error) via React-Toastify.
Architectural Patterns & Principles
• Component-Based Design: Each UI block is a self-contained React component.
• Separation of Concerns:
– components/ for presentation
– utils/ & hooks/ for business logic and behaviors
– constants/ & lib/ for configuration
• Single Source of Truth: App.js orchestrates top-level state, environment variables for credentials.
Detailed Elements to Capture
• Editor theming (Tailwind + defineTheme)
• Language options loaded from constants/languageOptions.js
• Custom hooks (useKeyPress) enhancing UX
• Environment variables for API credentials