# srinutyson/tracelens architecture

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

- Interactive diagram: https://gitdiagram.com/srinutyson/tracelens
- Repository: https://github.com/srinutyson/tracelens

## Overview

TraceLens captures instrumented application spans, aggregates them into traces, evaluates traces asynchronously with rules or an LLM judge, and presents traces, evaluations, projects, and API keys in a dashboard. Human session authentication and project-scoped SDK-key authentication are separate. The README documents SDK context propagation and the end-to-end ingestion flow; some dashboard and authentication details are only partially sampled, so uncertain internal links are omitted.

Main entry points: [`dashboard/src/App.jsx`](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/App.jsx) (Dashboard routes), [`dashboard/src/api.js`](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/api.js) (Dashboard API client), [`api/routes/Routes.js`](https://github.com/srinutyson/tracelens/blob/main/api/routes/Routes.js) (API routes), [`api/workers/evalWorker.js`](https://github.com/srinutyson/tracelens/blob/main/api/workers/evalWorker.js) (Evaluation worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_instrumentation["Instrumentation"]
  node_sdk["TraceLens SDK<br/>[index.js]"]
  node_exporter["Span exporter<br/>[exporter.js]"]
end

subgraph group_api["API and identity"]
  node_api_routes["API routes<br/>[Routes.js]"]
  node_ingest["Span ingestion"]
  node_span_store[("Span records<br/>[span.js]")]
  node_trace_store[("Trace records<br/>[trace.js]")]
  node_project_controller["Project management"]
  node_project_store[("Project records<br/>[project.js]")]
  node_human_auth["Human authentication<br/>[authController.js]"]
  node_user_store[("User records<br/>[users.js]")]
  node_trace_controller["Trace queries<br/>[traceController.js]"]
end

subgraph group_evaluation["Evaluation"]
  node_eval_controller["Evaluation requests<br/>[evalController.js]"]
  node_eval_store[("Evaluation jobs<br/>[eval.js]")]
  node_eval_worker["Evaluation worker<br/>[evalWorker.js]"]
  node_rule_eval["Rule evaluator<br/>[ruleEvaluator.js]"]
  node_llm_eval["LLM judge<br/>[llmEvaluator.js]"]
end

subgraph group_dashboard["Dashboard"]
  node_app_routes["Dashboard routes<br/>[App.jsx]"]
  node_api_client["Dashboard API client<br/>[api.js]"]
  node_projects_page["Projects and keys<br/>[Projects.jsx]"]
  node_keys_page["API key management<br/>[ApiKeys.jsx]"]
  node_auth_pages["Sign-in and verification<br/>[Login.jsx]"]
  node_signup_page["Signup<br/>[Signup.jsx]"]
  node_otp_page["OTP verification<br/>[VerifyOtp.jsx]"]
  node_trace_list["Trace list<br/>[TraceList.jsx]"]
  node_waterfall["Trace waterfall<br/>[TraceWaterFall.jsx]"]
  node_evaluations_page["Evaluation results<br/>[Evaluations.jsx]"]
end

node_app(("Instrumented app"))
node_email["Email delivery"]
node_dashboard_user(("Dashboard user"))

node_app -->|"instruments"| node_sdk
node_sdk -->|"exports spans"| node_exporter
node_exporter -.->|"posts spans"| node_api_routes
node_api_routes -->|"routes ingestion"| node_ingest
node_ingest -->|"creates spans"| node_span_store
node_ingest -->|"upserts traces"| node_trace_store
node_api_routes -->|"routes projects"| node_project_controller
node_project_controller -->|"reads and writes"| node_project_store
node_human_auth -->|"reads and writes"| node_user_store
node_human_auth -->|"sends verification"| node_email
node_api_routes -->|"routes evaluations"| node_eval_controller
node_eval_controller -->|"queues evaluations"| node_eval_store
node_eval_controller -->|"reads trace"| node_trace_store
node_eval_worker -->|"claims and updates"| node_eval_store
node_eval_worker -->|"loads trace"| node_trace_store
node_eval_worker -->|"loads spans"| node_span_store
node_eval_worker -->|"scores rules"| node_rule_eval
node_eval_worker -->|"scores with judge"| node_llm_eval
node_api_routes -->|"routes trace queries"| node_trace_controller
node_trace_controller -->|"queries traces"| node_trace_store
node_trace_controller -->|"queries spans"| node_span_store
node_trace_controller -->|"queries evaluations"| node_eval_store
node_dashboard_user -.->|"uses dashboard"| node_app_routes
node_app_routes -->|"routes to"| node_projects_page
node_app_routes -->|"routes to"| node_keys_page
node_app_routes -->|"routes to"| node_auth_pages
node_app_routes -->|"routes to"| node_signup_page
node_app_routes -->|"routes to"| node_otp_page
node_app_routes -->|"routes to"| node_trace_list
node_app_routes -->|"routes to"| node_waterfall
node_app_routes -->|"routes to"| node_evaluations_page
node_projects_page -->|"calls API"| node_api_client
node_keys_page -->|"calls API"| node_api_client
node_auth_pages -->|"calls API"| node_api_client
node_signup_page -->|"calls API"| node_api_client
node_otp_page -->|"calls API"| node_api_client
node_trace_list -->|"calls API"| node_api_client
node_waterfall -->|"calls API"| node_api_client
node_evaluations_page -->|"calls API"| node_api_client
node_api_client -.->|"requests backend"| node_api_routes

click node_sdk "https://github.com/srinutyson/tracelens/blob/main/sdk/index.js"
click node_exporter "https://github.com/srinutyson/tracelens/blob/main/sdk/exporter.js"
click node_api_routes "https://github.com/srinutyson/tracelens/blob/main/api/routes/Routes.js"
click node_ingest "https://github.com/srinutyson/tracelens/blob/main/api/controllers/ingestController.js"
click node_span_store "https://github.com/srinutyson/tracelens/blob/main/api/models/span.js"
click node_trace_store "https://github.com/srinutyson/tracelens/blob/main/api/models/trace.js"
click node_project_controller "https://github.com/srinutyson/tracelens/blob/main/api/controllers/projectController.js"
click node_project_store "https://github.com/srinutyson/tracelens/blob/main/api/models/project.js"
click node_human_auth "https://github.com/srinutyson/tracelens/blob/main/api/controllers/authController.js"
click node_user_store "https://github.com/srinutyson/tracelens/blob/main/api/models/users.js"
click node_eval_controller "https://github.com/srinutyson/tracelens/blob/main/api/controllers/evalController.js"
click node_eval_store "https://github.com/srinutyson/tracelens/blob/main/api/models/eval.js"
click node_eval_worker "https://github.com/srinutyson/tracelens/blob/main/api/workers/evalWorker.js"
click node_rule_eval "https://github.com/srinutyson/tracelens/blob/main/api/evalModels/ruleEvaluator.js"
click node_llm_eval "https://github.com/srinutyson/tracelens/blob/main/api/evalModels/llmEvaluator.js"
click node_trace_controller "https://github.com/srinutyson/tracelens/blob/main/api/controllers/traceController.js"
click node_app_routes "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/App.jsx"
click node_api_client "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/api.js"
click node_projects_page "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/Projects.jsx"
click node_keys_page "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/ApiKeys.jsx"
click node_auth_pages "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/Login.jsx"
click node_signup_page "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/Signup.jsx"
click node_otp_page "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/VerifyOtp.jsx"
click node_trace_list "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/TraceList.jsx"
click node_waterfall "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/TraceWaterFall.jsx"
click node_evaluations_page "https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/Evaluations.jsx"

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_sdk,node_exporter,node_dashboard_user toneBlue
class node_api_routes,node_ingest,node_span_store,node_trace_store,node_project_controller,node_project_store,node_human_auth,node_user_store,node_trace_controller toneAmber
class node_eval_controller,node_eval_store,node_eval_worker,node_rule_eval,node_llm_eval toneMint
class node_app_routes,node_api_client,node_projects_page,node_keys_page,node_auth_pages,node_signup_page,node_otp_page,node_trace_list,node_waterfall,node_evaluations_page toneRose
class node_app,node_email toneIndigo
```

## Components

### Instrumentation

- [TraceLens SDK](https://github.com/srinutyson/tracelens/blob/main/sdk/index.js): `sdk/index.js`
- [Span exporter](https://github.com/srinutyson/tracelens/blob/main/sdk/exporter.js): `sdk/exporter.js`

### API and identity

- [API routes](https://github.com/srinutyson/tracelens/blob/main/api/routes/Routes.js): `api/routes/Routes.js`
- [Span ingestion](https://github.com/srinutyson/tracelens/blob/main/api/controllers/ingestController.js): `api/controllers/ingestController.js`
- [Span records](https://github.com/srinutyson/tracelens/blob/main/api/models/span.js): `api/models/span.js`
- [Trace records](https://github.com/srinutyson/tracelens/blob/main/api/models/trace.js): `api/models/trace.js`
- [Project management](https://github.com/srinutyson/tracelens/blob/main/api/controllers/projectController.js): `api/controllers/projectController.js`
- [Project records](https://github.com/srinutyson/tracelens/blob/main/api/models/project.js): `api/models/project.js`
- [Human authentication](https://github.com/srinutyson/tracelens/blob/main/api/controllers/authController.js): `api/controllers/authController.js`
- [User records](https://github.com/srinutyson/tracelens/blob/main/api/models/users.js): `api/models/users.js`
- [Trace queries](https://github.com/srinutyson/tracelens/blob/main/api/controllers/traceController.js): `api/controllers/traceController.js`

### Evaluation

- [Evaluation requests](https://github.com/srinutyson/tracelens/blob/main/api/controllers/evalController.js): `api/controllers/evalController.js`
- [Evaluation jobs](https://github.com/srinutyson/tracelens/blob/main/api/models/eval.js): `api/models/eval.js`
- [Evaluation worker](https://github.com/srinutyson/tracelens/blob/main/api/workers/evalWorker.js): `api/workers/evalWorker.js`
- [Rule evaluator](https://github.com/srinutyson/tracelens/blob/main/api/evalModels/ruleEvaluator.js): `api/evalModels/ruleEvaluator.js`
- [LLM judge](https://github.com/srinutyson/tracelens/blob/main/api/evalModels/llmEvaluator.js): `api/evalModels/llmEvaluator.js`

### Dashboard

- [Dashboard routes](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/App.jsx): `dashboard/src/App.jsx`
- [Dashboard API client](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/api.js): `dashboard/src/api.js`
- [Projects and keys](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/Projects.jsx): `dashboard/src/pages/Projects.jsx`
- [API key management](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/ApiKeys.jsx): `dashboard/src/pages/ApiKeys.jsx`
- [Sign-in and verification](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/Login.jsx): `dashboard/src/pages/Login.jsx`
- [Signup](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/Signup.jsx): `dashboard/src/pages/Signup.jsx`
- [OTP verification](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/VerifyOtp.jsx): `dashboard/src/pages/VerifyOtp.jsx`
- [Trace list](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/TraceList.jsx): `dashboard/src/pages/TraceList.jsx`
- [Trace waterfall](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/TraceWaterFall.jsx): `dashboard/src/pages/TraceWaterFall.jsx`
- [Evaluation results](https://github.com/srinutyson/tracelens/blob/main/dashboard/src/pages/Evaluations.jsx): `dashboard/src/pages/Evaluations.jsx`

### Other components

- **Instrumented app**
- **Email delivery**
- **Dashboard user**

## Connections

- Instrumented app → TraceLens SDK: instruments (evidence: `README.md`)
- TraceLens SDK → Span exporter: exports spans (evidence: `sdk/index.js`)
- Span exporter → API routes: posts spans (evidence: `README.md`)
- API routes → Span ingestion: routes ingestion (evidence: `api/routes/Routes.js`)
- Span ingestion → Span records: creates spans (evidence: `api/controllers/ingestController.js`)
- Span ingestion → Trace records: upserts traces (evidence: `api/controllers/ingestController.js`)
- API routes → Project management: routes projects (evidence: `api/routes/Routes.js`)
- Project management → Project records: reads and writes (evidence: `api/controllers/projectController.js`)
- Human authentication → User records: reads and writes (evidence: `api/controllers/authController.js`)
- Human authentication → Email delivery: sends verification (evidence: `api/controllers/authController.js`)
- API routes → Evaluation requests: routes evaluations (evidence: `api/routes/Routes.js`)
- Evaluation requests → Evaluation jobs: queues evaluations (evidence: `api/controllers/evalController.js`)
- Evaluation requests → Trace records: reads trace (evidence: `api/controllers/evalController.js`)
- Evaluation worker → Evaluation jobs: claims and updates (evidence: `api/workers/evalWorker.js`)
- Evaluation worker → Trace records: loads trace (evidence: `api/workers/evalWorker.js`)
- Evaluation worker → Span records: loads spans (evidence: `api/workers/evalWorker.js`)
- Evaluation worker → Rule evaluator: scores rules (evidence: `api/workers/evalWorker.js`)
- Evaluation worker → LLM judge: scores with judge (evidence: `api/workers/evalWorker.js`)
- API routes → Trace queries: routes trace queries (evidence: `api/routes/Routes.js`)
- Trace queries → Trace records: queries traces (evidence: `api/controllers/traceController.js`)
- Trace queries → Span records: queries spans (evidence: `api/controllers/traceController.js`)
- Trace queries → Evaluation jobs: queries evaluations (evidence: `api/controllers/traceController.js`)
- Dashboard user → Dashboard routes: uses dashboard
- Dashboard routes → Projects and keys: routes to (evidence: `dashboard/src/App.jsx`)
- Dashboard routes → API key management: routes to (evidence: `dashboard/src/App.jsx`)
- Dashboard routes → Sign-in and verification: routes to (evidence: `dashboard/src/App.jsx`)
- Dashboard routes → Signup: routes to (evidence: `dashboard/src/App.jsx`)
- Dashboard routes → OTP verification: routes to (evidence: `dashboard/src/App.jsx`)
- Dashboard routes → Trace list: routes to (evidence: `dashboard/src/App.jsx`)
- Dashboard routes → Trace waterfall: routes to (evidence: `dashboard/src/App.jsx`)
- Dashboard routes → Evaluation results: routes to (evidence: `dashboard/src/App.jsx`)
- Projects and keys → Dashboard API client: calls API (evidence: `dashboard/src/pages/Projects.jsx`)
- API key management → Dashboard API client: calls API (evidence: `dashboard/src/pages/ApiKeys.jsx`)
- Sign-in and verification → Dashboard API client: calls API (evidence: `dashboard/src/pages/Login.jsx`)
- Signup → Dashboard API client: calls API (evidence: `dashboard/src/pages/Signup.jsx`)
- OTP verification → Dashboard API client: calls API (evidence: `dashboard/src/pages/VerifyOtp.jsx`)
- Trace list → Dashboard API client: calls API (evidence: `dashboard/src/pages/TraceList.jsx`)
- Trace waterfall → Dashboard API client: calls API (evidence: `dashboard/src/pages/TraceWaterFall.jsx`)
- Evaluation results → Dashboard API client: calls API (evidence: `dashboard/src/pages/Evaluations.jsx`)
- Dashboard API client → API routes: requests backend (evidence: `README.md`)
