Overview
OpenSail uses PostgreSQL with SQLAlchemy 2.x (async) as the ORM. The schema consists of 39+ models organized into functional domains. All models use UUID primary keys, timezone-aware timestamps, and cascade deletes for clean data removal. This reference covers every model, its key fields, and its relationships. If you are adding a new model or modifying the schema, read the Contributing Guide section on database migrations.Common Patterns
Before diving into individual models, here are the patterns shared across the codebase.- UUID Primary Keys
- Timestamps
- Cascade Deletes
- JSON Columns
Model Hierarchy
Auth Models
Defined inorchestrator/app/models_auth.py.
User
The central identity model. Extends FastAPI-Users’SQLAlchemyBaseUserTable with Tesslate-specific features.
Key relationships:
projects, chats, purchased_agents, purchased_bases, api_keys, custom_models, deployment_credentials, oauth_accounts, access_tokens
OAuthAccount
Stores OAuth provider tokens (GitHub, Google). Managed by FastAPI-Users.AccessToken
JWT access tokens for session management. Managed by FastAPI-Users.EmailVerificationCode
Stores hashed 2FA codes and password reset tokens.Core Models
Defined inorchestrator/app/models.py.
Project
Top-level organizational unit. Each project can contain multiple containers forming a monorepo architecture.
Key relationships:
owner, containers, files, assets, browser_previews, chats, project_agents, kanban_board, notes, deployments, shell_sessions
Environment status lifecycle:
Container
Individual services within a project (frontend, backend, database).
Key relationships:
project, base, connections_from, connections_to
The
effective_port property returns internal_port or port or 3000. Always use this instead of writing ad-hoc fallback chains.ContainerConnection
Edges in the React Flow graph defining how containers communicate.BrowserPreview
Live preview windows displayed on the React Flow canvas.ProjectFile
Database-backed file content storage for the Monaco editor.ProjectAsset
Tracks uploaded binary assets (images, fonts, videos).ProjectSnapshot
EBS VolumeSnapshot records for project versioning and timeline.Chat Models
Chat
Conversation threads with AI agents.
Key relationships:
messages (one-to-many)
Message
Individual messages in a chat (user or assistant).AgentCommandLog
Audit log for shell commands executed by AI agents.ShellSession
Persistent terminal sessions for WebSocket connections.Marketplace Models
MarketplaceAgent
AI agents available for purchase or free use.MarketplaceBase
Project templates (React, FastAPI, Next.js, etc.).WorkflowTemplate
Pre-configured multi-container workflows.UserPurchasedAgent
Tracks agents in a user’s library.ProjectAgent
Assigns agents to specific projects.AgentReview / BaseReview
User reviews and ratings for agents and bases.AgentCoInstall
Recommendation system data (“People also installed”).Deployment Models
Deployment
External deployment history and status.DeploymentCredential
Encrypted OAuth tokens for deployment providers.GitProviderCredential
Unified Git provider OAuth credentials.Billing Models
MarketplaceTransaction
Revenue from agent purchases and usage.CreditPurchase
Credit package purchases.UsageLog
Token usage tracking for billing.UserAPIKey
User API keys for BYOK (Bring Your Own Key) providers.UserCustomModel
User-added models under BYOK providers.Kanban Models
Defined inorchestrator/app/models_kanban.py.