This tutorial walks you through building a complete, production-ready backend with Kirak. By the end, you will understand the core mental model and have a running API with authentication, data validation, row-level security, and schema migrations.
The application we will build is a Task Manager API where authenticated users create, view, search, and update their own tasks, while administrators have full oversight.
Note (Database Settings in kirak.json):
Because you passed --database when creating the project, kirak.json already has the correct database engine and port configured.
If you are using PostgreSQL or MySQL, check the "database" block in kirak.json to verify the host ("localhost"), database name ("task_api"), and username ("postgres" for PostgreSQL, "task_api_app" for MySQL). For SQLite, no database settings need to be modified.
Kirak Core manages all authentication tables automatically (users, auth_tokens, auth_social, auth_mfa, and auth_otp). They are automatically generated in migrations — you do not define them.
When an API request arrives, it flows through Kirak’s security pipeline automatically. No CRUD endpoints or permission checks need to be manually coded:
soft_delete: true: When a record is deleted, Kirak sets deleted_at instead of dropping the row. Soft-deleted tasks are invisible to fetch, search, and count queries.
enum on status: Enforces validation at the API boundary. Submitting any value other than "pending", "in_progress", or "done" returns an immediate 400 VALIDATION_ERROR.
searchable: true on title: Enables text search via GET /tasks/search.
Deny-by-default Access: If an operation or role is not explicitly listed in "access", requests are rejected with 403 PERMISSION_DENIED. Notice that hard deletion (destroy) is restricted to the admin role.
Row-Level Security (condition): Kirak appends an SQL WHERE user_id = <token_user_id> clause automatically. Regular users only ever see and modify their own tasks.
Automatic Ownership Injection: On create, Kirak extracts user_id from the caller’s JWT claims and injects it into the INSERT. Clients cannot forge another user’s ID.
Important — Check Your Server Terminal Log:
Until a production email provider is configured, Kirak prints the email verification link directly to the terminal running Uvicorn:
[kirak] No verification email was sent for alice@example.com. Open this link to verify the account:
http://localhost:8000/auth/verify-email?token=...
Copy and open that link in your web browser, then press Verify my email to verify Alice’s account before attempting to log in.
Kirak runs anywhere Python does. To share the API without setting up a server, kirak deploy puts the
project on Kirak’s hosting in one command, with no account and no email:
Terminal window
kirakdeploy
Deployed: https://<your-app>...
Claim URL: https://...
Run 'kirak deploy claim-code' to retrieve your claim code.
Custom Python found (1 file). Until you claim this instance, custom endpoints answer 403 INSTANCE_NOT_CLAIMED, and hooks, tools and tasks don't run.
The deploy runs kirak validate first, sends the project’s files (never .env or kirak.local.json) and
its secrets from .env, and prints the public URL. It also prints:
A claim link. An unclaimed instance is temporary. Open the link, sign in, and enter the 8-character
claim code from kirak deploy claim-code to make the instance yours and keep it running. After five
wrong codes the claim locks; kirak deploy claim-code --new makes a new code and unlocks it.
When it expires, while it is unclaimed, and anything an unclaimed instance does not run yet.
Run kirak deploy again from the same folder to update the same instance: the CLI keeps its state in
.kirak/project.json (commit it) and its credentials in .kirak/deploy.json (never commit it; the CLI
adds it to .gitignore). After claiming, kirak login lets you deploy from any machine.
How long an unclaimed instance lives, and what the free tier includes: kirak.io/deploy.
Every option of the command: kirak deploy.
You have experienced the complete Kirak development cycle: declare schema $\rightarrow$ migrate $\rightarrow$ secure $\rightarrow$ extend with hooks $\rightarrow$ evolve.