A minimal Go application that autonomously generates complete REST APIs with tests using local LLMs via Ollama. This proof of concept demonstrates how AI can generate working code overnight with zero API costs.
# 1. Install Ollama (if not already installed)
# Visit: https://ollama.ai
# 2. Start Ollama and pull a model
ollama serve
ollama pull codellama:7b
# 3. Build and run the generator
make build
./overnight-llm -output ./my-api
# 4. Test the generated API
cd my-api
go test ./...
go run cmd/server/main.go- Go 1.21+ - Required for building and validating generated code
- Ollama - Local LLM runtime (https://ollama.ai)
- SQLite3 - Embedded database (included via Go driver)
- ~2GB RAM - For running small models
- ~5GB disk space - For model storage
The system follows a simple, fixed pipeline architecture:
ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β Prompts ββββββΆβ Ollama LLM ββββββΆβ Generated β
β Templates β β (Local) β β Code β
ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β
ββββββββΌβββββββ
β SQLite β
β Task Store β
βββββββββββββββ
- Orchestrator: Manages the fixed pipeline of code generation tasks
- LLM Client: Simple HTTP client for Ollama API (no streaming)
- Storage: SQLite database for tracking tasks and outputs
- Validator: Uses Go toolchain to validate generated code
- Prompts: Fixed templates for each generation phase
- β Zero API Costs - Uses only local Ollama models
- β Single Binary - Everything compiles to ~30MB executable
- β Embedded Resources - SQL schema and prompts included
- β Code Validation - Automatic formatting and validation
- β Progress Tracking - Real-time status updates
- β Safety Limits - Timeouts and output size restrictions
# Clone the repository
git clone <repository-url>
cd gorchestrator-poc
# Install dependencies
make deps
# Build the binary
make build
# Or install to GOPATH/bin
make install# Build for multiple platforms
make build-all
# Binaries will be in dist/
ls dist/
# overnight-llm-mac-arm64
# overnight-llm-mac-amd64
# overnight-llm-linux-amd64# Generate with default settings
./overnight-llm
# Specify output directory
./overnight-llm -output ./my-api
# Use a different model
./overnight-llm -model llama2:13b
# Skip validation for faster generation
./overnight-llm -skip-validation| Flag | Default | Description |
|---|---|---|
-output |
./generated |
Output directory for generated code |
-model |
codellama:7b |
Ollama model to use |
-ollama |
http://localhost:11434 |
Ollama API endpoint |
-prompt |
REST API for todo list |
What to generate |
-db |
./poc.db |
SQLite database path |
-skip-validation |
false |
Skip code validation |
-version |
- | Show version information |
-help |
- | Show help message |
Recommended models for code generation:
| Model | Size | Speed | Quality |
|---|---|---|---|
codellama:7b |
3.8GB | Fast | Good |
deepseek-coder:1.3b |
776MB | Very Fast | Acceptable |
codellama:13b |
7.4GB | Medium | Better |
llama2:13b |
7.4GB | Medium | Good |
The generator creates a complete Go project:
generated/
βββ cmd/
β βββ server/
β βββ main.go # API server entry point
βββ internal/
β βββ models/
β β βββ todo.go # Data models with validation
β βββ handlers/
β β βββ todo_handler.go # HTTP request handlers
β βββ repository/
β βββ todo_repo.go # Database operations
βββ tests/
β βββ todo_handler_test.go # Unit tests
βββ go.mod # Go module file
βββ README.md # Generated documentation
βββ status.json # Generation statistics
# Run all tests
make test
# Generate coverage report
make test-coverage
# Opens coverage.html in browser# Test the generated API
cd generated/
go test -v ./...
go run cmd/server/main.go
# In another terminal
curl http://localhost:8080/todos
curl -X POST http://localhost:8080/todos \
-H "Content-Type: application/json" \
-d '{"title":"Test Todo","description":"Testing the API"}'gorchestrator-poc/
βββ cmd/generator/ # CLI entry point
βββ internal/
β βββ orchestrator/ # Pipeline management
β βββ llm/ # Ollama client
β βββ storage/ # SQLite operations
β βββ validator/ # Code validation
βββ prompts/ # Generation templates
βββ Makefile # Build automation
βββ README.md # This file
# Auto-rebuild on file changes (requires entr)
make dev
# Format code
make fmt
# Run linter
make lint
# Run go vet
make vetThe PoC is considered successful when:
- β Generates a working Todo REST API
- β Generated code compiles without errors
- β Tests achieve >70% coverage
- β Completes in under 30 minutes
- β Uses $0 in API costs
- β Binary size under 50MB
# Check if Ollama is running
make check-ollama
# Start Ollama
ollama serve
# Pull required models
make setup-models# List available models
ollama list
# Pull a model
ollama pull codellama:7b# Clean and rebuild
make clean
make deps
make build- Check Ollama is running:
curl http://localhost:11434/api/tags - Verify model exists:
ollama list - Try a smaller model if out of memory
- Check
poc.dbfor detailed error messages - Review
generated/status.jsonfor task details
Typical generation times on M1 MacBook Pro:
| Model | Generation Time | Memory Usage |
|---|---|---|
codellama:7b |
~5-10 minutes | ~4GB |
deepseek-coder:1.3b |
~2-5 minutes | ~1GB |
codellama:13b |
~10-20 minutes | ~8GB |
- Fixed Pipeline: No dynamic task graphs (by design)
- Local Only: No cloud API support (cost control)
- Output Limits: 10MB max per task (configurable)
- Timeout: 30-minute maximum runtime
- No Retry Logic: Fails fast on errors (simplicity)
After the PoC proves successful, potential v2 features:
- Multiple agents working in parallel
- Dynamic task decomposition
- Cloud LLM fallback for complex tasks
- Web UI for monitoring progress
- Git integration for automatic commits
- Support for multiple programming languages
- Custom prompt templates
- Incremental code updates
This is a proof of concept for demonstration purposes.
This is a minimal PoC focused on demonstrating core value. Please keep contributions aligned with the simplicity principle.
For issues or questions:
- Check the troubleshooting section
- Review
poc.dbfor task errors - Examine
generated/status.jsonfor details - Try with a smaller model or simpler prompt
Remember: This is a MINIMAL proof of concept. Every feature beyond autonomous overnight code generation should be deferred to v2.