π Core Service β Devex Cloud IDE Backend
The core/
service is the main backend API server responsible for:
- β’Handling GitHub OAuth2.0 login
- β’Managing REPL sessions and their lifecycles
- β’Creating & deleting Kubernetes workloads for REPLs
- β’Interacting with S3 and Redis
It is written in Go and designed as a lightweight API service for managing REPL infrastructure.
You can Checkout how this server is deployed at
DEPLOYMENT
.
π Directory Structure
π API Endpoints
POST /auth/github
Handles GitHub OAuth2.0 login. After successful login, the user session is managed via cookies or JWT.
POST /api/repl/...
(Protected Route)
These routes require a valid authenticated user session.
Protected via Middleware
The middleware verifies the user's session using cookies or headers, and passes the request if authenticated.
π§ Core Concepts
ποΈ S3 β Code Storage
All REPL files are stored in S3 under:
username/repl-id/
On REPL creation:
- β’A folder is created
- β’Template files are copied from the
/templates
directory
βΈοΈ Kubernetes β Dynamic REPLs
When a REPL is started, the backend dynamically creates:
- β’A Deployment
- β’A Service
- β’An Ingress
These allow the user to access their running REPL via:
[https://repl.parthkapoor.me/repl-id/](https://repl.parthkapoor.me/repl-id/)<subpath>
REPL Creation Logic
- β’Files are pulled from S3 via an InitContainer
- β’The main container (Runner) connects to frontend over WebSocket
π Code:
REPL Deletion Logic
When a REPL session ends:
- β’An ephemeral container is injected into the pod
- β’Files are pushed back to S3
- β’The Deployment, Service, and Ingress are deleted
π Code:
πΎ Redis β In-memory Session State
We use Redis as a lightweight store to manage:
- β’
activeSession:{replId}
β userβs active REPL session
- β’
userRepls:{userId}
β all REPL IDs owned by the user
- β’
replMeta:{replId}
β metadata like name, template, etc.
No traditional SQL DB is needed as:
- β’User data comes directly from GitHub
- β’Code is stored in S3
π Redis Store Logic:
internal/redis/store.go
π§ Internal Utilities
π§ͺ Sample Flow
- β’User logs in via
/auth/github
- β’Frontend calls
/api/repl/create
with template + name
- β’Backend:
- β’Creates S3 folder and copies template files
- β’Creates K8s Deployment + Service + Ingress
- β’Returns access path
- β’User writes code, interacts via WebSocket
- β’On close:
- β’Ephemeral container syncs files β S3
- β’K8s resources cleaned up
π¦ Future Improvements
- β’Add metrics and logging
- β’Add support for multiple languages and templates
- β’Optional: move metadata from Redis to Postgres
π§ Next Docs
π Want to understand how the REPL container works? Check out the
runner/
docs.
Need help setting up the cluster? Head to
k8s/
.