-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
This guide walks you through setting up the OntoKit API for local development. Choose between two deployment modes:
- Full Docker Mode - Everything runs in Docker containers (simpler setup)
- Hybrid Mode - Infrastructure in Docker, API on host (better for debugging)
git clone https://github.com/JohnRDOrazio/ontokit-api.git
cd ontokit-apiThis mode runs everything in Docker, including the API. Best for trying things out quickly.
docker compose up -dThis starts:
- PostgreSQL (port 5432) - Shared database for Zitadel and OntoKit
- Redis (port 6379) - Caching and pub/sub
- MinIO (port 9000/9001) - Object storage
- Zitadel (port 8080/8081) - Identity provider
- OntoKit API (port 8000) - FastAPI backend
Verify all services are running:
docker compose psAll services should show as "healthy" or "running".
docker compose exec api alembic upgrade headRun the setup script to create OIDC applications and configure credentials:
./scripts/setup-zitadel.sh --update-envThis script automatically:
- Waits for Zitadel to be ready
- Creates the "OntoKit" project and OIDC application
- Updates both
ontokit-api/.envandontokit-web/.env.localwith credentials - Prompts to recreate the API container
After the script completes, recreate the API and worker containers to pick up the new credentials:
docker compose up -d --force-recreate api workerSee Authentication for detailed instructions and troubleshooting.
curl http://localhost:8000/health
# Expected: {"status": "healthy"}That's it! The API is ready to use.
This mode runs infrastructure in Docker while the API runs on your host machine. Best for active development with hot reload and IDE debugging.
Use the production compose file which excludes the API service:
docker compose -f compose.prod.yaml up -dThis starts:
- PostgreSQL (port 5432) - Shared database for Zitadel and OntoKit
- Redis (port 6379) - Caching and pub/sub
- MinIO (port 9000/9001) - Object storage
- Zitadel (port 8080/8081) - Identity provider
Verify all services are running:
docker compose -f compose.prod.yaml psAll services should show as "healthy" or "running".
Zitadel takes a moment to initialize. Wait until it's ready:
# Check Zitadel health
curl http://localhost:8080/debug/readyYou should see a 200 OK response.
# Create virtual environment
python -m venv .venv
# Activate it
# On Linux/macOS:
source .venv/bin/activate
# On Windows:
.venv\Scripts\activateYou should see (.venv) in your terminal prompt.
# Install the package with development dependencies
pip install -e ".[dev]"This installs:
- FastAPI, Uvicorn, Pydantic
- SQLAlchemy, asyncpg, Alembic
- RDFLib, OWLReady2
- Development tools (pytest, ruff, mypy)
Copy the example environment file:
cp .env.example .envThe default .env works for hybrid mode (API on host, infrastructure in Docker):
# Database - connects to shared PostgreSQL container
DATABASE_URL=postgresql+asyncpg://ontokit:ontokit@localhost:5432/ontokit
# Redis
REDIS_URL=redis://localhost:6379/0
# MinIO
MINIO_ENDPOINT=localhost:9000
# Zitadel - you'll add client credentials after setup
ZITADEL_ISSUER=http://localhost:8080
ZITADEL_CLIENT_ID=
ZITADEL_CLIENT_SECRET=See Configuration for all available options.
Zitadel needs to be configured with OIDC applications for the API and web frontend.
Run the setup script:
./scripts/setup-zitadel.sh --update-envThis automatically creates the OIDC applications in Zitadel and updates both ontokit-api/.env and ontokit-web/.env.local with the credentials.
Note: If you reset the database with
docker compose down -v, you'll need to run this script again to recreate the applications. See Authentication#Troubleshooting for common issues.
For manual setup instructions, see Authentication#Manual-Setup.
Create the database tables:
alembic upgrade headYou should see output like:
INFO [alembic.runtime.migration] Running upgrade -> abc123, Add projects and project_members tables
uvicorn ontokit.main:app --reload --host 0.0.0.0 --port 8000Or simply:
uvicorn ontokit.main:app --reloadThe API is now running at http://localhost:8000
curl http://localhost:8000/healthExpected response:
{"status": "healthy"}Open http://localhost:8000/docs in your browser to see the interactive Swagger UI.
curl http://localhost:8000/api/v1/projectsExpected response:
{"items": [], "total": 0, "skip": 0, "limit": 20}The stack uses a single PostgreSQL instance with multiple databases:
| Database | User | Purpose |
|---|---|---|
zitadel |
zitadel |
Zitadel identity data |
ontokit |
ontokit |
Application data (projects, ontologies, etc.) |
The scripts/init-db.sh script automatically creates both databases when the PostgreSQL container first starts.
Your development environment is now ready:
| Service | URL |
|---|---|
| OntoKit API | http://localhost:8000 |
| API Docs (Swagger) | http://localhost:8000/docs |
| API Docs (ReDoc) | http://localhost:8000/redoc |
| Zitadel Console | http://localhost:8080/ui/console |
| MinIO Console | http://localhost:9001 |
| Mailpit (Email Testing) | http://localhost:8025 |
Default Zitadel Admin: admin@ontokit.localhost / Admin123!
Ensure Docker services are running:
docker compose ps # or docker compose -f compose.prod.yaml psCheck PostgreSQL is ready:
docker compose logs postgresEnsure the ontokit database exists:
docker compose exec postgres psql -U postgres -c "\l"See Authentication#Troubleshooting for common authentication problems including:
- "App not found" errors
- "Unknown error occurred" on login
- Token validation failures
If you ran docker compose down -v, you need to:
- Start services:
docker compose up -d - Re-run the setup script:
./scripts/setup-zitadel.sh --update-env - Recreate API/worker containers:
docker compose up -d --force-recreate api worker
- Configuration - Customize your environment
- Development - Learn the development workflow
- Authentication - Complete Zitadel setup for user authentication