Skip to content

dalurness/self_gen_webserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Self-Healing Webserver

A dynamically evolving webserver that uses AI agents to handle unknown requests, automatically generates permanent handlers, and self-heals through continuous monitoring.

Architecture

  • 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

Quick Start

Prerequisites

  • Docker and Docker Compose
  • At least 8GB RAM (for Ollama)

Start the Services

# 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

Test the Gateway

# 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

Services

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

Development

# 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

How It Works

  1. Request arrives at Gateway
  2. If handler exists → execute handler
  3. If no handler → forward to AI Interpreter
  4. AI Interpreter:
    • Introspects database schema
    • Uses Ollama to understand request intent
    • Executes SQL query
    • Returns response
    • Writes specification to queue
  5. Coding Agent picks up specification:
    • Validates against current schema
    • Generates TypeScript handler
    • Updates registry
    • Triggers Gateway restart
  6. Self-Healer monitors logs:
    • Detects errors and patterns
    • Generates correction specifications
    • Feeds back into Coding Agent

Directory Structure

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)

API Examples

# 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"}'

Configuration

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

License

MIT "# self_gen_webserver"

About

Webserver that generates itself with agents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors