# dto-btn/ssc-assistant architecture

> Architecture diagram of the GitHub repository dto-btn/ssc-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dto-btn/ssc-assistant
- Repository: https://github.com/dto-btn/ssc-assistant

## Overview

#### Purpose and Runtime
SSC Assistant is an Azure-hosted, RAG-enabled internal chatbot. It combines Azure OpenAI models (including GPT-4o), Azure AI Search-backed knowledge, and domain tools/APIs. Development runs a Flask API on port 5001 and a Vite/React frontend; Python 3.12+ and Node/npm are material runtimes. Primary entry points: `app/api/app.py`, `app/frontend/src/index.tsx`, and `app/frontend/server.js`.

#### Client Applications and Routes
The frontend contains a legacy/main chat experience plus a newer “playground” session-oriented experience. Routing selects application surfaces and auth-aware views. The playground is architecturally significant: it supports conversations, uploads, citations, tool attribution, feedback, export, and offline/sync state.
Paths: `app/frontend/src/routes/AppRoutes.tsx`, `app/frontend/src/playground/Playground.tsx`, `app/frontend/src/playground/components/PlaygroundRoot.tsx`.

#### Frontend State, Orchestration, and Completion Flow
Playground Redux-style state partitions auth, sessions, messages, tools, files, outbox, sync, and UI. User actions dispatch thunks; the assistant thunk builds messages, invokes the orchestration/completion layer, streams or renders responses, and records tool/citation metadata. Persistence plus outbox/archiver middleware form the client-side durability and synchronization boundary.
Paths: `app/frontend/src/playground/store/index.ts`, `app/frontend/src/playground/store/thunks/assistantThunks.ts`, `app/frontend/src/playground/services/orchestratorService.ts`.

#### API Boundary and Request Processing
Flask exposes the backend API and a separate playground route surface. API handlers are the boundary for browser requests, authentication/authorization utilities, Azure client access, conversation/session operations, suggestions, reporting, and tool execution. Proxy modules isolate Azure-specific request behavior.
Paths: `app/api/app.py`, `app/api/v1/routes_v1.py`, `app/api/playground/routes_playground.py`.

#### LLM Context and Tool Execution
Backend context construction prepares model/tool input. `ToolService` and the tool registry route model-requested actions to domain integrations: Archibus, BITS, Corporate, GEDS, PMCOE, and Telecom. Tool results are incorporated into assistant responses and exposed to the UI as tool-use metadata. Azure OpenAI deployment/client utilities isolate model-provider configuration.
Paths: `app/api/src/context/build_context.py`, `app/api/src/service/tool_service.py`, `app/api/src/constants/tools.py`.

#### Persistence and Suggestion Context
Conversation and user repositories sit over SQL entities/session provisioning; chat-table DAO abstractions include an in-memory adapter. Suggestion context has a distinct DAO contract with Blob Storage and mock implementations, keeping recommendation/context storage separable from conversational persistence.
Paths: `app/api/src/repository/conversation_repository.py`, `app/api/src/db/sql_session_provider.py`, `app/api/src/dao/suggestion_context/blob_suggestion_context_dao.py`.

#### Azure Data/Infrastruture Pipeline
Azure Functions ingest/fetch source data and build the search index used by RAG. Terraform provisions API, frontend, Functions, Azure OpenAI, search services, storage, networking, and access/groups. External dependencies include SSCPlus data-fetch services, Azure Blob Storage, Azure AI Search, Azure OpenAI, and Microsoft/Azure identity.
Paths: `az-functions/create-index/function_app.py`, `az-functions/create-index/build_seach_index_bp.py`, `terraform/main.tf`.

