How samudralaaravind/code_deck works
Project type and purpose
• This is a front-end only, single-page application (SPA) built with React.js.
• Purpose: Provide an in-browser code playground/IDE (“Code Deck”) that lets users write code snippets in multiple languages, submit them to an external Judge0 compilation/execution API (via RapidAPI), view results, and save/load sessions locally.
File structure
• Top-level:
• public/index.html – SPA host
• src/index.js, src/App.js – React entry point and root component
• src/components – reusable UI pieces (Modals, ModalTypes)
• src/screens – page-level components (Error404, Home, Playground)
• src/context – React Context providers for modal state (ModalContext.jsx) and playground data/state (PlaygroundContext.jsx)
• src/assets, src/style – static assets and global styled-components definitions
README insights
• Tech stack: React, React Router, Styled Components, CodeMirror for code editing, Axios for API calls.
• Integrates Judge0 CE API (over RapidAPI) for compiling/running code.
• Supports multi-language, multi-theme, code upload/download, localStorage persistence, fullscreen, input/output consoles.
Main components and relationships
a. Browser / User Agent (host of the SPA)
b. React SPA
• Router layer toggles between Home screen and Playground screen
• Home screen: folder/playground management UI
• Playground screen:
– Navbar (language/theme selectors, run/download buttons)
– CodeEditor (CodeMirror wrapped)
– InputConsole (user-provided stdin)
– OutputConsole (API execution results)
– EditorContainer (layout wrapper)
– Modals (New/Edit Folder, New/Edit Playground, Loading indicator)
• Context providers:
– PlaygroundContext: holds snippet list, current snippet data, persists to localStorage
– ModalContext: manages open/close state of modals
• Styled components: global styles and component styles
c. External / Cloud Services
• Judge0 CE API (via RapidAPI): accepts code submissions, returns compile/run responses
d. Browser localStorage
• Persists playgrounds and folders between sessions
Architectural patterns and design principles
• SPA with client-side routing (React Router)
• State management via React Context API
• Component-driven UI (reusable Modal components, screen modules)
• Clear separation: Presentation (components/screens) vs. State (contexts) vs. Data persistence (localStorage) vs. External API calls (Axios)
• Asynchronous flow: user triggers “Run” → Axios request → Judge0 CE → promise resolves → update OutputConsole
• Browser (outermost)
• React SPA
• Router
• Home Screen
• Playground Screen
– Navbar
– CodeEditor (CodeMirror)
– InputConsole
– OutputConsole
– EditorContainer
– Modal Components (list)
• Context Providers (ModalContext, PlaygroundContext)
• Styled Components (global styles)
• LocalStorage (browser API)
• Judge0 CE API (external service)
• Browser → React SPA (initial load)
• Router → Home/Playground screens (client-side navigation)
• PlaygroundContext ↔ Components (provides/primes state)
• Components → localStorage (save/load playgrounds)
• Components (on Run) → Axios → Judge0 API → Components (OutputConsole updates)
c. Architectural patterns
• SPA / client-side routing
• Context API for state distribution
• CodeMirror integration for code editing
• HTTP API integration via Axios
• Persisted state in localStorage
d. Technologies & libraries callouts
• React.js, React Router, Styled Components, CodeMirror, Axios, RapidAPI / Judge0 CE
Detail
• Contextual boundary (Router vs. Context vs. network layer)
• How user actions traverse through components → context → API → UI updates
• No critical piece (e.g., ModalContext, PlaygroundContext, CodeMirror, Axios layer) is omitted