How rahulc34/online-compiler-backend works
This is a Compiler API: users authenticate and submit source files and input, then retrieve execution results. The API validates and queues jobs; a separate worker claims them, dispatches by language, runs them in Docker, and records status and output. Auth also supports email verification, password reset, sessions, and Google sign-in. Edges are limited to relationships shown in excerpts or the source index; unsampled recovery, cancellation, and integrations are represented only where their wiring is evidenced.
Main entry points: execution.worker.ts Execution worker · docker.service.ts Docker sandbox · execution.model.ts Execution records · auth.controller.ts Auth controller
Components 28
API and access
- HTTP application
src/app.ts - Auth routes
src/modules/auth/auth.routes.ts - Execution routes
src/modules/execution/execution.routes.ts
Identity
- Auth controller
src/modules/auth/auth.controller.ts - Auth service
src/modules/auth/auth.service.ts - Email OTP
src/services/otp.service.ts - Mail delivery
src/services/mail.service.ts - User records
src/models/user.model.ts - OTP records
src/models/otp.model.ts - Google authentication
src/config/passport.ts
Execution
- Execution controller
src/modules/execution/execution.controller.ts - Execution service
src/modules/execution/execution.service.ts - Cancellation service
src/modules/execution/execution-cancellation.service.ts - Execution records
src/models/execution.model.ts - Job queue
src/queues/execution.queue.ts - Execution worker
src/workers/execution.worker.ts
Language runtime
- C++ runner
src/services/cpp-execution.service.ts - Java runner
src/services/java-execution.service.ts - Script runner
src/services/script-execution.service.ts - JavaScript runner
src/services/javascript-execution.service.ts - Python runner
src/services/python-execution.service.ts - TypeScript runner
src/services/typescript-execution.service.ts - Docker sandbox
src/services/docker.service.ts
Other components
- Client user
- Docker Engine
- MongoDB
- Redis
- SMTP provider
Connections 36
- Client user → HTTP application: calls API
src/app.ts - HTTP application → Auth routes: mounts routes
src/app.ts - HTTP application → Execution routes: mounts routes
src/app.ts - Auth routes → Auth controller: routes requests
src/modules/auth/auth.routes.ts - Auth controller → Auth service: delegates auth
src/modules/auth/auth.controller.ts - Auth service → User records: reads and writes
src/modules/auth/auth.service.ts - Auth controller → Email OTP: verifies OTP
src/modules/auth/auth.controller.ts - Auth service → Email OTP: creates OTP
src/modules/auth/auth.service.ts - Email OTP → OTP records: stores OTP
src/services/otp.service.ts - Email OTP → User records: updates user
src/services/otp.service.ts - Auth service → Mail delivery: sends reset mail
src/modules/auth/auth.service.ts - Auth controller → Google authentication: authenticates Google
src/modules/auth/auth.controller.ts - Execution routes → Execution controller: routes requests
src/modules/execution/execution.routes.ts - Execution controller → Execution service: creates job
src/modules/execution/execution.controller.ts - Execution controller → Execution records: reads result
src/modules/execution/execution.controller.ts - Execution service → Execution records: creates record
src/modules/execution/execution.service.ts - Execution service → Job queue: enqueues job
src/modules/execution/execution.service.ts - Cancellation service → Execution records: updates status
src/modules/execution/execution-cancellation.service.ts - Cancellation service → Job queue: removes job
src/modules/execution/execution-cancellation.service.ts - Cancellation service → Redis: uses Redis
src/modules/execution/execution-cancellation.service.ts - Execution worker → Job queue: consumes jobs
src/workers/execution.worker.ts - Execution worker → Execution records: claims and updates
src/workers/execution.worker.ts - Execution worker → C++ runner: dispatches C++
src/workers/execution.worker.ts - Execution worker → Java runner: dispatches Java
src/workers/execution.worker.ts - Execution worker → JavaScript runner: dispatches JavaScript
src/workers/execution.worker.ts - Execution worker → Python runner: dispatches Python
src/workers/execution.worker.ts - Execution worker → TypeScript runner: dispatches TypeScript
src/workers/execution.worker.ts - C++ runner → Docker sandbox: runs in sandbox
src/services/cpp-execution.service.ts - Java runner → Docker sandbox: runs in sandbox
src/services/java-execution.service.ts - Script runner → Docker sandbox: runs in sandbox
src/services/script-execution.service.ts - Docker sandbox → Docker Engine: controls containers
src/services/docker.service.ts - Docker sandbox → MongoDB: execution persistence
- Docker sandbox → Redis: queue infrastructure
- Mail delivery → SMTP provider: sends email
- User records → MongoDB: persists users
- Execution records → MongoDB: persists executions