# mukulsinghal407/tiktoktechjam architecture

> Architecture diagram of the GitHub repository mukulsinghal407/tiktoktechjam, 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/mukulsinghal407/tiktoktechjam
- Repository: https://github.com/mukulsinghal407/tiktoktechjam

## Overview

TikTalk is a deterministic, multi-turn shopping copilot: it updates session intent from each shopper message, retrieves and scores catalog products, then selects recommendations and may ask a clarifying question. The README documents this flow and the evaluator capability; sampled source shows the facade’s orchestration and several component calls. Other links rely on the SOURCE INDEX’s import/reference lists, so those lists support dependencies but not unshown runtime details.

Main entry points: [`starter/agent.py`](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/agent.py) (Agent API), [`starter/catalog/repository.py`](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/catalog/repository.py) (Catalog repository), [`starter/retrieval/candidate_retriever.py`](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/retrieval/candidate_retriever.py) (Candidate retriever), [`starter/ranking/scorer.py`](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/ranking/scorer.py) (Candidate scorer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Conversation and intent"]
  node_agent["Agent API<br/>[agent.py]"]
  node_state["State manager<br/>[state_manager.py]"]
  node_extractor["Evidence extractor"]
  node_belief["Intent belief<br/>[belief.py]"]
end

subgraph group_catalog["Catalog and retrieval"]
  node_catalog_repo[("Catalog repository<br/>[repository.py]")]
  node_search_index[("FTS5 search index<br/>[search_index.py]")]
  node_retriever["Candidate retriever"]
end

subgraph group_decision["Ranking and dialogue"]
  node_scorer["Candidate scorer<br/>[scorer.py]"]
  node_selector["Risk-aware selector<br/>[selector.py]"]
  node_question_policy["Question policy<br/>[question_policy.py]"]
end

subgraph group_shared["Shared state and utilities"]
  node_shared_helpers["Shared state and helpers"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluator["Local evaluator<br/>[local_evaluator.py]"]
end

node_shopper(("Shopper"))
node_response["Response"]

node_shopper -->|"sends message"| node_agent
node_agent -->|"updates state"| node_state
node_state -->|"extracts evidence"| node_extractor
node_state -->|"uses session state"| node_shared_helpers
node_extractor -->|"uses ontology"| node_shared_helpers
node_agent -->|"retrieves candidates"| node_retriever
node_retriever -->|"gets active terms"| node_belief
node_retriever -->|"searches catalog"| node_search_index
node_retriever -->|"checks catalog"| node_catalog_repo
node_search_index -->|"indexes products"| node_catalog_repo
node_agent -->|"scores candidates"| node_scorer
node_scorer -->|"reads active evidence"| node_belief
node_scorer -->|"reads products"| node_catalog_repo
node_scorer -->|"uses product text"| node_shared_helpers
node_agent -->|"selects recommendations"| node_selector
node_selector -->|"checks uncertainty"| node_belief
node_selector -->|"reads products"| node_catalog_repo
node_agent -->|"chooses question"| node_question_policy
node_question_policy -->|"checks candidates"| node_catalog_repo
node_question_policy -->|"uses prompts"| node_shared_helpers
node_agent -->|"records response"| node_state
node_agent -->|"returns answer"| node_response
node_evaluator -->|"invokes agent"| node_agent

click node_agent "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/agent.py"
click node_state "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/intent/state_manager.py"
click node_extractor "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/intent/evidence_extractor.py"
click node_belief "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/intent/belief.py"
click node_catalog_repo "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/catalog/repository.py"
click node_search_index "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/catalog/search_index.py"
click node_retriever "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/retrieval/candidate_retriever.py"
click node_scorer "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/ranking/scorer.py"
click node_selector "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/ranking/selector.py"
click node_question_policy "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/dialogue/question_policy.py"
click node_shared_helpers "https://github.com/mukulsinghal407/tiktoktechjam/tree/main/starter/helper"
click node_evaluator "https://github.com/mukulsinghal407/tiktoktechjam/blob/main/evaluator/local_evaluator.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_agent,node_state,node_extractor,node_belief toneBlue
class node_catalog_repo,node_search_index,node_retriever toneAmber
class node_scorer,node_selector,node_question_policy toneMint
class node_shared_helpers toneRose
class node_evaluator,node_shopper,node_response toneIndigo
```

## Components

### Conversation and intent

- [Agent API](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/agent.py): `starter/agent.py`
- [State manager](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/intent/state_manager.py): `starter/intent/state_manager.py`
- [Evidence extractor](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/intent/evidence_extractor.py): `starter/intent/evidence_extractor.py`
- [Intent belief](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/intent/belief.py): `starter/intent/belief.py`

### Catalog and retrieval

- [Catalog repository](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/catalog/repository.py): `starter/catalog/repository.py`
- [FTS5 search index](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/catalog/search_index.py): `starter/catalog/search_index.py`
- [Candidate retriever](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/retrieval/candidate_retriever.py): `starter/retrieval/candidate_retriever.py`

### Ranking and dialogue

- [Candidate scorer](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/ranking/scorer.py): `starter/ranking/scorer.py`
- [Risk-aware selector](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/ranking/selector.py): `starter/ranking/selector.py`
- [Question policy](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/starter/dialogue/question_policy.py): `starter/dialogue/question_policy.py`

### Shared state and utilities

- [Shared state and helpers](https://github.com/mukulsinghal407/tiktoktechjam/tree/main/starter/helper): `starter/helper`

### Evaluation

- [Local evaluator](https://github.com/mukulsinghal407/tiktoktechjam/blob/main/evaluator/local_evaluator.py): `evaluator/local_evaluator.py`

### Other components

- **Shopper**
- **Response**

## Connections

- Shopper → Agent API: sends message (evidence: `README.md`)
- Agent API → State manager: updates state (evidence: `starter/agent.py`)
- State manager → Evidence extractor: extracts evidence (evidence: `starter/intent/state_manager.py`)
- State manager → Shared state and helpers: uses session state (evidence: `starter/intent/state_manager.py`)
- Evidence extractor → Shared state and helpers: uses ontology (evidence: `starter/intent/evidence_extractor.py`)
- Agent API → Candidate retriever: retrieves candidates (evidence: `starter/agent.py`)
- Candidate retriever → Intent belief: gets active terms (evidence: `starter/retrieval/candidate_retriever.py`)
- Candidate retriever → FTS5 search index: searches catalog (evidence: `starter/retrieval/candidate_retriever.py`)
- Candidate retriever → Catalog repository: checks catalog (evidence: `starter/retrieval/candidate_retriever.py`)
- FTS5 search index → Catalog repository: indexes products (evidence: `starter/catalog/search_index.py`)
- Agent API → Candidate scorer: scores candidates (evidence: `starter/agent.py`)
- Candidate scorer → Intent belief: reads active evidence (evidence: `starter/ranking/scorer.py`)
- Candidate scorer → Catalog repository: reads products (evidence: `starter/ranking/scorer.py`)
- Candidate scorer → Shared state and helpers: uses product text (evidence: `starter/ranking/scorer.py`)
- Agent API → Risk-aware selector: selects recommendations (evidence: `starter/agent.py`)
- Risk-aware selector → Intent belief: checks uncertainty (evidence: `starter/ranking/selector.py`)
- Risk-aware selector → Catalog repository: reads products (evidence: `starter/ranking/selector.py`)
- Agent API → Question policy: chooses question (evidence: `starter/agent.py`)
- Question policy → Catalog repository: checks candidates (evidence: `starter/dialogue/question_policy.py`)
- Question policy → Shared state and helpers: uses prompts (evidence: `starter/dialogue/question_policy.py`)
- Agent API → State manager: records response (evidence: `starter/agent.py`)
- Agent API → Response: returns answer (evidence: `README.md`)
- Local evaluator → Agent API: invokes agent (evidence: `evaluator/local_evaluator.py`)
