Skip to content

JullMol/nebula

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌌 Nebula

Go Docker gRPC Redis PostgreSQL

A lightweight, distributed serverless code execution platform

Execute Python & Node.js code in isolated Docker containers with automatic load balancing

Features β€’ Architecture β€’ Getting Started β€’ API Reference


⚑ Features

Feature Description
🐳 Container Isolation Each code execution runs in a fresh Docker container
βš–οΈ Load Balancing Round-robin distribution across multiple worker nodes
πŸ”„ Async Job Queue Redis-powered job queue with background processing
πŸ“Š Real-time Monitoring Prometheus metrics + Grafana dashboards
🌐 gRPC Communication High-performance inter-service communication
🐍 Multi-Language Support for Python and Node.js

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           CLIENT (Browser)                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚ HTTP/REST
                                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         API GATEWAY (Fiber)                         β”‚
β”‚  β€’ Authentication (API Key)      β€’ Rate Limiting                    β”‚
β”‚  β€’ Job Submission                β€’ Status Polling                   β”‚
β”‚  β€’ Prometheus Metrics            β€’ Static UI Serving                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                                         β”‚
            β–Ό                                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      PostgreSQL       β”‚                 β”‚          Redis            β”‚
β”‚   (Job Persistence)   β”‚                 β”‚      (Job Queue)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                        β”‚
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚                             β”‚             β”‚
                          β–Ό                             β–Ό             β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚    WORKER 1       β”‚         β”‚    WORKER 2       β”‚  ...
              β”‚  (gRPC Server)    β”‚         β”‚  (gRPC Server)    β”‚
              β”‚                   β”‚         β”‚                   β”‚
              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
              β”‚  β”‚   Docker    β”‚  β”‚         β”‚  β”‚   Docker    β”‚  β”‚
              β”‚  β”‚  Container  β”‚  β”‚         β”‚  β”‚  Container  β”‚  β”‚
              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Getting Started

Prerequisites

  • Go 1.21+
  • Docker Desktop
  • PostgreSQL (via Docker)
  • Redis (via Docker)

Quick Start

# Clone the repository
git clone https://github.com/JullMol/nebula.git
cd nebula

# Start infrastructure
docker-compose up -d redis postgres prometheus grafana

# Run Gateway (Terminal 1)
go run cmd/gateway/main.go

# Run Workers (Terminal 2 & 3)
go run cmd/worker/main.go -port 9091
go run cmd/worker/main.go -port 9092

Open http://localhost:3000 in your browser πŸŽ‰


πŸ“ Project Structure

nebula/
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ proto/              # Protocol Buffer definitions
β”‚   └── pb/                 # Generated gRPC code
β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ gateway/            # API Gateway service
β”‚   β”‚   β”œβ”€β”€ main.go
β”‚   β”‚   └── index.html      # Web UI
β”‚   └── worker/             # Worker service
β”‚       └── main.go
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ gateway/
β”‚   β”‚   └── proxy/          # gRPC proxy to workers
β”‚   β”œβ”€β”€ orchestrator/
β”‚   β”‚   └── scheduler/      # Load balancer (Round Robin)
β”‚   β”œβ”€β”€ platform/
β”‚   β”‚   β”œβ”€β”€ database/       # PostgreSQL connection
β”‚   β”‚   β”œβ”€β”€ docker/         # Docker client
β”‚   β”‚   └── queue/          # Redis queue
β”‚   └── worker/             # Worker gRPC server
β”œβ”€β”€ pkg/
β”‚   └── config/             # Configuration loader
β”œβ”€β”€ deploy/
β”‚   β”œβ”€β”€ docker/             # Dockerfiles
β”‚   └── monitoring/         # Prometheus config
β”œβ”€β”€ docker-compose.yaml
└── config.yaml

πŸ“‘ API Reference

Submit Job

POST /submit
Headers: X-API-KEY: rahasia-negara
Content-Type: application/json

{
  "image": "python:alpine",
  "command": "",
  "code": "print('Hello, Nebula!')"
}

Response:

{
  "status": "queued",
  "job_id": "uuid-here",
  "info": "Job tersimpan di DB & Masuk Redis"
}

Check Status

GET /status/:job_id

Response:

{
  "job_id": "uuid-here",
  "status": "completed",
  "result": "Hello, Nebula!\n",
  "created_at": "2024-01-05T10:00:00Z",
  "updated_at": "2024-01-05T10:00:03Z"
}

πŸ“Š Monitoring

Access dashboards:

Available metrics:

  • nebula_jobs_submitted_total - Total jobs submitted
  • nebula_jobs_processed_total{status="completed|failed"} - Jobs by status

πŸ› οΈ Tech Stack

Layer Technology
Language Go 1.21
Web Framework Fiber v2
RPC gRPC + Protocol Buffers
Database PostgreSQL 15
Queue Redis
Container Docker
Monitoring Prometheus + Grafana

🎯 How It Works

  1. Client submits code via REST API or Web UI
  2. Gateway saves job to PostgreSQL and pushes to Redis queue
  3. Background Dispatcher dequeues job and forwards to available worker
  4. Worker creates temp file, mounts to Docker container, executes
  5. Worker captures logs and returns result via gRPC
  6. Gateway updates PostgreSQL with result
  7. Client polls status endpoint until completion

πŸ“ License

MIT License - feel free to use for learning and portfolio!


Built with ❀️ by JullMol

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors