A dynamically evolving webserver that uses AI agents to handle unknown requests, automatically generates permanent handlers, and self-heals through continuous monitoring.
- Gateway: Routes requests to handlers or AI interpreter
- AI Interpreter: Uses Ollama to understand and execute requests
- Coding Agent: Generates handler code from specifications
- Self-Healer: Monitors logs and generates corrections
- Docker and Docker Compose
- At least 8GB RAM (for Ollama)
# Start all services
docker-compose up -d
# Pull the AI model (first time only)
./scripts/pull-model.sh llama3.2
# View logs
docker-compose logs -f# Health check
curl http://localhost:3000/health
# Try an unhandled route (AI will interpret and respond)
curl http://localhost:3000/v1/users/1
# After AI handles it, a handler spec is generated
# The coding agent will process it and create a permanent handler| Service | Port | Description |
|---|---|---|
| Gateway | 3000 | Main HTTP API |
| AI Interpreter | 3010 | Handles unknown requests |
| Coding Agent | - | Generates handlers |
| Self-Healer | - | Monitors and repairs |
| PostgreSQL | 5432 | Database |
| Ollama | 11434 | Local LLM |
# Start with live logs
docker-compose up
# Rebuild a specific service
docker-compose build gateway
# View service logs
docker-compose logs -f gateway
# Reset everything
./scripts/reset.sh- Request arrives at Gateway
- If handler exists → execute handler
- If no handler → forward to AI Interpreter
- AI Interpreter:
- Introspects database schema
- Uses Ollama to understand request intent
- Executes SQL query
- Returns response
- Writes specification to queue
- Coding Agent picks up specification:
- Validates against current schema
- Generates TypeScript handler
- Updates registry
- Triggers Gateway restart
- Self-Healer monitors logs:
- Detects errors and patterns
- Generates correction specifications
- Feeds back into Coding Agent
selfhealserver/
├── docker-compose.yml
├── shared/ # Shared types
├── services/
│ ├── gateway/ # HTTP Gateway
│ ├── ai-interpreter/ # AI request handling
│ ├── coding-agent/ # Code generation
│ └── self-healer/ # Error monitoring
├── scripts/ # Helper scripts
└── volumes/ # Local dev mounts (gitignored)
# Get a user (AI will interpret first time)
curl http://localhost:3000/v1/users/1
# List products
curl http://localhost:3000/v1/products
# Create a user
curl -X POST http://localhost:3000/v1/users \
-H "Content-Type: application/json" \
-d '{"name": "John", "email": "john@example.com"}'Environment variables:
| Variable | Default | Description |
|---|---|---|
INTERNAL_SECRET |
- | Secret for internal API calls |
DATABASE_URL |
- | PostgreSQL connection string |
OLLAMA_URL |
http://ollama:11434 | Ollama API URL |
LOG_LEVEL |
info | Logging level |
MIT "# self_gen_webserver"