CRUD Application
A simple FastAPI CRUD service for testing systemg service management capabilities.Features demonstrated
- Service management with
sysg startandsysg stop - Automatic recovery from failures
- Zero-downtime rolling deployments
- Modern Python with FastAPI and uvicorn
- Package management with uv
Configuration
Application code
main.py
Dependencies
Createpyproject.toml:
Run it
API endpoints
GET /- Health checkPOST /todos- Create a new todoGET /todos- List all todosGET /todos/{id}- Get a specific todoPUT /todos/{id}- Update a todoDELETE /todos/{id}- Delete a todoGET /chaos- Random failure endpoint (70% failure rate)
Testing
Run the test script to verify all endpoints:- Create a new todo
- Read all todos
- Update the todo
- Get a specific todo
- Test the chaos endpoint (demonstrates recovery)
- Delete the todo
Operations
Stop the service
View logs
Check status
Example usage
Create a Todo
List Todos
Update a Todo
Test chaos endpoint
What happens
- Service starts with
sysg startand serves the API on port 8888 - In-memory storage using Python dict for simplicity
- Chaos endpoint randomly fails to demonstrate recovery capabilities
- Automatic restarts when service crashes (up to 10 retries with 5s backoff)
- Rolling deployments ensure zero downtime during updates
Interactive API docs
FastAPI provides automatic interactive documentation at:- Swagger UI:
http://localhost:8888/docs - ReDoc:
http://localhost:8888/redoc
See also
- Configuration - Service definitions
- Hello World - Simple example to get started
- Orchestrator - Multi-agent task execution