Skip to main content
This quickstart uses a real FastAPI codebase:
  • https://github.com/fastapi/full-stack-fastapi-template
Goal:
  1. Scan live OpenAPI.
  2. Generate initial policy artifacts.
  3. Wire policy into route code and write decision logs.
  4. Switch from observe to enforce mode.

1) Boot the FastAPI template

Keep this terminal running. Use a second terminal for the steps below.

2) Pull OpenAPI and generate policy artifacts

From repo root (full-stack-fastapi-template):
Generated files:
  • backend/.kernite/policy-bundle.generated.json
  • backend/.kernite/policy-map.generated.json
  • backend/.kernite/policy-generation-report.json
Coverage check (expected to fail strict initially because source OpenAPI has no x-kernite fields yet):

3) Add one demo deny rule to generated policy

This makes mode switching obvious for one real route: POST /api/v1/users/signup.

4) Wire policy into route code (observe mode)

Create backend/app/core/kernite_guard.py:
Patch backend/app/api/routes/users.py inside register_user(...):
The backend dev server reloads automatically after file changes.

5) Observe mode demo

Run a signup request that should be denied by policy but still allowed in observe mode:
Inspect decision event:
Expected:
  • mode = "observe"
  • decision_raw = "denied"
  • decision_effective = "approved"
  • allow_write = true

6) Enforce mode demo

Restart backend in enforce mode:
Denied request (now blocked):
Approved request:
You now have one complete real-project flow:
  • OpenAPI scan
  • initial policy generation
  • in-code decision logging
  • observe to enforce switch with the same integration contract