A mini AWS Lambda system for learning serverless architecture, distributed processing, and sandboxing. Execute JavaScript code in isolated Docker containers with resource limits and real-time monitoring.
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Frontend βββββββΆβ Backend βββββββΆβ Redis β
β (React) β β (Node.js) β β (Queue) β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β
βΌ βΌ
βββββββββββββββ βββββββββββββββ
β MongoDB β β Worker β
β (Storage) β β (Executor) β
βββββββββββββββ βββββββββββββββ
β
βΌ
βββββββββββββββ
β Sandbox β
β (Docker) β
βββββββββββββββ
- Serverless Execution: Submit JavaScript code and execute it in isolated environments
- Sandboxing: Docker containers with resource limits (CPU, memory, timeout)
- Distributed Processing: BullMQ-based job queue with horizontal scaling
- Real-time Monitoring: Live job status updates and log streaming
- Analytics Dashboard: Comprehensive view of system health, success rates, and queue pressure
- Premium UI: Modern, responsive React frontend built with Tailwind CSS v4 and shadcn/ui
- Adaptive Design: Fully optimized for mobile, tablet, and desktop with theme-aware branding
- Metrics: Native Prometheus integration and built-in visual analytics
- Docker and Docker Compose
- Node.js 20+ (for local development)
# Clone the repository
git clone <repository-url>
cd lambda-lite
# Build and start all services
docker compose -f infra/docker-compose.yml up --build
# Access the application
# Frontend: http://localhost:5173
# Backend API: http://localhost:8000
# Prometheus: http://localhost:9090For development, it's recommended to run Databases in Docker and Code locally.
# 1. Start only the databases
cd infra && docker compose up -d mongodb redis
# 2. Run your app (see below)cd apps/backend
yarn install
yarn devcd apps/worker
yarn install
yarn devcd apps/frontend
yarn install
yarn devPOST /api/jobs
Content-Type: application/json
{
"code": "function main(a, b) { return a + b; }",
"args": [2, 3],
"timeout": 30000
}GET /api/jobs/:idGET /api/jobs/:id/logsGET /api/jobs/analyticsGET /api/jobs?page=1&limit=20PORT: Server port (default: 8000)MONGODB_URI: MongoDB connection stringREDIS_HOST: Redis hostREDIS_PORT: Redis port
MONGODB_URI: MongoDB connection stringREDIS_HOST: Redis hostREDIS_PORT: Redis portSANDBOX_IMAGE: Docker image for sandbox (default: lambda-lite-sandbox:latest)
VITE_API_URL: Backend API URL
Access Prometheus metrics at http://localhost:9090
Available metrics:
lambda_lite_jobs_submitted_total: Total jobs submittedlambda_lite_jobs_completed_total: Total jobs completed (by status)lambda_lite_job_execution_duration_seconds: Job execution time histogramlambda_lite_active_jobs: Current active jobslambda_lite_queue_size: Jobs in queue
- Code Validation: Basic security checks for dangerous operations
- Sandboxing: Isolated Docker containers with:
- No network access
- Read-only filesystem
- CPU and memory limits
- Execution timeout
- Resource Limits: Configurable CPU, memory, and timeout constraints
function main(a, b) {
console.log('Adding', a, 'and', b);
return a + b;
}Arguments: [2, 3]
function main(numbers) {
console.log('Processing array:', numbers);
return numbers.reduce((sum, n) => sum + n, 0);
}Arguments: [[1, 2, 3, 4, 5]]
async function main(delay) {
console.log('Waiting', delay, 'ms');
await new Promise(resolve => setTimeout(resolve, delay));
console.log('Done!');
return 'Completed';
}Arguments: [1000]
lambda-lite/
βββ apps/
β βββ backend/ # REST API service
β βββ worker/ # Job execution service
β βββ frontend/ # React UI
βββ docker/
β βββ sandbox/ # Sandbox Docker image
βββ infra/
β βββ docker-compose.yml
β βββ prometheus.yml
β βββ redis.conf
βββ shared/ # Shared TypeScript types
Scale workers horizontally:
docker compose -f infra/docker-compose.yml up --scale worker=5- Backend: Node.js, Express, TypeScript
- Worker: Node.js, Dockerode, TypeScript
- Queue: Redis, BullMQ
- Database: MongoDB
- Monitoring: Prometheus, prom-client
- Frontend: React, TypeScript, Vite, Tailwind CSS v4, shadcn/ui, Lucide Icons, Monaco Editor
- Containerization: Docker, Docker Compose
Contributions are welcome! This is a learning project demonstrating:
- Serverless architecture patterns
- Distributed job processing
- Container-based sandboxing
- Real-time monitoring
- Microservices communication
MIT License - feel free to use this project for learning and experimentation.
This project demonstrates:
- Distributed Systems: Job queue, worker pool, horizontal scaling
- Sandboxing: Secure code execution in isolated environments
- Microservices: Backend, worker, and frontend as separate services
- Real-time Updates: WebSocket-based status and log streaming
- Monitoring: Prometheus metrics and observability
- Docker: Multi-stage builds, Docker-in-Docker, resource limits
- Full-stack Development: React frontend + Node.js backend
Ensure Docker socket is mounted:
volumes:
- /var/run/docker.sock:/var/run/docker.sockCheck worker logs:
docker compose -f infra/docker-compose.yml logs workerCheck API proxy configuration in nginx.conf or vite.config.ts
Built with β€οΈ for learning distributed systems and serverless architecture