UASAM — user, auth, and agent management
UASAM runs on port 8000 and is the control plane for everything that is not an event. It handles:- User accounts — sign-up, login, profile editing, and password updates. Passwords are hashed; JWTs are issued with PyJWT and returned as
X-OTAS-USER-TOKEN. - Projects — a named container for agents and their event data. When you create a project, OTAS creates a
UserProjectMappingrecord that binds you to the project with Admin privilege (1). Members can be added with privilege2. - Agents — registered AI systems within a project. Each agent has a name, description, and provider (for example,
Anthropic). Only project Admins can create agents. - AgentKeys — time-limited keys (valid 30 days) scoped to a single agent. They use the format
agent_<prefix>_<secret>and are stored as bcrypt hashes. Keys are used asX-OTAS-AGENT-KEYand never returned after initial creation. - Agent sessions — ephemeral sessions created by an agent at the start of each run. UASAM issues a session JWT (
X-OTAS-AGENT-SESSION-TOKEN) that Brain validates on every log request. - Backend SDK keys — project-scoped keys (
otas_<prefix>_<secret>) used by server-side SDK integrations.
Brain — event capture and analytics
Brain runs on port 8002 and is the data plane. It accepts event logs from two sources:- Backend SDK —
POST /api/v1/backend/log/sdk/authenticated withX-OTAS-SDK-KEY+X-OTAS-AGENT-SESSION-TOKEN - Agent direct —
POST /api/v1/backend/log/agent/authenticated withX-OTAS-AGENT-KEY+X-OTAS-AGENT-SESSION-TOKEN
BackendEvent record. Brain validates the session token against UASAM before writing, then hands off to Celery for async processing. The analytics endpoints query BackendEvent directly:
GET /api/v1/agent/path-timeseries/— request counts per path over timeGET /api/v1/agent/session/events/— all events for a specific sessionGET /api/v1/agent/latency-percentiles/— daily p50 / p95 / p99 per agentGET /api/v1/agent/error-count/— daily error counts over a requested date range
BackendEvent model fields
Each event logged to Brain is stored as aBackendEvent row with the following fields:
| Field | Type | Description |
|---|---|---|
event_id | UUID | Primary key, auto-generated |
event_time | DateTimeField | When the event occurred (indexed) |
event_date | DateField | Derived from event_time; used for daily analytics queries |
project_id | CharField | UUID of the project this event belongs to |
agent_id | CharField | UUID of the agent (optional) |
agent_session_id | CharField | UUID of the agent session (optional) |
path | TextField | The API path called (indexed) |
method | CharField | HTTP method (GET, POST, etc.) |
status_code | PositiveIntegerField | HTTP response status code |
latency_ms | FloatField | Round-trip time in milliseconds |
request_size_bytes | PositiveIntegerField | Size of the request payload |
response_size_bytes | PositiveIntegerField | Size of the response payload |
request_headers | TextField | Serialized request headers |
request_body | TextField | Request body |
query_params | TextField | URL query string |
response_headers | TextField | Serialized response headers |
response_body | TextField | Response body |
request_content_type | CharField | MIME type of the request |
response_content_type | CharField | MIME type of the response |
custom_properties | JSONField | Arbitrary key-value data you attach |
error | TextField | Error message if the call failed |
metadata | JSONField | Additional structured metadata |
Frontend — React dashboard
The frontend runs on port 5173 (Vite dev server) and is built with React 19, MUI 7, and React Router 7. It connects to UASAM and Brain using two hardcoded base URLs insrc/constants.ts:
- Project and agent creation and management
- Agent key creation and revocation
- Session list with per-session event drill-down
- Path timeseries charts (request counts by path over time)
- Latency percentile charts (daily p50, p95, p99)
- Error count charts (configurable date range)
Data flow
The sequence below shows how a single agent run moves through the system:- Agent calls UASAM —
POST /api/agent/v1/session/create/withX-OTAS-AGENT-KEY. UASAM validates the key, creates anAgentSessionrecord, and returns a session JWT. - Agent makes API calls — for in-domain calls, the agent attaches
X-OTAS-AGENT-SESSION-TOKENto every request so the backend SDK can intercept and log them automatically. - Agent logs external calls — for out-of-domain calls, the agent logs each request to Brain after it completes via
POST /api/v1/backend/log/agent/. - Brain stores events — Brain validates the session token, writes a
BackendEventrow, and queues async post-processing in Celery. - User views analytics — the frontend queries Brain’s analytics endpoints and renders charts and session views in the dashboard.
Port reference
| Service | Port |
|---|---|
| UASAM API | 8000 |
| Brain API | 8002 |
| Frontend | 5173 |
| UASAM PostgreSQL | 5432 |
| Brain PostgreSQL | 5433 |
| UASAM Redis | 6379 |
| Brain Redis | 6378 |
Project privilege model
UserProjectMapping assigns each user a privilege level within a project:
| Value | Label | Permissions |
|---|---|---|
1 | Admin | Create agents, create and revoke keys, manage project members |
2 | Member | View agents, sessions, and analytics; no write access to keys |