# manojkesani/rln architecture

> Architecture diagram of the GitHub repository manojkesani/rln, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manojkesani/rln
- Repository: https://github.com/manojkesani/rln

## Overview

Trillian is a browser-based chat application backed by a FastAPI service. A user authenticates, selects a model, creates or opens a conversation, and sends turns that the API runs through an agent before returning a reply (optionally streamed). Conversation metadata, agent checkpoints, and per-model-call usage are distinct state paths. The graph follows the documented router and service wiring; several frontend-to-API and external-provider links are not visible in the supplied excerpts, so they are omitted or marked unverified.

Main entry points: [`apps/api/app/main.py`](https://github.com/manojkesani/rln/blob/master/apps/api/app/main.py) (FastAPI app), [`apps/api/app/services/chat.py`](https://github.com/manojkesani/rln/blob/master/apps/api/app/services/chat.py) (Conversation service), [`apps/web/src/App.tsx`](https://github.com/manojkesani/rln/blob/master/apps/web/src/App.tsx) (Route app), [`apps/api/app/routers/conversations.py`](https://github.com/manojkesani/rln/blob/master/apps/api/app/routers/conversations.py) (Conversation routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Route app<br/>[App.tsx]"]
  node_authui["Login page<br/>[LoginPage.tsx]"]
  node_guard["Auth guard<br/>[RequireAuth.tsx]"]
  node_chatui["Chat page<br/>[ChatPage.tsx]"]
  node_apiclient["API client<br/>[client.ts]"]
  node_sse["SSE parser<br/>[sse.ts]"]
end

subgraph group_api["API and domain services"]
  node_api["FastAPI app<br/>[main.py]"]
  node_authroutes["Auth routes<br/>[auth.py]"]
  node_authservice["Auth service<br/>[auth.py]"]
  node_convroutes["Conversation routes<br/>[conversations.py]"]
  node_chatservice["Conversation service<br/>[chat.py]"]
  node_streaming["Stream service<br/>[streaming.py]"]
  node_usageservice["Usage service<br/>[usage.py]"]
  node_modelroutes["Model routes<br/>[models.py]"]
end

subgraph group_models["Model execution"]
  node_catalog["Model catalog<br/>[catalog.py]"]
  node_factory["Model factory<br/>[factory.py]"]
  node_providers["Provider adapters<br/>[providers.py]"]
  node_agent["Agent builder<br/>[builder.py]"]
  node_callbacks["Usage callbacks<br/>[callbacks.py]"]
end

subgraph group_state["Persistence and observability"]
  node_conversationdb[("Conversation records<br/>[conversation.py]")]
  node_llmcalldb[("Model-call records<br/>[llm_call.py]")]
  node_checkpointer[("Agent checkpoints<br/>[checkpointer.py]")]
  node_session["DB sessions<br/>[session.py]"]
  node_tracing["Tracing setup<br/>[tracing.py]"]
end

node_user(("User"))
node_phoenix["Phoenix collector"]
node_provider_services["LLM providers"]

node_user -.->|"uses"| node_webapp
node_webapp -->|"routes to"| node_authui
node_webapp -->|"protects route"| node_guard
node_webapp -->|"routes to"| node_chatui
node_chatui -.->|"requests"| node_apiclient
node_chatui -.->|"parses stream"| node_sse
node_user -.->|"sends requests"| node_api
node_api -->|"mounts"| node_authroutes
node_api -->|"mounts"| node_convroutes
node_api -->|"mounts"| node_modelroutes
node_api -->|"sets up"| node_tracing
node_api -->|"opens"| node_checkpointer
node_authroutes -->|"calls"| node_authservice
node_convroutes -->|"calls"| node_chatservice
node_convroutes -->|"calls"| node_streaming
node_convroutes -->|"calls"| node_usageservice
node_modelroutes -->|"queries"| node_catalog
node_chatservice -->|"builds model"| node_factory
node_chatservice -->|"builds agent"| node_agent
node_chatservice -->|"registers"| node_callbacks
node_chatservice -->|"reads and writes"| node_conversationdb
node_chatservice -->|"loads history"| node_checkpointer
node_streaming -->|"builds model"| node_factory
node_streaming -->|"runs agent"| node_agent
node_streaming -->|"registers"| node_callbacks
node_usageservice -->|"reads usage"| node_llmcalldb
node_catalog -->|"uses"| node_providers
node_factory -->|"selects"| node_providers
node_callbacks -->|"opens session"| node_session
node_callbacks -->|"writes records"| node_llmcalldb
node_session -.->|"persists"| node_conversationdb
node_session -.->|"persists"| node_llmcalldb
node_agent -->|"saves state"| node_checkpointer
node_tracing -.->|"exports traces"| node_phoenix
node_providers -.->|"calls models"| node_provider_services

click node_webapp "https://github.com/manojkesani/rln/blob/master/apps/web/src/App.tsx"
click node_authui "https://github.com/manojkesani/rln/blob/master/apps/web/src/pages/LoginPage.tsx"
click node_guard "https://github.com/manojkesani/rln/blob/master/apps/web/src/components/RequireAuth.tsx"
click node_chatui "https://github.com/manojkesani/rln/blob/master/apps/web/src/pages/ChatPage.tsx"
click node_apiclient "https://github.com/manojkesani/rln/blob/master/apps/web/src/api/client.ts"
click node_sse "https://github.com/manojkesani/rln/blob/master/apps/web/src/lib/sse.ts"
click node_api "https://github.com/manojkesani/rln/blob/master/apps/api/app/main.py"
click node_authroutes "https://github.com/manojkesani/rln/blob/master/apps/api/app/routers/auth.py"
click node_authservice "https://github.com/manojkesani/rln/blob/master/apps/api/app/services/auth.py"
click node_convroutes "https://github.com/manojkesani/rln/blob/master/apps/api/app/routers/conversations.py"
click node_chatservice "https://github.com/manojkesani/rln/blob/master/apps/api/app/services/chat.py"
click node_streaming "https://github.com/manojkesani/rln/blob/master/apps/api/app/services/streaming.py"
click node_usageservice "https://github.com/manojkesani/rln/blob/master/apps/api/app/services/usage.py"
click node_modelroutes "https://github.com/manojkesani/rln/blob/master/apps/api/app/routers/models.py"
click node_catalog "https://github.com/manojkesani/rln/blob/master/apps/api/app/llm/catalog.py"
click node_factory "https://github.com/manojkesani/rln/blob/master/apps/api/app/llm/factory.py"
click node_providers "https://github.com/manojkesani/rln/blob/master/apps/api/app/llm/providers.py"
click node_agent "https://github.com/manojkesani/rln/blob/master/apps/api/app/agents/builder.py"
click node_callbacks "https://github.com/manojkesani/rln/blob/master/apps/api/app/llm/callbacks.py"
click node_conversationdb "https://github.com/manojkesani/rln/blob/master/apps/api/app/db/models/conversation.py"
click node_llmcalldb "https://github.com/manojkesani/rln/blob/master/apps/api/app/db/models/llm_call.py"
click node_checkpointer "https://github.com/manojkesani/rln/blob/master/apps/api/app/db/checkpointer.py"
click node_session "https://github.com/manojkesani/rln/blob/master/apps/api/app/db/session.py"
click node_tracing "https://github.com/manojkesani/rln/blob/master/apps/api/app/tracing.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_authui,node_guard,node_chatui,node_apiclient,node_sse,node_user toneBlue
class node_api,node_authroutes,node_authservice,node_convroutes,node_chatservice,node_streaming,node_usageservice,node_modelroutes toneAmber
class node_catalog,node_factory,node_providers,node_agent,node_callbacks toneMint
class node_conversationdb,node_llmcalldb,node_checkpointer,node_session,node_tracing toneRose
class node_phoenix,node_provider_services toneIndigo
```

## Components

### Web application

- [Route app](https://github.com/manojkesani/rln/blob/master/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Login page](https://github.com/manojkesani/rln/blob/master/apps/web/src/pages/LoginPage.tsx): `apps/web/src/pages/LoginPage.tsx`
- [Auth guard](https://github.com/manojkesani/rln/blob/master/apps/web/src/components/RequireAuth.tsx): `apps/web/src/components/RequireAuth.tsx`
- [Chat page](https://github.com/manojkesani/rln/blob/master/apps/web/src/pages/ChatPage.tsx): `apps/web/src/pages/ChatPage.tsx`
- [API client](https://github.com/manojkesani/rln/blob/master/apps/web/src/api/client.ts): `apps/web/src/api/client.ts`
- [SSE parser](https://github.com/manojkesani/rln/blob/master/apps/web/src/lib/sse.ts): `apps/web/src/lib/sse.ts`

### API and domain services

- [FastAPI app](https://github.com/manojkesani/rln/blob/master/apps/api/app/main.py): `apps/api/app/main.py`
- [Auth routes](https://github.com/manojkesani/rln/blob/master/apps/api/app/routers/auth.py): `apps/api/app/routers/auth.py`
- [Auth service](https://github.com/manojkesani/rln/blob/master/apps/api/app/services/auth.py): `apps/api/app/services/auth.py`
- [Conversation routes](https://github.com/manojkesani/rln/blob/master/apps/api/app/routers/conversations.py): `apps/api/app/routers/conversations.py`
- [Conversation service](https://github.com/manojkesani/rln/blob/master/apps/api/app/services/chat.py): `apps/api/app/services/chat.py`
- [Stream service](https://github.com/manojkesani/rln/blob/master/apps/api/app/services/streaming.py): `apps/api/app/services/streaming.py`
- [Usage service](https://github.com/manojkesani/rln/blob/master/apps/api/app/services/usage.py): `apps/api/app/services/usage.py`
- [Model routes](https://github.com/manojkesani/rln/blob/master/apps/api/app/routers/models.py): `apps/api/app/routers/models.py`

### Model execution

- [Model catalog](https://github.com/manojkesani/rln/blob/master/apps/api/app/llm/catalog.py): `apps/api/app/llm/catalog.py`
- [Model factory](https://github.com/manojkesani/rln/blob/master/apps/api/app/llm/factory.py): `apps/api/app/llm/factory.py`
- [Provider adapters](https://github.com/manojkesani/rln/blob/master/apps/api/app/llm/providers.py): `apps/api/app/llm/providers.py`
- [Agent builder](https://github.com/manojkesani/rln/blob/master/apps/api/app/agents/builder.py): `apps/api/app/agents/builder.py`
- [Usage callbacks](https://github.com/manojkesani/rln/blob/master/apps/api/app/llm/callbacks.py): `apps/api/app/llm/callbacks.py`

### Persistence and observability

- [Conversation records](https://github.com/manojkesani/rln/blob/master/apps/api/app/db/models/conversation.py): `apps/api/app/db/models/conversation.py`
- [Model-call records](https://github.com/manojkesani/rln/blob/master/apps/api/app/db/models/llm_call.py): `apps/api/app/db/models/llm_call.py`
- [Agent checkpoints](https://github.com/manojkesani/rln/blob/master/apps/api/app/db/checkpointer.py): `apps/api/app/db/checkpointer.py`
- [DB sessions](https://github.com/manojkesani/rln/blob/master/apps/api/app/db/session.py): `apps/api/app/db/session.py`
- [Tracing setup](https://github.com/manojkesani/rln/blob/master/apps/api/app/tracing.py): `apps/api/app/tracing.py`

### Other components

- **User**
- **Phoenix collector**
- **LLM providers**

## Connections

- User → Route app: uses
- Route app → Login page: routes to (evidence: `apps/web/src/App.tsx`)
- Route app → Auth guard: protects route (evidence: `apps/web/src/App.tsx`)
- Route app → Chat page: routes to (evidence: `apps/web/src/App.tsx`)
- Chat page → API client: requests
- Chat page → SSE parser: parses stream
- User → FastAPI app: sends requests
- FastAPI app → Auth routes: mounts (evidence: `apps/api/app/main.py`)
- FastAPI app → Conversation routes: mounts (evidence: `apps/api/app/main.py`)
- FastAPI app → Model routes: mounts (evidence: `apps/api/app/main.py`)
- FastAPI app → Tracing setup: sets up (evidence: `apps/api/app/main.py`)
- FastAPI app → Agent checkpoints: opens (evidence: `apps/api/app/main.py`)
- Auth routes → Auth service: calls (evidence: `apps/api/app/routers/auth.py`)
- Conversation routes → Conversation service: calls (evidence: `apps/api/app/routers/conversations.py`)
- Conversation routes → Stream service: calls (evidence: `apps/api/app/routers/conversations.py`)
- Conversation routes → Usage service: calls (evidence: `apps/api/app/routers/conversations.py`)
- Model routes → Model catalog: queries (evidence: `apps/api/app/routers/models.py`)
- Conversation service → Model factory: builds model (evidence: `apps/api/app/services/chat.py`)
- Conversation service → Agent builder: builds agent (evidence: `apps/api/app/services/chat.py`)
- Conversation service → Usage callbacks: registers (evidence: `apps/api/app/services/chat.py`)
- Conversation service → Conversation records: reads and writes (evidence: `apps/api/app/services/chat.py`)
- Conversation service → Agent checkpoints: loads history (evidence: `apps/api/app/services/chat.py`)
- Stream service → Model factory: builds model (evidence: `apps/api/app/services/streaming.py`)
- Stream service → Agent builder: runs agent (evidence: `apps/api/app/services/streaming.py`)
- Stream service → Usage callbacks: registers (evidence: `apps/api/app/services/streaming.py`)
- Usage service → Model-call records: reads usage (evidence: `apps/api/app/services/usage.py`)
- Model catalog → Provider adapters: uses (evidence: `apps/api/app/llm/catalog.py`)
- Model factory → Provider adapters: selects (evidence: `apps/api/app/llm/factory.py`)
- Usage callbacks → DB sessions: opens session (evidence: `apps/api/app/llm/callbacks.py`)
- Usage callbacks → Model-call records: writes records (evidence: `apps/api/app/llm/callbacks.py`)
- DB sessions → Conversation records: persists
- DB sessions → Model-call records: persists
- Agent builder → Agent checkpoints: saves state (evidence: `apps/api/app/agents/builder.py`)
- Tracing setup → Phoenix collector: exports traces
- Provider adapters → LLM providers: calls models
