Overview
Theweb-api is the primary API backend for the Rapida dashboard. Every request from the browser — authentication, organization setup, assistant management, credential storage — goes through this service. It also acts as the gRPC proxy for downstream services, validating JWT tokens before forwarding requests.
Port
9001 — HTTP · gRPC · gRPC-web (cmux)Language
Go 1.25
Gin (REST) + gRPC
Storage
PostgreSQL
web_db
Redis (session cache)All gRPC-web requests from the browser, except for real-time audio, are routed through
web-api. The service validates the JWT and proxies the request to the correct downstream service using typed gRPC clients from pkg/clients/.Components
Authentication & Session Management
Authentication & Session Management
Handles user registration, login, password recovery, OAuth 2.0 flows, and JWT issuance.
| Feature | Detail |
|---|---|
| Token type | JWT (signed with SECRET, shared across all services) |
| Token storage | Client-side (Authorization header) |
| Session cache | Redis DB 1 |
| OAuth providers | Google, GitHub, Microsoft (configured per deployment) |
| Token expiry | Configurable; default 24 hours |
Organization & Project Hierarchy
Organization & Project Hierarchy
Every resource in Rapida is scoped to an Each entity stores
Organization → Project hierarchy. The web-api enforces this scoping at the gRPC interceptor level.organization_id and project_id via the Organizational base model. The gRPC auth interceptor rejects any request where the JWT’s organization claim does not match the target resource.Credential Vault
Credential Vault
Provider API keys and OAuth tokens are encrypted with AES-256 before storage. The encryption key is derived from
SECRET. The vault is the source of truth for all provider credentials — integration-api reads from it at call time.| Operation | Behavior |
|---|---|
| Store key | AES-256-GCM encrypt → write to web_db |
| Retrieve key | Read from web_db → decrypt in-memory → forward to integration-api |
| Rotate key | Replace ciphertext; existing calls in flight are unaffected |
| Audit | Every vault read/write is logged with user ID and timestamp |
Internal gRPC Proxy
Internal gRPC Proxy
The web-api acts as a proxy for all dashboard gRPC calls. It validates the JWT, extracts the organization context, and forwards to the correct downstream service.
| gRPC Path Prefix | Forwarded To |
|---|---|
/web_api | Local (web-api owns this) |
/vault_api | Local (web-api owns this) |
/workflow_api · /assistant_api | assistant-api:9007 |
/knowledge_api | assistant-api:9007 |
/tool_api · /endpoint_api · /webhook_api | endpoint-api:9005 |
/provider_api · /integration_api | integration-api:9004 |
/connect_api | Local (OAuth connector) |
/document_api | document-api:9010 |
/lead_api | Local |
Entity and Data Model
Entity and Data Model
All entities compose base GORM models:
IDs are generated as Snowflake IDs in the
| Base Model | Fields |
|---|---|
Audited | id (Snowflake), created_at, updated_at |
Mutable | status, created_by, updated_by |
Organizational | project_id, organization_id |
BeforeCreate GORM hook — no UUID dependency. The Snowflake generator is initialized at service startup using the service instance ID.Request Flow
Configuration
Editdocker/web-api/.web.env before starting the service.
Required variables
| Variable | Required | Default | Description |
|---|---|---|---|
SECRET | ✅ Yes | rpd_pks | JWT signing secret — must match all services |
POSTGRES__HOST | ✅ Yes | postgres | PostgreSQL host |
POSTGRES__DB_NAME | ✅ Yes | web_db | Database name |
POSTGRES__AUTH__USER | ✅ Yes | rapida_user | Database user |
POSTGRES__AUTH__PASSWORD | ✅ Yes | — | Database password |
REDIS__HOST | ✅ Yes | redis | Redis host |
INTEGRATION_HOST | ✅ Yes | integration-api:9004 | integration-api gRPC address |
ENDPOINT_HOST | ✅ Yes | endpoint-api:9005 | endpoint-api gRPC address |
ASSISTANT_HOST | ✅ Yes | assistant-api:9007 | assistant-api gRPC address |
DOCUMENT_HOST | ✅ Yes | http://document-api:9010 | document-api HTTP address |
Tuning variables
| Variable | Default | Description |
|---|---|---|
LOG_LEVEL | debug | debug · info · warn · error |
ENV | development | development · staging · production |
POSTGRES__MAX_OPEN_CONNECTION | 10 | Database connection pool size |
POSTGRES__MAX_IDEAL_CONNECTION | 10 | Idle connections to keep open |
REDIS__MAX_CONNECTION | 5 | Redis connection pool size |
ASSET_STORE__STORAGE_TYPE | local | local · s3 · azure |
Full environment file
Running
- Docker Compose
- From Source
Database Migrations
Migrations run automatically at service startup using golang-migrate. Migration files are inapi/web-api/migrations/ and follow sequential naming:
Health & Observability
| Endpoint | Purpose |
|---|---|
GET /readiness/ | Reports whether the service is ready (DB + Redis connected) |
GET /healthz/ | Liveness probe |
Troubleshooting
Service exits immediately on startup
Service exits immediately on startup
The most common cause is PostgreSQL not yet healthy. Check
make logs-web and confirm the postgres container is Up (healthy).JWT validation fails across services
JWT validation fails across services
All services must share the same
SECRET value. Confirm it is identical in .web.env, .assistant.env, .integration.env, and .endpoint.env.OAuth login redirects fail
OAuth login redirects fail
- Ensure
GOOGLE_CLIENT_ID/GITHUB_CLIENT_IDare set in.web.env. - Verify the redirect URI registered with the OAuth provider exactly matches
UI_HOST.
gRPC proxy returns 'service unavailable'
gRPC proxy returns 'service unavailable'