New table stores: - Edge identification (from_node → to_node) - Analysis results (confidence, level, method) - Proposed mapping (AI-generated) - User mapping (overrides) - Confirmation status Indexes: - By flow_id for listing - Unique on (flow_id, from_node, to_node) for upsert This supports the edge analysis API for visual wiring in the canvas. Co-authored-by: Dan |
||
|---|---|---|
| .. | ||
| alembic | ||
| api | ||
| domain | ||
| runtime | ||
| .env.example | ||
| __init__.py | ||
| alembic.ini | ||
| docker-compose.yml | ||
| Dockerfile | ||
| README.md | ||
| requirements.txt | ||
BloxServer API
Backend API for BloxServer (OpenBlox.ai) - Visual AI Agent Workflow Builder.
Quick Start
With Docker Compose (Recommended)
cd bloxserver
# Start PostgreSQL, Redis, and API
docker-compose up -d
# Check logs
docker-compose logs -f api
# API available at http://localhost:8000
# Docs at http://localhost:8000/docs
Local Development
cd bloxserver
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Copy environment variables
cp .env.example .env
# Edit .env with your settings
# Start PostgreSQL and Redis (or use Docker)
docker-compose up -d postgres redis
# Run the API
python -m bloxserver.api.main
# Or with uvicorn directly:
uvicorn bloxserver.api.main:app --reload
API Endpoints
Health
GET /health- Basic health checkGET /health/ready- Readiness check (includes DB)GET /health/live- Liveness check
Flows
GET /api/v1/flows- List flowsPOST /api/v1/flows- Create flowGET /api/v1/flows/{id}- Get flowPATCH /api/v1/flows/{id}- Update flowDELETE /api/v1/flows/{id}- Delete flowPOST /api/v1/flows/{id}/start- Start flowPOST /api/v1/flows/{id}/stop- Stop flow
Triggers
GET /api/v1/flows/{flow_id}/triggers- List triggersPOST /api/v1/flows/{flow_id}/triggers- Create triggerGET /api/v1/flows/{flow_id}/triggers/{id}- Get triggerDELETE /api/v1/flows/{flow_id}/triggers/{id}- Delete triggerPOST /api/v1/flows/{flow_id}/triggers/{id}/regenerate-token- Regenerate webhook token
Executions
GET /api/v1/flows/{flow_id}/executions- List executionsGET /api/v1/flows/{flow_id}/executions/{id}- Get executionPOST /api/v1/flows/{flow_id}/executions/run- Manual triggerGET /api/v1/flows/{flow_id}/executions/stats- Get stats
Webhooks
POST /webhooks/{token}- Trigger flow via webhookGET /webhooks/{token}/test- Test webhook token
Project Structure
bloxserver/
├── api/
│ ├── __init__.py
│ ├── main.py # FastAPI app entry point
│ ├── dependencies.py # Auth, DB session dependencies
│ ├── schemas.py # Pydantic request/response models
│ ├── models/
│ │ ├── __init__.py
│ │ ├── database.py # SQLAlchemy engine/session
│ │ └── tables.py # ORM table definitions
│ └── routes/
│ ├── __init__.py
│ ├── flows.py # Flow CRUD
│ ├── triggers.py # Trigger CRUD
│ ├── executions.py # Execution history
│ ├── webhooks.py # Webhook handler
│ └── health.py # Health checks
├── requirements.txt
├── Dockerfile
├── docker-compose.yml
├── .env.example
└── README.md
Authentication
Uses Clerk for JWT authentication. All /api/v1/* endpoints require a valid JWT.
curl -H "Authorization: Bearer <clerk-jwt>" \
http://localhost:8000/api/v1/flows
Environment Variables
See .env.example for all configuration options.
Key variables:
DATABASE_URL- PostgreSQL connection stringCLERK_ISSUER- Clerk JWT issuer URLSTRIPE_SECRET_KEY- Stripe API keyAPI_KEY_ENCRYPTION_KEY- Fernet key for encrypting user API keys
Database Migrations
Using Alembic for migrations (not yet set up):
# Initialize (first time)
alembic init alembic
# Create migration
alembic revision --autogenerate -m "description"
# Apply migrations
alembic upgrade head
Testing
# Install test dependencies
pip install pytest pytest-asyncio httpx
# Run tests
pytest tests/ -v
Deployment
Railway / Render / Fly.io
- Connect your repo
- Set environment variables
- Deploy
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: bloxserver-api
spec:
replicas: 3
template:
spec:
containers:
- name: api
image: your-registry/bloxserver-api:latest
ports:
- containerPort: 8000
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: bloxserver-secrets
key: database-url
livenessProbe:
httpGet:
path: /health/live
port: 8000
readinessProbe:
httpGet:
path: /health/ready
port: 8000
Next Steps
- Alembic migrations setup
- Stripe webhook handlers
- Redis rate limiting
- Container orchestration integration
- WebSocket for real-time logs