Main entry points: [`terraform/main.tf`](https://github.com/dto-btn/ssc-assistant/blob/main/terraform/main.tf) (Terraform infrastructure), [`app/api/src/context/build_context.py`](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/context/build_context.py) (Context builder), [`app/api/v1/routes_v1.py`](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/v1/routes_v1.py) (Core API routes), [`app/api/src/service/tool_service.py`](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/service/tool_service.py) (Tool service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_entry["React entry<br/>Vite/React<br/>[index.tsx]"]
  node_frontend_routes["App routes<br/>route selection<br/>[AppRoutes.tsx]"]
  node_playground["Playground UI<br/>chat workspace<br/>[Playground.tsx]"]
  node_playground_root["Playground root<br/>UI composition<br/>[PlaygroundRoot.tsx]"]
  node_playground_store[("Playground store<br/>Redux state<br/>[index.ts]")]
  node_assistant_thunks["Assistant thunks<br/>action flow<br/>[assistantThunks.ts]"]
  node_client_orchestrator["Client orchestrator<br/>completion client"]
  node_frontend_server["Frontend server<br/>Node server<br/>[server.js]"]
end

subgraph group_api["Backend API"]
  node_flask_app["Flask API<br/>Python entry point<br/>[app.py]"]
  node_v1_routes["Core API routes<br/>Flask routes<br/>[routes_v1.py]"]
  node_playground_routes["Playground routes<br/>Flask routes"]
  node_context_builder["Context builder<br/>LLM context<br/>[build_context.py]"]
  node_tool_service{{"Tool service<br/>tool dispatcher<br/>[tool_service.py]"}}
  node_tool_registry["Tool registry<br/>tool catalog<br/>[tools.py]"]
  node_conversation_repository[("Conversation repository<br/>persistence repository")]
  node_sql_session[("SQL session provider<br/>database access")]
  node_suggestion_dao[("Suggestion context DAO<br/>Blob DAO")]
end

subgraph group_azure["Azure Platform"]
  node_index_function{{"Indexing Functions<br/>Azure Functions<br/>[function_app.py]"}}
  node_index_builder["Search index builder<br/>index pipeline"]
  node_terraform["Terraform infrastructure<br/>IaC<br/>[main.tf]"]
  node_azure_openai{{"Azure OpenAI<br/>LLM provider"}}
  node_azure_search[("Azure AI Search<br/>RAG index")]
  node_blob_storage[("Azure Blob Storage<br/>object storage")]
end

node_domain_apis{{"Domain APIs<br/>enterprise integrations"}}

node_frontend_entry --> node_frontend_routes
node_frontend_routes -->|"playground route"| node_playground
node_playground --> node_playground_root
node_playground_root -->|"reads and dispatches"| node_playground_store
node_playground_store -->|"user actions"| node_assistant_thunks
node_assistant_thunks -->|"completion request"| node_client_orchestrator
node_client_orchestrator -->|"browser API"| node_playground_routes
node_frontend_server -->|"serves client"| node_frontend_entry
node_flask_app -->|"mounts"| node_v1_routes
node_flask_app -->|"mounts"| node_playground_routes
node_playground_routes -->|"completion processing"| node_context_builder
node_v1_routes -->|"sessions and messages"| node_conversation_repository
node_context_builder -->|"model completion"| node_azure_openai
node_context_builder -->|"RAG retrieval"| node_azure_search
node_context_builder -->|"tool calls"| node_tool_service
node_tool_service -->|"resolves tools"| node_tool_registry
node_tool_service -->|"executes actions"| node_domain_apis
node_conversation_repository -->|"uses"| node_sql_session
node_v1_routes -->|"suggestion context"| node_suggestion_dao
node_suggestion_dao -->|"stores context"| node_blob_storage
node_index_function -->|"runs"| node_index_builder
node_index_builder -->|"builds index"| node_azure_search
node_blob_storage -->|"source content"| node_index_function
node_terraform -.->|"provisions"| node_flask_app
node_terraform -.->|"provisions"| node_frontend_server
node_terraform -.->|"provisions"| node_index_function
node_terraform -.->|"provisions"| node_azure_openai
node_terraform -.->|"provisions"| node_azure_search
node_terraform -.->|"provisions"| node_blob_storage

click node_frontend_entry "https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/index.tsx"
click node_frontend_routes "https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/routes/AppRoutes.tsx"
click node_playground "https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/Playground.tsx"
click node_playground_root "https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/components/PlaygroundRoot.tsx"
click node_playground_store "https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/store/index.ts"
click node_assistant_thunks "https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/store/thunks/assistantThunks.ts"
click node_client_orchestrator "https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/services/orchestratorService.ts"
click node_frontend_server "https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/server.js"
click node_flask_app "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/app.py"
click node_v1_routes "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/v1/routes_v1.py"
click node_playground_routes "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/playground/routes_playground.py"
click node_context_builder "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/context/build_context.py"
click node_tool_service "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/service/tool_service.py"
click node_tool_registry "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/constants/tools.py"
click node_conversation_repository "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/repository/conversation_repository.py"
click node_sql_session "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/db/sql_session_provider.py"
click node_suggestion_dao "https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/dao/suggestion_context/blob_suggestion_context_dao.py"
click node_index_function "https://github.com/dto-btn/ssc-assistant/blob/main/az-functions/create-index/function_app.py"
click node_index_builder "https://github.com/dto-btn/ssc-assistant/blob/main/az-functions/create-index/build_seach_index_bp.py"
click node_terraform "https://github.com/dto-btn/ssc-assistant/blob/main/terraform/main.tf"

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_frontend_entry,node_frontend_routes,node_playground,node_playground_root,node_playground_store,node_assistant_thunks,node_client_orchestrator,node_frontend_server toneBlue
class node_flask_app,node_v1_routes,node_playground_routes,node_context_builder,node_tool_service,node_tool_registry,node_conversation_repository,node_sql_session,node_suggestion_dao toneAmber
class node_index_function,node_index_builder,node_terraform,node_azure_openai,node_azure_search,node_blob_storage toneMint
class node_domain_apis toneNeutral
```

## Components

### Frontend

Vite/React chat clients and playground state.

- [React entry](https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/index.tsx): Vite/React · `app/frontend/src/index.tsx`
- [App routes](https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/routes/AppRoutes.tsx): route selection · Selects legacy and playground surfaces. · `app/frontend/src/routes/AppRoutes.tsx`
- [Playground UI](https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/Playground.tsx): chat workspace · Session chat, uploads, citations, feedback, export, and sync UI. · `app/frontend/src/playground/Playground.tsx`
- [Playground root](https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/components/PlaygroundRoot.tsx): UI composition · `app/frontend/src/playground/components/PlaygroundRoot.tsx`
- [Playground store](https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/store/index.ts): Redux state · Partitions auth, sessions, messages, tools, files, outbox, sync, and UI. · `app/frontend/src/playground/store/index.ts`
- [Assistant thunks](https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/store/thunks/assistantThunks.ts): action flow · Builds requests and records streamed response metadata. · `app/frontend/src/playground/store/thunks/assistantThunks.ts`
- [Client orchestrator](https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/src/playground/services/orchestratorService.ts): completion client · `app/frontend/src/playground/services/orchestratorService.ts`
- [Frontend server](https://github.com/dto-btn/ssc-assistant/blob/main/app/frontend/server.js): Node server · `app/frontend/server.js`

### Backend API

Flask request boundary, orchestration, tools, and persistence.

- [Flask API](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/app.py): Python entry point · Browser API host on port 5001. · `app/api/app.py`
- [Core API routes](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/v1/routes_v1.py): Flask routes · Handles authenticated chat, sessions, suggestions, reports, and tools. · `app/api/v1/routes_v1.py`
- [Playground routes](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/playground/routes_playground.py): Flask routes · Dedicated route surface for playground requests. · `app/api/playground/routes_playground.py`
- [Context builder](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/context/build_context.py): LLM context · Prepares model and tool input. · `app/api/src/context/build_context.py`
- [Tool service](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/service/tool_service.py): tool dispatcher · Routes model-requested actions and returns tool metadata. · `app/api/src/service/tool_service.py`
- [Tool registry](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/constants/tools.py): tool catalog · Defines Archibus, BITS, Corporate, GEDS, PMCOE, and Telecom tools. · `app/api/src/constants/tools.py`
- [Conversation repository](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/repository/conversation_repository.py): persistence repository · `app/api/src/repository/conversation_repository.py`
- [SQL session provider](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/db/sql_session_provider.py): database access · `app/api/src/db/sql_session_provider.py`
- [Suggestion context DAO](https://github.com/dto-btn/ssc-assistant/blob/main/app/api/src/dao/suggestion_context/blob_suggestion_context_dao.py): Blob DAO · Separates recommendation context from conversation storage. · `app/api/src/dao/suggestion_context/blob_suggestion_context_dao.py`

### Azure Platform

RAG data pipeline and provisioned cloud services.

- [Indexing Functions](https://github.com/dto-btn/ssc-assistant/blob/main/az-functions/create-index/function_app.py): Azure Functions · Ingests source data and builds the RAG search index. · `az-functions/create-index/function_app.py`
- [Search index builder](https://github.com/dto-btn/ssc-assistant/blob/main/az-functions/create-index/build_seach_index_bp.py): index pipeline · `az-functions/create-index/build_seach_index_bp.py`
- [Terraform infrastructure](https://github.com/dto-btn/ssc-assistant/blob/main/terraform/main.tf): IaC · Provisions apps, Functions, OpenAI, search, storage, networking, and access. · `terraform/main.tf`
- **Azure OpenAI**: LLM provider · GPT-4o and other deployments.
- **Azure AI Search**: RAG index
- **Azure Blob Storage**: object storage

### Other components

- **Domain APIs**: enterprise integrations · Archibus, BITS, Corporate, GEDS, PMCOE, and Telecom.

## Connections

- React entry → App routes
- App routes → Playground UI: playground route
- Playground UI → Playground root
- Playground root → Playground store: reads and dispatches
- Playground store → Assistant thunks: user actions
- Assistant thunks → Client orchestrator: completion request
- Client orchestrator → Playground routes: browser API
- Frontend server → React entry: serves client
- Flask API → Core API routes: mounts
- Flask API → Playground routes: mounts
- Playground routes → Context builder: completion processing
- Core API routes → Conversation repository: sessions and messages
- Context builder → Azure OpenAI: model completion
- Context builder → Azure AI Search: RAG retrieval
- Context builder → Tool service: tool calls
- Tool service → Tool registry: resolves tools
- Tool service → Domain APIs: executes actions
- Conversation repository → SQL session provider: uses
- Core API routes → Suggestion context DAO: suggestion context
- Suggestion context DAO → Azure Blob Storage: stores context
- Indexing Functions → Search index builder: runs
- Search index builder → Azure AI Search: builds index
- Azure Blob Storage → Indexing Functions: source content
- Terraform infrastructure → Flask API: provisions
- Terraform infrastructure → Frontend server: provisions
- Terraform infrastructure → Indexing Functions: provisions
- Terraform infrastructure → Azure OpenAI: provisions
- Terraform infrastructure → Azure AI Search: provisions
- Terraform infrastructure → Azure Blob Storage: provisions
