Vertical lex platform
Koder Lex — Platform Backend
- *rea:*Industry Solutions (Legal)
- *ath:*
products/vertical/lex/engine - *ind:*Go REST API — legal practice management backend
- *ersion:*0.1.0
- *tatus:*Initial release
Role in the stack
products/vertical/lex/engine is the Go backend that powers Koder Lex. It handles authentication via Koder ID PKCE exchange, stores and serves all legal practice data (cases, clients, documents, deadlines, events, time entries, invoices, contracts), and proxies AI queries to ai.koder.dev.
The backend is userscoped: every resource is keyed by the authenticated user's ID, derived from the Koder ID tenant team isolation in v0.1.0 — each attorney sees only their own data.sub claim. There is no multi
Primary couplings
| Module | Relationship |
|---|---|
products/vertical/lex/app |
Primary consumer — Flutter app calls all endpoints |
foundation/id |
PKCE token exchange — POST /oauth/v2/token + GET /api/v1/me with dev.koder.lex client |
ai/gateway |
AI legal assistant queries — POST /v1/chat/completions |
data/kdb (PostgreSQL) |
All legal data persisted in lex_* tables |
Public API (/api/v1)
| Method | Path | Auth | Notes |
|---|---|---|---|
| POST | /auth/koder-id |
— | PKCE code exchange; issues Lex JWT |
| GET | /cases |
JWT | List cases (page, area, status, q) |
| POST | /cases |
JWT | Create case |
| GET | /cases/{id} |
JWT | Get case |
| PUT | /cases/{id} |
JWT | Update case fields |
| GET | /clients |
JWT | List clients (page, q) |
| POST | /clients |
JWT | Create client |
| GET | /documents |
JWT | List documents (case_id filter) |
| GET | /deadlines |
JWT | List deadlines ordered by due_date |
| PUT | /deadlines/{id}/complete |
JWT | Mark deadline completed |
| GET | /events |
JWT | List events (month=YYYY-MM filter) |
| POST | /events |
JWT | Create event |
| GET | /time-entries |
JWT | List time entries (case_id filter) |
| POST | /time-entries |
JWT | Create time entry (auto-computes amount) |
| GET | /invoices |
JWT | List invoices |
| GET | /reports/summary |
JWT | Aggregate stats |
| GET | /contracts |
JWT | List contracts |
| PATCH | /contracts/{id}/status |
JWT | Update contract status |
| POST | /ai/query |
JWT | AI legal assistant (graceful fallback) |
Configuration (environment variables)
| Variable | Default | Description |
|---|---|---|
PORT |
8090 | Server port |
DATABASE_URL |
— | Postgres DSN (overrides DB_* vars) |
JWT_SECRET |
change-me |
HS256 signing key |
KODER_ID_URL |
https://id.koder.dev |
Koder ID base URL |
KODER_ID_CLIENT_ID |
dev.koder.lex |
OIDC client ID |
AI_URL |
https://ai.koder.dev |
AI gateway base URL |
AI_KEY |
— | Bearer token for AI gateway |
Database schema
9 tables: lex_users, lex_cases, lex_clients, lex_documents, lex_deadlines, lex_events, lex_time_entries, lex_invoices, lex_contracts. Migration: migrations/001_initial.sql.