# tannuparashar/code-compiler architecture

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

- Interactive diagram: https://gitdiagram.com/tannuparashar/code-compiler
- Repository: https://github.com/tannuparashar/code-compiler

## Overview

##### Project type and purpose
- From the file tree and minimal README, we see two distinct parts at the repo root:
a) **codex/** – a static HTML/CSS/JS–based site (login, register, dashboard, resources).
b) **online-code-compiler/** – a Next.js (App Router) full-stack web application for writing, compiling, and running code online.
- The overall project appears to provide both a documentation/portal site (“codex”) and a live code-compiler web app (“online-code-compiler”).

##### File structure
- Top-level:
- codex/ – purely client-side.
- online-code-compiler/ – full-stack Next.js project with:
– **app/** (entry point, layout.tsx, page.tsx)
– **actions/compile.ts** (server-action to compile code)
– **components/** (EditorComponent.tsx, SelectLanguages.tsx, UI primitives)
– **config/** (config.ts), **lib/** (utils.ts)
– **public/** (static assets), **styles**, and build configs (next.config.mjs, tsconfig.json, tailwind.config.ts, postcss.config.mjs)

##### README for additional insights
- README is sparse (“# code-compiler”) but the file names and locations reveal the technology stack: Next.js + React + TypeScript + Tailwind CSS + server-actions for compilation logic. The “codex” folder is a standalone static resource portal.

a. Main components:
- **User Browser**
- **Codex Static Site** (HTML/CSS/JS hosting)
- **Online Code Compiler Frontend** (Next.js React app)
- **Compile Service (Server-Action)** in Next.js → child-process or containerized compiler runtime
- **Config & Utility Layer** (config/config.ts, lib/utils.ts)
- **Third-Party Services** (if any: e.g., npm packages to support compilation, logging, CDN for static assets)

b. Relationships & interactions:
1. **Browser** requests either codex HTML pages or Next.js pages.
2. In the **Online-Compiler Frontend**: the user writes code in **EditorComponent**, picks language via **SelectLanguages**, hits “Compile.”
3. Frontend dispatches a call to the **compile.ts** server-action (API endpoint).
4. **compile.ts** invokes the underlying compiler or interpreter (Docker/child_process), returns stdout/stderr.
5. UI renders the result, using **toast** notifications or in-editor output.
6. **Config & Utils** modules are imported by both frontend and server-action to maintain consistent settings (e.g., language definitions, timeouts).

c. Architectural patterns & design principles:
- **Separation of concerns**: static vs. dynamic sites, UI vs. server logic.
- **Component-based UI** (React + Next.js app router).
- **Server-actions** for secure code execution on the server.
- **Utility layer** for shared constants and helper functions.

d. Key technologies and frameworks:
- **Next.js 13+** (App Router, server-actions)
- **React + TypeScript**
- **Tailwind CSS** (style, design system)
- **UI primitives** under components/ui (button, dropdown, resizable, toast)
- **Static asset hosting** (codex and Next.js public/)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Browser
    Browser["User Browser"]:::client

    %% Codex Static Site
    subgraph "Codex Static Site" 
        direction TB
        CodexLogin["Login Page<br/>(HTML/JS)"]:::static
        CodexRegister["Register Page<br/>(HTML/JS)"]:::static
        CodexDashboard["Dashboard Page<br/>(HTML)"]:::static
        CodexResources["Resources Page<br/>(HTML)"]:::static
        CodexStyles["Stylesheet<br/>(CSS)"]:::static
    end

    %% Online Code Compiler App
    subgraph "Online Code Compiler (Next.js App)" 
        direction TB

        %% App Router Entry
        subgraph "App Router Entry" 
            direction TB
            GlobalsCSS["globals.css"]:::styles
            Layout["layout.tsx"]:::frontend
            HomePage["page.tsx"]:::frontend
        end

        %% UI Components
        subgraph "UI Components" 
            direction TB
            Editor["EditorComponent.tsx"]:::frontend
            LangSelect["SelectLanguages.tsx"]:::frontend
            ModeToggle["mode-toggle-btn.tsx"]:::frontend
            ThemeProvider["theme-provider.tsx"]:::frontend

            subgraph "UI Primitives" 
                direction TB
                Button["button.tsx"]:::frontend
                Dropdown["dropdown-menu.tsx"]:::frontend
                Resizable["resizable.tsx"]:::frontend
                ToastNotif["toast.tsx"]:::frontend
                Toaster["toaster.tsx"]:::frontend
                ToastHook["use-toast.ts"]:::frontend
            end
        end

        %% Server Actions & Services
        subgraph "Server Layer" 
            direction TB
            CompileService["compile.ts<br/>(Server-Action)"]:::server
            Config["config.ts"]:::config
            Utils["utils.ts"]:::config
        end

        %% External Compile Engine
        CompileEngine["Docker/child_process<br/>(Compile Engine)"]:::external
    end

    %% Interactions
    Browser -->|"Request codex pages"| CodexLogin
    Browser --> CodexRegister
    Browser --> CodexDashboard
    Browser --> CodexResources

    Browser -->|"Request Next.js pages"| HomePage
    HomePage -->|"uses"| Editor
    HomePage -->|"uses"| LangSelect
    HomePage -->|"uses"| ModeToggle
    HomePage -->|"uses"| ThemeProvider
    Editor -->|"uses primitives"| Button
    Editor --> Dropdown
    Editor --> Resizable
    ThemeProvider -->|"uses toast"| ToastNotif
    ThemeProvider --> Toaster
    ThemeProvider --> ToastHook

    HomePage -->|"imports styles"| GlobalsCSS
    Layout --> GlobalsCSS

    HomePage -->|"calls"| CompileService
    CompileService -->|"uses config"| Config
    CompileService -->|"uses utils"| Utils
    HomePage -->|"uses config"| Config
    HomePage -->|"uses utils"| Utils
    CompileService -->|"executes code on"| CompileEngine

    %% Click Events for component mapping
    click CodexLogin "https://github.com/tannuparashar/code-compiler/blob/main/codex/login.html"
    click CodexLogin "https://github.com/tannuparashar/code-compiler/blob/main/codex/login.js"
    click CodexRegister "https://github.com/tannuparashar/code-compiler/blob/main/codex/register.html"
    click CodexRegister "https://github.com/tannuparashar/code-compiler/blob/main/codex/register.js"
    click CodexDashboard "https://github.com/tannuparashar/code-compiler/blob/main/codex/dashboard.html"
    click CodexResources "https://github.com/tannuparashar/code-compiler/blob/main/codex/resource.html"
    click CodexStyles "https://github.com/tannuparashar/code-compiler/blob/main/codex/style.css"

    click GlobalsCSS "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/app/globals.css"
    click Layout "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/app/layout.tsx"
    click HomePage "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/app/page.tsx"

    click CompileService "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/actions/compile.ts"

    click Editor "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/EditorComponent.tsx"
    click LangSelect "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/SelectLanguages.tsx"
    click ModeToggle "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/mode-toggle-btn.tsx"
    click ThemeProvider "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/theme-provider.tsx"

    click Button "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/ui/button.tsx"
    click Dropdown "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/ui/dropdown-menu.tsx"
    click Resizable "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/ui/resizable.tsx"
    click ToastNotif "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/ui/toast.tsx"
    click Toaster "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/ui/toaster.tsx"
    click ToastHook "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/components/ui/use-toast.ts"

    click Config "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/config/config.ts"
    click Utils "https://github.com/tannuparashar/code-compiler/blob/main/online-code-compiler/lib/utils.ts"

    click CompileEngine "https://github.com/tannuparashar/code-compiler/tree/main/online-code-compiler/public/"

    %% Styles
    classDef client fill:#D6EAF8,stroke:#3498DB,color:#154360;
    classDef static fill:#EBF5FB,stroke:#5DADE2,color:#1B4F72;
    classDef frontend fill:#E8DAEF,stroke:#8E44AD,color:#4A235A;
    classDef server fill:#D5F5E3,stroke:#27AE60,color:#1E8449;
    classDef config fill:#FCF3CF,stroke:#F1C40F,color:#7D6608;
    classDef external fill:#FADBD8,stroke:#E74C3C,color:#641E16;
    classDef styles fill:#FEF9E7,stroke:#F5B041,color:#7E5109
```
