Complete SaaS platform demonstrating pactown’s ability to orchestrate multiple interconnected services.
┌─────────────┐
│ Gateway │ :8000
│ (FastAPI) │
└──────┬──────┘
│
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Web │ │ API │ │ Database │
│ :8002 │ │ :8001 │ │ :8003 │
│ (HTML) │ │ (FastAPI) │ │ (SQLite) │
└─────────────┘ └──────┬──────┘ └─────────────┘
│ ▲
└───────────────┘
│
┌───────┴───────┐
│ CLI │
│ (Click) │
└───────────────┘
| Service | Port | Technology | Description |
|---|---|---|---|
| Gateway | 8000 | FastAPI | API gateway, routes requests |
| API | 8001 | FastAPI | REST API for users/stats |
| Web | 8002 | HTML/JS | Web frontend dashboard |
| Database | 8003 | SQLite/FastAPI | Key-value database service |
| CLI | - | Click/Rich | Admin command-line tool |
# Install pactown
pip install pactown
# Start the ecosystem
cd examples/saas-platform
pactown up saas.pactown.yaml
# Or dry-run to see the plan
pactown up saas.pactown.yaml --dry-run
Pactown automatically resolves dependencies and starts services in order:
Once running:
# In the CLI sandbox
cd .pactown-sandboxes/cli
# List users
python cli.py users list
# Add a user
python cli.py users add "John Doe" "john@example.com"
# Check service health
python cli.py health
# View stats
python cli.py stats
Each service receives injected environment variables for its dependencies:
| Service | Variable | Value |
|---|---|---|
| API | DATABASE_URL |
http://localhost:8003 |
| Web | API_URL |
http://localhost:8001 |
| CLI | API_URL |
http://localhost:8001 |
| CLI | DATABASE_URL |
http://localhost:8003 |
| Gateway | API_URL |
http://localhost:8001 |
| Gateway | DATABASE_URL |
http://localhost:8003 |
| Gateway | WEB_URL |
http://localhost:8002 |
saas-platform/
├── saas.pactown.yaml # Ecosystem configuration
├── README.md # This file
└── services/
├── api/
│ └── README.md # API service (markpact)
├── web/
│ └── README.md # Web frontend (markpact)
├── database/
│ └── README.md # Database service (markpact)
├── cli/
│ └── README.md # CLI tool (markpact)
└── gateway/
└── README.md # API gateway (markpact)
services/new-service/README.md with markpact blockssaas.pactown.yaml:services:
new-service:
readme: services/new-service/README.md
port: 8004
health_check: /health
depends_on:
- name: api
endpoint: http://localhost:8001
pactown down saas.pactown.yaml && pactown up saas.pactown.yamlUpdate the port in saas.pactown.yaml and any dependent services will automatically receive the updated endpoint.
# Find what's using the port
lsof -i :8001
# Kill the process or change the port in saas.pactown.yaml
# Check the sandbox logs
cat .pactown-sandboxes/api/app.log
# Or run the service manually
cd .pactown-sandboxes/api
source .venv/bin/activate
python -m uvicorn app.main:app --port 8001
# Validate configuration
pactown validate saas.pactown.yaml