Skip to main content
Every workspace, issue, agent, and comment you create is stored in these tables.

Quick Start

1

Zero Configuration (Default)

from praisonai_platform.client import PlatformClient

# In-memory SQLite - data lost on restart
client = PlatformClient(base_url="http://localhost:8000")
client.login(email="me@example.com", password="...")

workspace = client.workspaces.create(name="Research")
issue = client.issues.create(workspace_id=workspace.id, title="Setup database")
2

Persistent SQLite

# Set database URL for persistence
export DATABASE_URL="sqlite+aiosqlite:///./platform.db"

# Initialize database tables
python -c "import asyncio; from praisonai_platform.db import init_db; asyncio.run(init_db())"
3

PostgreSQL Production

# Switch to PostgreSQL
export DATABASE_URL="postgresql+asyncpg://user:pass@host/db"

# Initialize tables
python -c "import asyncio; from praisonai_platform.db import init_db; asyncio.run(init_db())"

How It Works

ComponentPurposeLifecycle
EngineDatabase connection poolCached globally, first call wins
SessionPer-request transactionCreated/disposed per API call
get_dbFastAPI dependencyYields session, auto-commits
init_dbTable creationCall once for persistent databases

Entities

User (users)

Authentication and identity for platform access.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
namestrUsername (unique)
emailstrEmail address (unique)
password_hashstrHashed password
created_atdatetimeUTC nowCreation timestamp
updated_atdatetimeUTC nowLast update timestamp

Workspace (workspaces)

Top-level container for organizing projects and issues.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
namestrWorkspace name
descriptionstrNoneOptional description
settingsdict{}JSON configuration
issue_prefixstr"ISSUE"Issue numbering prefix
created_atdatetimeUTC nowCreation timestamp
updated_atdatetimeUTC nowLast update timestamp

Member (members)

User membership and roles within workspaces.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
user_idstrForeign key to users
workspace_idstrForeign key to workspaces
rolestr"member"Role: owner, admin, member
created_atdatetimeUTC nowCreation timestamp
updated_atdatetimeUTC nowLast update timestamp
Constraints: Unique (user_id, workspace_id)

Project (projects)

Optional grouping for issues within a workspace.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
workspace_idstrForeign key to workspaces
namestrProject name
descriptionstrNoneOptional description
settingsdict{}JSON configuration
created_atdatetimeUTC nowCreation timestamp
updated_atdatetimeUTC nowLast update timestamp

Issue (issues)

Work items and tasks within a workspace.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
workspace_idstrForeign key to workspaces
project_idstrNoneOptional foreign key to projects
titlestrIssue title
descriptionstrNoneOptional description
statusstr"backlog"Status: backlog, in-progress, done
prioritystr"medium"Priority: low, medium, high, urgent
assignee_idstrNoneOptional foreign key to users
created_by_idstrNoneOptional foreign key to users
issue_numberintNoneAuto-incrementing number
created_atdatetimeUTC nowCreation timestamp
updated_atdatetimeUTC nowLast update timestamp

Comment (comments)

Discussion threads on issues.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
issue_idstrForeign key to issues
author_idstrNoneOptional foreign key to users
contentstrComment text
created_atdatetimeUTC nowCreation timestamp
updated_atdatetimeUTC nowLast update timestamp

Agent (agents)

AI agents assigned to workspaces.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
workspace_idstrForeign key to workspaces
namestrAgent name
descriptionstrNoneOptional description
statusstr"idle"Status: idle, active, error
configdict{}JSON configuration
created_atdatetimeUTC nowCreation timestamp
updated_atdatetimeUTC nowLast update timestamp

IssueLabel (issue_labels)

Label definitions for categorizing issues.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
workspace_idstrForeign key to workspaces
namestrLabel name
colorstr"#000000"Hex color code
descriptionstrNoneOptional description
created_atdatetimeUTC nowCreation timestamp
updated_atdatetimeUTC nowLast update timestamp
Many-to-many relationship between issues and labels.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
issue_idstrForeign key to issues
label_idstrForeign key to issue_labels
created_atdatetimeUTC nowCreation timestamp
Constraints: Unique (issue_id, label_id)

