-
Notifications
You must be signed in to change notification settings - Fork 0
Development
John R. D'Orazio edited this page Feb 18, 2026
·
3 revisions
This guide covers the development workflow for the OntoKit API.
# Activate virtual environment
source .venv/bin/activate
# Start with auto-reload
uvicorn ontokit.main:app --reloadThe server will automatically restart when you modify Python files.
uvicorn ontokit.main:app --reload --host 0.0.0.0 --port 8000# Set DEBUG=true in .env, or:
DEBUG=true uvicorn ontokit.main:app --reload# Check for issues
ruff check ontokit/
# Auto-fix issues
ruff check --fix .
# Format code
ruff format ontokit/mypy ontokit/# Run linting, formatting check, and type checking
ruff check ontokit/
ruff format --check ontokit/
mypy ontokit/pytestpytest --cov=ontokit --cov-report=term-missingpytest tests/test_projects.pypytest tests/test_projects.py::test_create_projectpytest -vontokit-api/
├── ontokit/ # Application source code
│ ├── __init__.py
│ ├── main.py # FastAPI application entry point
│ ├── runner.py # CLI entry point
│ ├── version.py # Version management
│ ├── worker.py # ARQ background job queue
│ ├── api/routes/ # API routes
│ │ ├── auth.py # Authentication endpoints
│ │ ├── projects.py # Project management
│ │ ├── ontologies.py # Ontology CRUD
│ │ ├── classes.py # OWL class operations
│ │ └── ...
│ ├── core/ # Core functionality
│ │ ├── config.py # Settings (Pydantic)
│ │ ├── database.py # Database connection
│ │ └── auth.py # JWT validation
│ ├── models/ # SQLAlchemy models
│ ├── schemas/ # Pydantic schemas
│ ├── services/ # Business logic
│ ├── git/ # Git repository management (pygit2)
│ └── collab/ # WebSocket collaboration
├── alembic/ # Database migrations
├── tests/
├── scripts/
│ └── setup-zitadel.sh # Zitadel setup script
├── .env # Environment variables (not in git)
├── .env.example
├── alembic.ini
├── compose.yaml # Docker Compose (full stack)
├── compose.prod.yaml # Docker Compose (infrastructure only)
└── pyproject.toml # Project configuration
-
Create/update the schema in
ontokit/schemas/ -
Create/update the service in
ontokit/services/ -
Create/update the router in
ontokit/api/routes/ -
Register the router in
ontokit/api/routes/__init__.py
-
Create the model in
ontokit/models/ -
Export it in
ontokit/models/__init__.py - Create a migration (see Database)
-
Create corresponding schemas in
ontokit/schemas/
# 1. ontokit/models/comment.py
from sqlalchemy.orm import Mapped, mapped_column
from ontokit.core.database import Base
class Comment(Base):
__tablename__ = "comments"
id: Mapped[int] = mapped_column(primary_key=True)
content: Mapped[str]
# ...
# 2. ontokit/models/__init__.py
from ontokit.models.comment import Comment
__all__ = [..., "Comment"]
# 3. Generate migration
# alembic revision --autogenerate -m "Add comments table"
# 4. ontokit/schemas/comment.py
from pydantic import BaseModel
class CommentCreate(BaseModel):
content: str
class CommentResponse(CommentCreate):
id: int
class Config:
from_attributes = TrueThe API documentation is automatically generated:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/openapi.json
import logging
logger = logging.getLogger(__name__)
logger.info("Debug message: %s", variable)
logger.debug("Detailed debug info")- Install debugpy:
pip install debugpy - Add to your VS Code launch.json:
{
"name": "FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": ["app.main:app", "--reload"],
"jinja": true
}# Start Python with app context
python
>>> from ontokit.core.database import async_session_maker
>>> from ontokit.models import Project
>>> import asyncio
>>> # ... interactive debuggingdocker compose restart# All services
docker compose logs -f
# Specific service
docker compose logs -f postgres# Stop services and remove volumes
docker compose down -v
# Restart
docker compose up -d
# Re-run migrations
alembic upgrade head# Update all dependencies
pip install -U -e ".[dev]"
# Update specific package
pip install -U fastapi- Database - Learn about migrations
- API Reference - See available endpoints
- Project Structure - Understand the codebase organization