How tannuparashar/code-compiler works
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/)