IssueDependency (issue_dependencies)

Dependency relationships between issues.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
issue_idstrForeign key to issues
depends_on_idstrForeign key to issues
dependency_typestrType: blocks, blocked_by, related
created_atdatetimeUTC nowCreation timestamp
Constraints: Unique (issue_id, depends_on_id, dependency_type)

ActivityLog (activity_logs)

Audit trail for workspace activities.
ColumnTypeDefaultDescription
idstrUUIDPrimary key
workspace_idstrForeign key to workspaces
entity_typestrEntity type: issue, project, workspace
entity_idstrID of the affected entity
actionstrAction: created, updated, deleted
actor_idstrNoneOptional foreign key to users
detailsdict{}JSON details
created_atdatetimeUTC nowCreation timestamp

Configuration Options

NameWhereDefaultDescription
DATABASE_URLenv varsqlite+aiosqlite:///:memory:SQLAlchemy async URL used by get_engine()
get_engine(database_url=None)praisonai_platform.dbReturns the cached AsyncEngine; first call wins, pass database_url to override env
get_session()praisonai_platform.dbAsync generator yielding an AsyncSession per request
init_db()praisonai_platform.dbCreates all tables via Base.metadata.create_all
reset_engine()praisonai_platform.dbDisposes and clears the cached engine (tests / URL switch)

Common Patterns

Running One-Off Queries

import asyncio
from praisonai_platform.db import get_session, init_db
from praisonai_platform.db.models import Workspace
from sqlalchemy import select

async def count_workspaces():
    await init_db()  # Ensure tables exist
    async for session in get_session():
        result = await session.execute(select(Workspace))
        workspaces = result.scalars().all()
        print(f"Found {len(workspaces)} workspaces")
        break

asyncio.run(count_workspaces())

Switching to PostgreSQL in Production

# 1. Install driver
pip install asyncpg

# 2. Set database URL
export DATABASE_URL="postgresql+asyncpg://user:password@localhost/platform"

# 3. Initialize tables
python -c "import asyncio; from praisonai_platform.db import init_db; asyncio.run(init_db())"

# 4. Start platform server
python -m praisonai_platform

Resetting Engine in Tests

import pytest
from praisonai_platform.db import reset_engine, init_db

@pytest.fixture(autouse=True)
async def clean_db():
    await reset_engine()  # Clear cached engine
    await init_db()       # Create fresh tables
    yield
    await reset_engine()  # Clean up

Best Practices

For non-memory databases, call init_db() once at application startup, not per request. The default in-memory SQLite creates tables automatically.
# In your app startup
import asyncio
from praisonai_platform.db import init_db

if __name__ == "__main__":
    asyncio.run(init_db())  # Only for persistent databases
    # Start your server...
The engine is cached globally - if you need to switch DATABASE_URL values, call reset_engine() first to avoid connection pool conflicts.
from praisonai_platform.db import reset_engine, get_engine

# Switch from SQLite to Postgres
await reset_engine()
engine = get_engine("postgresql+asyncpg://user:pass@host/db")
Use SQLite for development and testing, but switch to PostgreSQL for production workloads. SQLite doesn’t handle concurrent writes well in server environments.
# Development
export DATABASE_URL="sqlite+aiosqlite:///./dev.db"

# Production
export DATABASE_URL="postgresql+asyncpg://user:pass@prod-host/platform"
Always use the get_db dependency in FastAPI routes - it handles session lifecycle, commits, and rollbacks automatically. Don’t create sessions manually.
from fastapi import Depends
from praisonai_platform.api.deps import get_db

@app.get("/workspaces")
async def list_workspaces(session: AsyncSession = Depends(get_db)):
    # Session is auto-managed
    return await workspace_service.list_all(session)

Workspaces

Manage teams and organize work

Issues

Track and manage work items

Agents

Deploy AI agents to workspaces

Authentication

User authentication and sessions