System overview
Core components
Frontend (Vue 3)
The frontend is a single-page application built with:- Vue 3 with Composition API and TypeScript
- Tailwind CSS for styling
- Pinia for state management
- Vue Router for navigation
- Axios for API communication
Backend (FastAPI)
The backend uses FastAPI with a domain-driven design pattern: Component structure:- FastAPI - Web framework
- SQLModel - ORM with Pydantic integration
- Alembic - Database migrations
- Loguru - Structured logging
- Pydantic - Data validation
Type registry pattern
Syft Space uses a plugin-style registry pattern for extensibility:- Adding new dataset types (e.g., Pinecone, Milvus)
- Adding new model providers (e.g., Cohere, Gemini)
- Adding new policy types (e.g., quota, throttling)
Multi-tenancy
Syft Space implements tenant isolation: Tenant middleware (tenants/middleware.py):
- Extracts tenant from JWT token or X-Tenant-Name header
- Injects tenant context into all requests
- Ensures data isolation between tenants
Provisioning system
Automatic Docker provisioning for vector databases: Provisioner manager manages:- Container lifecycle (start/stop/cleanup)
- Port allocation
- Volume management
- Health monitoring
- State persistence
Authentication & authorization
Authentication
Two auth modes:- Local auth - Bearer token from login
- SyftHub auth - Satellite token from marketplace
auth/middleware.py):
Authorization
Policy-based authorization:- Access policies control who can query endpoints
- Rate limit policies control query frequency
- Accounting policies track usage and costs
Database architecture
SQLite with async support:Lifecycle management
Components implementLifecycleService protocol:
- Initialize database
- Register type registries
- Start provisioner manager
- Start ingestion manager
- Start heartbeat manager
- Sync marketplace state
- Stop background tasks
- Cleanup provisioned resources
- Close database connections
Background services
Ingestion manager
Processes file uploads asynchronously:- Queue-based task processing
- File watching for auto-ingestion
- Chunking and embedding generation
- Progress tracking
Heartbeat manager
Monitors system health:- Periodic health checks
- Marketplace status sync
- Endpoint availability monitoring
Proxy service
Manages ngrok tunnels:- Automatic tunnel creation
- Public URL management
- Connection monitoring
API versioning
All endpoints are versioned:/api/v1/endpoints//api/v2/endpoints/(future)
Error handling
Consistent error responses:Performance considerations
- Async/await throughout for concurrency
- Connection pooling for database
- Caching for type registries and schemas
- Batch operations for policy evaluation
- Streaming responses for large queries
Security architecture
- JWT tokens for authentication
- Tenant isolation at data layer
- Input validation with Pydantic
- SQL injection protection via SQLModel
- CORS configured for trusted origins
- Rate limiting via policies
Extensibility points
- Dataset types - Add new data sources
- Model types - Add new AI providers
- Policy types - Add new access controls
- Middlewares - Add custom request processing
- Background services - Add scheduled tasks
See Custom integrations for implementation guides.