How dto-btn/ssc-assistant works
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: main.tf Terraform infrastructure · build_context.py Context builder · routes_v1.py Core API routes · tool_service.py Tool service
Components 24
Frontend
Vite/React chat clients and playground state.
- React entry
app/frontend/src/index.tsx - App routes · Selects legacy and playground surfaces.
app/frontend/src/routes/AppRoutes.tsx - Playground UI · Session chat, uploads, citations, feedback, export, and sync UI.
app/frontend/src/playground/Playground.tsx - Playground root
app/frontend/src/playground/components/PlaygroundRoot.tsx - Playground store · Partitions auth, sessions, messages, tools, files, outbox, sync, and UI.
app/frontend/src/playground/store/index.ts - Assistant thunks · Builds requests and records streamed response metadata.
app/frontend/src/playground/store/thunks/assistantThunks.ts - Client orchestrator
app/frontend/src/playground/services/orchestratorService.ts - Frontend server
app/frontend/server.js
Backend API
Flask request boundary, orchestration, tools, and persistence.
- Flask API · Browser API host on port 5001.
app/api/app.py - Core API routes · Handles authenticated chat, sessions, suggestions, reports, and tools.
app/api/v1/routes_v1.py - Playground routes · Dedicated route surface for playground requests.
app/api/playground/routes_playground.py - Context builder · Prepares model and tool input.
app/api/src/context/build_context.py - Tool service · Routes model-requested actions and returns tool metadata.
app/api/src/service/tool_service.py - Tool registry · Defines Archibus, BITS, Corporate, GEDS, PMCOE, and Telecom tools.
app/api/src/constants/tools.py - Conversation repository
app/api/src/repository/conversation_repository.py - SQL session provider
app/api/src/db/sql_session_provider.py - Suggestion context 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 · Ingests source data and builds the RAG search index.
az-functions/create-index/function_app.py - Search index builder
az-functions/create-index/build_seach_index_bp.py - Terraform infrastructure · Provisions apps, Functions, OpenAI, search, storage, networking, and access.
terraform/main.tf - Azure OpenAI · GPT-4o and other deployments.
- Azure AI Search
- Azure Blob Storage
Other components
- Domain APIs · Archibus, BITS, Corporate, GEDS, PMCOE, and Telecom.
Connections 29
- 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