# samudralaaravind/code_deck architecture

> Architecture diagram of the GitHub repository samudralaaravind/code_deck, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samudralaaravind/code_deck
- Repository: https://github.com/samudralaaravind/code_deck

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entities
    Browser["Browser"]:::external
    HTML["public/index.html"]:::state
    IndexJS["src/index.js"]:::state
    AppJS["src/App.js"]:::state

    %% React SPA Components
    subgraph "React SPA"
        Router["Router"]:::state

        subgraph "Screens (UI Components)"
            HomeScreen["Home Screen"]:::ui
            PlaygroundScreen["Playground Screen"]:::ui
        end

        subgraph "Home Screen Details"
            LeftPanel["Left Panel"]:::ui
            RightPanel["Right Panel"]:::ui
        end

        subgraph "Playground Screen Details"
            Navbar["Navbar"]:::ui
            EditorContainer["Editor Container"]:::ui
            CodeEditor["Code Editor"]:::ui
            InputConsole["Input Console"]:::ui
            OutputConsole["Output Console"]:::ui
        end

        subgraph "Modals"
            ModalShell["Modal Shell"]:::ui
            ModalTypes["ModalTypes Registry"]:::ui
            NewFolder["New Folder Modal"]:::ui
            EditFolder["Edit Folder Modal"]:::ui
            NewPlayground["New Playground Modal"]:::ui
            NewPlaygroundAndFolder["New Playground & Folder Modal"]:::ui
            EditPlayTitle["Edit Playground Title Modal"]:::ui
            LoadingModal["Loading Indicator Modal"]:::ui
        end

        subgraph "Context Providers"
            PlaygroundContext["PlaygroundContext"]:::state
            ModalContext["ModalContext"]:::state
        end

        GlobalStyles["Global Styles (src/style/global.js, src/index.css)"]:::state
        Assets["Static Assets"]:::state
        PackageJSON["package.json / package-lock.json"]:::state
    end

    %% Persistence and External API
    LocalStorage[(LocalStorage)]:::state
    Judge0API[(Judge0 CE API)]:::external

    %% Connections
    Browser --> HTML --> IndexJS --> AppJS --> Router
    Router --> HomeScreen
    Router --> PlaygroundScreen

    HomeScreen --> LeftPanel
    HomeScreen --> RightPanel

    PlaygroundScreen --> Navbar
    PlaygroundScreen --> EditorContainer
    EditorContainer --> CodeEditor
    EditorContainer --> InputConsole
    EditorContainer --> OutputConsole

    PlaygroundScreen --> Modals
    Modals --> ModalShell
    ModalShell --> ModalTypes
    ModalTypes --> NewFolder
    ModalTypes --> EditFolder
    ModalTypes --> NewPlayground
    ModalTypes --> NewPlaygroundAndFolder
    ModalTypes --> EditPlayTitle
    ModalTypes --> LoadingModal

    AppJS --> PlaygroundContext
    AppJS --> ModalContext
    PlaygroundContext --> PlaygroundScreen
    PlaygroundContext --> HomeScreen
    ModalContext --> Modals

    PlaygroundContext --> LocalStorage
    HomeScreen --> LocalStorage

    Navbar -->|Run Command| Judge0API
    Judge0API -->|Response| OutputConsole

    AppJS --> GlobalStyles
    AppJS --> Assets
    AppJS --> PackageJSON

    %% Click Events
    click HTML "https://github.com/samudralaaravind/code_deck/blob/main/public/index.html"
    click IndexJS "https://github.com/samudralaaravind/code_deck/blob/main/src/index.js"
    click AppJS "https://github.com/samudralaaravind/code_deck/blob/main/src/App.js"
    click HomeScreen "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Home/index.jsx"
    click LeftPanel "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Home/LeftComponent.jsx"
    click RightPanel "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Home/RightComponent.jsx"
    click PlaygroundScreen "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Playground/index.jsx"
    click Navbar "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Playground/Navbar.jsx"
    click CodeEditor "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Playground/CodeEditor.jsx"
    click InputConsole "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Playground/InputConsole.jsx"
    click OutputConsole "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Playground/OutputConsole.jsx"
    click EditorContainer "https://github.com/samudralaaravind/code_deck/blob/main/src/screens/Playground/EditorContainer.jsx"
    click ModalShell "https://github.com/samudralaaravind/code_deck/blob/main/src/components/Modal.jsx"
    click ModalTypes "https://github.com/samudralaaravind/code_deck/blob/main/src/components/ModalTypes/index.js"
    click NewFolder "https://github.com/samudralaaravind/code_deck/blob/main/src/components/ModalTypes/NewFolder.jsx"
    click EditFolder "https://github.com/samudralaaravind/code_deck/blob/main/src/components/ModalTypes/EditFolder.jsx"
    click NewPlayground "https://github.com/samudralaaravind/code_deck/blob/main/src/components/ModalTypes/NewPlayground.jsx"
    click NewPlaygroundAndFolder "https://github.com/samudralaaravind/code_deck/blob/main/src/components/ModalTypes/NewPlaygroundAndFolder.jsx"
    click EditPlayTitle "https://github.com/samudralaaravind/code_deck/blob/main/src/components/ModalTypes/EditPlaygroundTitle.jsx"
    click LoadingModal "https://github.com/samudralaaravind/code_deck/blob/main/src/components/ModalTypes/Loading.jsx"
    click PlaygroundContext "https://github.com/samudralaaravind/code_deck/blob/main/src/context/PlaygroundContext.jsx"
    click ModalContext "https://github.com/samudralaaravind/code_deck/blob/main/src/context/ModalContext.jsx"
    click GlobalStyles "https://github.com/samudralaaravind/code_deck/blob/main/src/style/global.js"
    click Assets "https://github.com/samudralaaravind/code_deck/tree/main/src/assets"
    click PackageJSON "https://github.com/samudralaaravind/code_deck/blob/main/package.json"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,color:#000;
    classDef state fill:#90EE90,stroke:#000,color:#000;
    classDef external fill:#FFA500,stroke:#000,color:#000;
```
