API Mesh¶
Project: Distributed WebSocket Proxy Network Tech Stack: Python 3.11+, FastAPI, WebSockets, Pydantic
Overview¶
API Mesh is a lightweight, Python-native distributed WebSocket network that proxies FastAPI services. Workers wrap existing FastAPI services, discover each other via UDP broadcast, exchange API Cards describing their capabilities, and route messages through a central Gateway.
Core Concepts¶
| Concept | Description |
|---|---|
| API Worker | Wraps a FastAPI service, parses its OpenAPI spec, handles proxied requests |
| API Card | Service advertisement containing endpoints, schemas, and metadata |
| Message Protocol | JSON envelope for all inter-worker communication |
| Discovery | UDP broadcast for LAN-based worker discovery |
| Gateway | External WebSocket entry point for clients |
Architecture¶
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Gateway │◄───►│ Worker A │◄───►│ Worker B │
│ (External) │ │ (FastAPI) │ │ (FastAPI) │
└─────────────┘ └─────────────┘ └─────────────┘
▲ │ │
│ UDP Broadcast Discovery
│ ▼ ▼
WebSocket ┌─────────────────────────────┐
Clients │ Service Registry │
└─────────────────────────────┘
Documentation¶
- Full Project Guide - Complete specification and implementation details
Development¶
# Install dependencies
pip install -e ".[dev]"
# Run linting
ruff check src tests
# Run tests
pytest
# Type checking
mypy src
CLI¶
# Start a worker wrapping a FastAPI service
apimesh worker --service http://localhost:8000
# Start the gateway
apimesh gateway --port 9000
Related¶
- CLAUDE.md - AI coding guide