How abhiiinav6/codecook works
Project Type and Purpose
• This is a full-stack, web-based “Codecook” platform for coding problems, submissions, and live code execution.
• The client is a React + TypeScript single-page-app (SPA) built with Vite and Tailwind CSS.
• The server is a Node.js/Express API using Prisma ORM to talk to a SQL database and integrates with Judge0 for code compilation/execution.
Main Components
a. Frontend (Client)
• App shell: React, TypeScript, Vite, Tailwind.
• UI components: Navbar, Problem tables/cards, CodePlayground, Submission views, Auth flows.
• Context: AuthContext for JWT and user session.
• Routes: Home, Login, Signup, Problem detail, Submission detail, Top submissions.
b. Backend (Server)
• HTTP API: Express app (index.ts) with route modules (auth, problem, submissions).
• Controllers: Business logic for each resource.
• Middlewares: JWT auth guard, request logger.
• Prisma ORM: schema.prisma + migrations → SQL database.
• Utils: Compiler integration with Judge0 REST API.
c. Database
• PostgreSQL (or compatible) with tables for users, problems, submissions, testcases, etc.
• Managed via Prisma migration files under server/prisma/migrations.
d. External Service
• Judge0 code-execution engine (REST endpoint) for sandboxed code compiling and running.
Relationships and Data Flows
• Browser → HTTP(S) requests → Frontend React Router → API calls to Backend endpoints (e.g., /api/auth/login, /api/problems, /api/submissions).
• Backend routes → Controllers → Prisma client → Database (CRUD).
• On code submission: Controller calls compiler.ts util → judge0 REST API → receives execution results → stores results via Prisma → returns to client.
• Frontend reads execution result, errors, TestCaseResults from response and updates UI.
Architectural Patterns and Principles
• Client-server separation (SPA frontend + RESTful backend).
• Layered backend: Routes → Middlewares → Controllers → Data access (ORM).
• Single source of truth for state in frontend via React contexts and routed pages.
• Externalization of compute-heavy work to Judge0 (microservice integration).
• Database schema versioning and migrations handled by Prisma.