# key1lee/samsara-atlas-llama architecture

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

- Interactive diagram: https://gitdiagram.com/key1lee/samsara-atlas-llama
- Repository: https://github.com/key1lee/samsara-atlas-llama

## Overview

Samsara Atlas is an HR case-workflow platform. An employee or HR partner submits a case through the Streamlit intake or API; the workflow gathers employee context and policy evidence, summarizes the case, drafts a response, and records an HRIS case note. Supporting capabilities include case history and replay, recovery, policy retrieval and indexing, provider diagnostics, auditing, and workflow evaluation. The README documents the end-to-end behavior; some implementation links below rely on SOURCE INDEX references because excerpts are partial.

Main entry points: [`app/engine/steps.py`](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/steps.py) (Workflow steps), [`app/engine/runner.py`](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/runner.py) (Workflow runner), [`app/api/routes.py`](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/api/routes.py) (FastAPI routes), [`app/rag/retrieval.py`](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/retrieval.py) (RAG retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_streamlit["Streamlit intake<br/>[streamlit_app.py]"]
  node_presentation["Case presentation<br/>[presentation.py]"]
  node_api["FastAPI routes<br/>[routes.py]"]
end

subgraph group_workflow["Case workflow"]
  node_runner["Workflow runner<br/>[runner.py]"]
  node_steps["Workflow steps<br/>[steps.py]"]
  node_recovery["Run recovery<br/>[recovery.py]"]
  node_answer_safety["Answer safety<br/>[answer_safety.py]"]
  node_employee_facts["Employee facts<br/>[employee_facts.py]"]
end

subgraph group_policy["Policy retrieval"]
  node_policy_tool["Policy tool<br/>[retrieval.py]"]
  node_lexical_retrieval["Lexical retrieval<br/>[retrieval.py]"]
  node_rag_retrieval["RAG retrieval<br/>[retrieval.py]"]
  node_rag_index[("Policy index<br/>[index.py]")]
  node_rag_documents["Policy documents<br/>[documents.py]"]
  node_embeddings["Embedding provider<br/>[embeddings.py]"]
end

subgraph group_integrations["Tools and providers"]
  node_tool_registry["Tool registry<br/>[registry.py]"]
  node_hris["HRIS tools<br/>[hris.py]"]
  node_provider_factory["Model selection<br/>[factory.py]"]
  node_model_provider["Model provider<br/>[base.py]"]
  node_ollama["Ollama adapter<br/>[ollama.py]"]
end

subgraph group_records["Persistence and operations"]
  node_database[("Database session<br/>[database.py]")]
  node_case_records[("Case records<br/>[models.py]")]
  node_audit["Audit events<br/>[audit.py]"]
  node_diagnostics["Safe diagnostics<br/>[diagnostics.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation["Evaluation subsystem"]
  node_observation["Run observations<br/>[observation.py]"]
  node_contracts["Evaluation contracts<br/>[contracts.py]"]
end

node_hr_user(("Employee or HR"))

node_hr_user -->|"submits case"| node_streamlit
node_streamlit -->|"sends request"| node_api
node_api -->|"starts or replays"| node_runner
node_api -->|"reads case history"| node_case_records
node_runner -->|"executes steps"| node_steps
node_runner -->|"recovers runs"| node_recovery
node_runner -->|"opens sessions"| node_database
node_runner -->|"records events"| node_audit
node_steps -->|"executes tools"| node_tool_registry
node_steps -->|"selects provider"| node_provider_factory
node_steps -->|"checks responses"| node_answer_safety
node_steps -->|"uses facts"| node_employee_facts
node_steps -->|"records failures"| node_diagnostics
node_steps -->|"records retrieval"| node_observation
node_tool_registry -->|"registers tool"| node_hris
node_tool_registry -->|"registers tool"| node_policy_tool
node_hris -->|"reads employee data"| node_database
node_hris -->|"writes case notes"| node_case_records
node_policy_tool -->|"uses semantic mode"| node_rag_retrieval
node_policy_tool -->|"uses lexical mode"| node_lexical_retrieval
node_rag_retrieval -->|"loads sources"| node_rag_documents
node_rag_retrieval -->|"checks index"| node_rag_index
node_rag_retrieval -->|"searches vectors"| node_embeddings
node_provider_factory -->|"creates provider"| node_model_provider
node_ollama -->|"implements interface"| node_model_provider
node_case_records -->|"maps tables"| node_database
node_api -->|"serves benchmarks"| node_evaluation

click node_streamlit "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/ui/streamlit_app.py"
click node_presentation "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/ui/presentation.py"
click node_api "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/api/routes.py"
click node_runner "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/runner.py"
click node_steps "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/steps.py"
click node_recovery "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/recovery.py"
click node_answer_safety "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/answer_safety.py"
click node_employee_facts "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/employee_facts.py"
click node_tool_registry "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/tools/registry.py"
click node_hris "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/tools/hris.py"
click node_policy_tool "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/tools/retrieval.py"
click node_lexical_retrieval "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/tools/retrieval.py"
click node_rag_retrieval "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/retrieval.py"
click node_rag_index "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/index.py"
click node_rag_documents "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/documents.py"
click node_embeddings "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/embeddings.py"
click node_provider_factory "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/providers/factory.py"
click node_model_provider "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/providers/base.py"
click node_ollama "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/providers/ollama.py"
click node_database "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/storage/database.py"
click node_case_records "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/storage/models.py"
click node_audit "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/audit.py"
click node_diagnostics "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/diagnostics.py"
click node_evaluation "https://github.com/key1lee/samsara-atlas-llama/tree/feat/langchain-policy-rag/app/evaluation"
click node_observation "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/evaluation/observation.py"
click node_contracts "https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/evaluation/contracts.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_streamlit,node_presentation,node_api toneBlue
class node_runner,node_steps,node_recovery,node_answer_safety,node_employee_facts toneAmber
class node_policy_tool,node_lexical_retrieval,node_rag_retrieval,node_rag_index,node_rag_documents,node_embeddings toneMint
class node_tool_registry,node_hris,node_provider_factory,node_model_provider,node_ollama toneRose
class node_database,node_case_records,node_audit,node_diagnostics,node_hr_user toneIndigo
class node_evaluation,node_observation,node_contracts toneTeal
```

## Components

### User experience

- [Streamlit intake](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/ui/streamlit_app.py): `ui/streamlit_app.py`
- [Case presentation](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/ui/presentation.py): `ui/presentation.py`
- [FastAPI routes](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/api/routes.py): `app/api/routes.py`

### Case workflow

- [Workflow runner](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/runner.py): `app/engine/runner.py`
- [Workflow steps](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/steps.py): `app/engine/steps.py`
- [Run recovery](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/recovery.py): `app/engine/recovery.py`
- [Answer safety](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/engine/answer_safety.py): `app/engine/answer_safety.py`
- [Employee facts](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/employee_facts.py): `app/employee_facts.py`

### Policy retrieval

- [Policy tool](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/tools/retrieval.py): `app/tools/retrieval.py`
- [Lexical retrieval](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/tools/retrieval.py): `app/tools/retrieval.py`
- [RAG retrieval](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/retrieval.py): `app/rag/retrieval.py`
- [Policy index](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/index.py): `app/rag/index.py`
- [Policy documents](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/documents.py): `app/rag/documents.py`
- [Embedding provider](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/rag/embeddings.py): `app/rag/embeddings.py`

### Tools and providers

- [Tool registry](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/tools/registry.py): `app/tools/registry.py`
- [HRIS tools](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/tools/hris.py): `app/tools/hris.py`
- [Model selection](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/providers/factory.py): `app/providers/factory.py`
- [Model provider](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/providers/base.py): `app/providers/base.py`
- [Ollama adapter](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/providers/ollama.py): `app/providers/ollama.py`

### Persistence and operations

- [Database session](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/storage/database.py): `app/storage/database.py`
- [Case records](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/storage/models.py): `app/storage/models.py`
- [Audit events](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/audit.py): `app/audit.py`
- [Safe diagnostics](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/diagnostics.py): `app/diagnostics.py`

### Evaluation

- [Evaluation subsystem](https://github.com/key1lee/samsara-atlas-llama/tree/feat/langchain-policy-rag/app/evaluation): `app/evaluation`
- [Run observations](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/evaluation/observation.py): `app/evaluation/observation.py`
- [Evaluation contracts](https://github.com/key1lee/samsara-atlas-llama/blob/feat/langchain-policy-rag/app/evaluation/contracts.py): `app/evaluation/contracts.py`

### Other components

- **Employee or HR**

## Connections

- Employee or HR → Streamlit intake: submits case
- Streamlit intake → FastAPI routes: sends request
- FastAPI routes → Workflow runner: starts or replays (evidence: `app/api/routes.py`)
- FastAPI routes → Case records: reads case history (evidence: `app/api/routes.py`)
- Workflow runner → Workflow steps: executes steps (evidence: `app/engine/runner.py`)
- Workflow runner → Run recovery: recovers runs (evidence: `app/engine/runner.py`)
- Workflow runner → Database session: opens sessions (evidence: `app/engine/runner.py`)
- Workflow runner → Audit events: records events (evidence: `app/engine/runner.py`)
- Workflow steps → Tool registry: executes tools (evidence: `app/engine/steps.py`)
- Workflow steps → Model selection: selects provider (evidence: `app/engine/steps.py`)
- Workflow steps → Answer safety: checks responses (evidence: `app/engine/steps.py`)
- Workflow steps → Employee facts: uses facts (evidence: `app/engine/steps.py`)
- Workflow steps → Safe diagnostics: records failures (evidence: `app/engine/steps.py`)
- Workflow steps → Run observations: records retrieval (evidence: `app/engine/steps.py`)
- Tool registry → HRIS tools: registers tool (evidence: `app/tools/registry.py`)
- Tool registry → Policy tool: registers tool (evidence: `app/tools/registry.py`)
- HRIS tools → Database session: reads employee data (evidence: `app/tools/hris.py`)
- HRIS tools → Case records: writes case notes (evidence: `app/tools/hris.py`)
- Policy tool → RAG retrieval: uses semantic mode (evidence: `app/tools/retrieval.py`)
- Policy tool → Lexical retrieval: uses lexical mode (evidence: `app/tools/retrieval.py`)
- RAG retrieval → Policy documents: loads sources (evidence: `app/rag/retrieval.py`)
- RAG retrieval → Policy index: checks index (evidence: `app/rag/retrieval.py`)
- RAG retrieval → Embedding provider: searches vectors (evidence: `app/rag/retrieval.py`)
- Model selection → Model provider: creates provider
- Ollama adapter → Model provider: implements interface (evidence: `app/providers/ollama.py`)
- Case records → Database session: maps tables (evidence: `app/storage/models.py`)
- FastAPI routes → Evaluation subsystem: serves benchmarks (evidence: `app/api/routes.py`)
