# silenthg/ccv2bot architecture

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

- Interactive diagram: https://gitdiagram.com/silenthg/ccv2bot
- Repository: https://github.com/silenthg/ccv2bot

## Overview

1. **What this repo is**
   - This is a **Microsoft Teams command bot** built with **Node.js** and the **TeamsFx SDK**.
   - It is not a traditional web app UI; the user interface lives inside **Teams chat messages** and **Adaptive Cards** returned by the bot.

2. **Top-level orchestration**
   - `teamsapp.yml` is the main lifecycle spec for the app: provisioning, deployment, and local debug.
   - `teamsapp.local.yml` overrides that for local development.
   - `env/.env.dev` and related env files hold environment-specific values that feed both infrastructure and runtime configuration.

3. **Runtime entrypoint and bot bootstrap**
   - `src/index.js` is the application entrypoint and HTTP/bot host.
   - `src/internal/initialize.js` constructs the bot runtime and registers command handlers.
   - `src/internal/config.js` centralizes runtime configuration from environment values.
   - `src/teamsBot.js` is the extension point for non-command Teams activity handling.

4. **Command dispatch model**
   - The bot is organized as a set of **small command handler modules** under `src/`.
   - Each handler corresponds to one Teams command, such as:
     - `createBuild`
     - `createDeployment`
     - `getBuildProgress`
     - `getDeploymentProgress`
     - `getEnvironments`
     - `help`
     - `setupApiToken`
     - `getBotAdmin`
     - `updateBotAdmin`
     - `giveCreateAccess`
   - `src/internal/initialize.js` is the main registration boundary where these handlers are wired into the command bot.

5. **How a message flows through the system**
   - A user types a command in Teams.
   - Teams routes the message to the bot endpoint hosted by this app.
   - The TeamsFx/Bot Framework adapter forwards the activity into the command bot.
   - The matching handler executes command-specific logic and returns either plain text or an Adaptive Card response.

6. **Adaptive Card presentation layer**
   - `src/adaptiveCards/` contains the card templates used by command responses.
   - The cards are rendered dynamically from JSON templates via the Adaptive Cards tooling.
   - In this repo, cards are used to present structured command output for commands like help and environment listing.

7. **Domain shape of the bot**
   - This template has been customized beyond the generic “hello world” sample into a **command-driven operations bot**.
   - The handler names indicate the bot likely fronts automation around build/deployment workflows, progress checks, environment discovery, and access/admin setup.
   - That means the bot is an orchestration layer over external processes or services, not just a static responder.

8. **Azure and hosting boundary**
   - `infra/azure.bicep` and `infra/azure.parameters.json` define the Azure resources needed to host the bot.
   - The presence of `web.config` and `.appserviceIgnore` suggests the bot is intended to run on **Azure App Service**.
   - `infra/botRegistration/azurebot.bicep` provisions the Teams/Azure bot registration separately from the app hosting resources.

9. **Teams packaging boundary**
   - `appPackage/manifest.json` defines how the app appears in Teams, including the supported command list and bot metadata.
   - This manifest is the contract between Teams and the bot: it determines what commands users can type and how the app is installed.

10. **Local development vs deployed behavior**
   - The README indicates the app can be run locally and debugged via Teams Toolkit.
   - Local behavior is controlled by `teamsapp.local.yml`, while cloud deployment is controlled by `teamsapp.yml` and the infra templates.
   - This creates a clean split between developer workflow and Azure-hosted runtime.

11. **Important architectural boundaries**
   - **Teams manifest boundary:** what commands exist and how Teams exposes them.
   - **Bot runtime boundary:** message reception, routing, and response generation.
   - **Command handler boundary:** one file per command, isolating business logic.
   - **Card/template boundary:** presentation JSON separated from handler logic.
   - **Infrastructure boundary:** Azure provisioning and bot registration kept outside application code.

12. **What to show in an architecture diagram**
   - Teams client → Teams platform → bot endpoint in Azure App Service → TeamsFx/Bot Framework adapter → command dispatcher in `initialize.js` → individual command handler modules → Adaptive Card templates / external services.
   - In parallel, show deployment-time flows from `teamsapp.yml` into `infra/*.bicep` and `appPackage/manifest.json`, because those define how the bot is created, registered, and exposed to Teams.

Main entry points: [`src/internal/initialize.js`](https://github.com/silenthg/ccv2bot/blob/main/src/internal/initialize.js) (Bootstrap), [`teamsapp.yml`](https://github.com/silenthg/ccv2bot/blob/main/teamsapp.yml) (App lifecycle), [`src/index.js`](https://github.com/silenthg/ccv2bot/blob/main/src/index.js) (Entry point), [`env/.env.dev`](https://github.com/silenthg/ccv2bot/blob/main/env/.env.dev) (Env values)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtime"]
  node_node_entry["Entry point<br/>node runtime<br/>[index.js]"]
  node_node_init["Bootstrap<br/>command wiring<br/>[initialize.js]"]
  node_node_config["Config<br/>[config.js]"]
  node_node_teamsbot["Teams bot<br/>activity handler<br/>[teamsBot.js]"]
end

subgraph group_group_commands["Commands"]
  node_node_create_build["Build cmd<br/>command handler"]
  node_node_create_deploy["Deploy cmd<br/>command handler"]
  node_node_build_progress["Build status<br/>command handler"]
  node_node_deploy_progress["Deploy status<br/>command handler"]
  node_node_envs["Environments<br/>command handler"]
  node_node_help["Help cmd<br/>command handler"]
  node_node_setup_token["Token setup<br/>command handler"]
  node_node_get_admin["Get admin<br/>command handler"]
  node_node_update_admin["Update admin<br/>command handler"]
  node_node_create_access["Create access<br/>command handler"]
end

subgraph group_group_cards["Cards"]
  node_node_help_card["Help card<br/>adaptive card<br/>[helpCommand.json]"]
  node_node_env_card["Env card<br/>adaptive card"]
end

subgraph group_group_deploy["Deploy"]
  node_node_manifest["Manifest<br/>[manifest.json]"]
  node_node_teamstapp["App lifecycle<br/>teams toolkit yaml<br/>[teamsapp.yml]"]
  node_node_teamstapp_local["Local override<br/>teams toolkit yaml<br/>[teamsapp.local.yml]"]
  node_node_envfile["Env values<br/>environment file<br/>[.env.dev]"]
  node_node_azure_bicep["Azure infra<br/>bicep template<br/>[azure.bicep]"]
  node_node_azure_params["Azure params<br/>parameter file"]
  node_node_botreg_bicep["Bot reg<br/>bicep template<br/>[azurebot.bicep]"]
end

node_node_teams_users(("Teams users<br/>client"))
node_node_teams_platform(("Teams platform<br/>channel"))
node_node_app_service(("Bot host<br/>runtime host"))

node_node_teams_users -->|"send command"| node_node_teams_platform
node_node_teams_platform -->|"route activity"| node_node_app_service
node_node_app_service -->|"host"| node_node_entry
node_node_entry -->|"load config"| node_node_config
node_node_entry -->|"bootstrap"| node_node_init
node_node_entry -->|"activity hook"| node_node_teamsbot
node_node_init -->|"register"| node_node_create_build
node_node_init -->|"register"| node_node_create_deploy
node_node_init -->|"register"| node_node_build_progress
node_node_init -->|"register"| node_node_deploy_progress
node_node_init -->|"register"| node_node_envs
node_node_init -->|"register"| node_node_help
node_node_init -->|"register"| node_node_setup_token
node_node_init -->|"register"| node_node_get_admin
node_node_init -->|"register"| node_node_update_admin
node_node_init -->|"register"| node_node_create_access
node_node_help -->|"render"| node_node_help_card
node_node_envs -->|"render"| node_node_env_card
node_node_teamstapp -->|"package"| node_node_manifest
node_node_teamstapp -->|"provision"| node_node_azure_bicep
node_node_teamstapp -->|"register"| node_node_botreg_bicep
node_node_teamstapp -->|"configure"| node_node_envfile
node_node_teamstapp_local -->|"override"| node_node_teamstapp
node_node_azure_bicep -->|"parametrize"| node_node_azure_params
node_node_envfile -->|"runtime env"| node_node_entry
node_node_envfile -->|"infra env"| node_node_azure_bicep
node_node_manifest -->|"declare bot"| node_node_teams_platform

click node_node_entry "https://github.com/silenthg/ccv2bot/blob/main/src/index.js"
click node_node_init "https://github.com/silenthg/ccv2bot/blob/main/src/internal/initialize.js"
click node_node_config "https://github.com/silenthg/ccv2bot/blob/main/src/internal/config.js"
click node_node_teamsbot "https://github.com/silenthg/ccv2bot/blob/main/src/teamsBot.js"
click node_node_create_build "https://github.com/silenthg/ccv2bot/blob/main/src/createBuildCommandHandler.js"
click node_node_create_deploy "https://github.com/silenthg/ccv2bot/blob/main/src/createDeploymentCommandHandler.js"
click node_node_build_progress "https://github.com/silenthg/ccv2bot/blob/main/src/getBuildProgressCommandHandler.js"
click node_node_deploy_progress "https://github.com/silenthg/ccv2bot/blob/main/src/getDeploymentProgressCommandHandler.js"
click node_node_envs "https://github.com/silenthg/ccv2bot/blob/main/src/getEnvironmentsCommandHandler.js"
click node_node_help "https://github.com/silenthg/ccv2bot/blob/main/src/helpCommandHandler.js"
click node_node_setup_token "https://github.com/silenthg/ccv2bot/blob/main/src/setupApiTokenCommandHandler.js"
click node_node_get_admin "https://github.com/silenthg/ccv2bot/blob/main/src/getBotAdminCommandHandler.js"
click node_node_update_admin "https://github.com/silenthg/ccv2bot/blob/main/src/updateBotAdminCommandHandler.js"
click node_node_create_access "https://github.com/silenthg/ccv2bot/blob/main/src/giveCreateAccessCommandHandler.js"
click node_node_help_card "https://github.com/silenthg/ccv2bot/blob/main/src/adaptiveCards/helpCommand.json"
click node_node_env_card "https://github.com/silenthg/ccv2bot/blob/main/src/adaptiveCards/getEnvironmentsCommand.json"
click node_node_manifest "https://github.com/silenthg/ccv2bot/blob/main/appPackage/manifest.json"
click node_node_teamstapp "https://github.com/silenthg/ccv2bot/blob/main/teamsapp.yml"
click node_node_teamstapp_local "https://github.com/silenthg/ccv2bot/blob/main/teamsapp.local.yml"
click node_node_envfile "https://github.com/silenthg/ccv2bot/blob/main/env/.env.dev"
click node_node_azure_bicep "https://github.com/silenthg/ccv2bot/blob/main/infra/azure.bicep"
click node_node_azure_params "https://github.com/silenthg/ccv2bot/blob/main/infra/azure.parameters.json"
click node_node_botreg_bicep "https://github.com/silenthg/ccv2bot/blob/main/infra/botRegistration/azurebot.bicep"

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_node_entry,node_node_init,node_node_config,node_node_teamsbot toneBlue
class node_node_create_build,node_node_create_deploy,node_node_build_progress,node_node_deploy_progress,node_node_envs,node_node_help,node_node_setup_token,node_node_get_admin,node_node_update_admin,node_node_create_access toneAmber
class node_node_help_card,node_node_env_card toneMint
class node_node_manifest,node_node_teamstapp,node_node_teamstapp_local,node_node_envfile,node_node_azure_bicep,node_node_azure_params,node_node_botreg_bicep toneRose
class node_node_teams_users,node_node_teams_platform,node_node_app_service toneNeutral
```

## Components

### Runtime

Bot host, bootstrapping, and command dispatch.

- [Entry point](https://github.com/silenthg/ccv2bot/blob/main/src/index.js): node runtime · Application entrypoint and bot host startup. · `src/index.js`
- [Bootstrap](https://github.com/silenthg/ccv2bot/blob/main/src/internal/initialize.js): command wiring · Constructs the bot runtime and registers command handlers. · `src/internal/initialize.js`
- [Config](https://github.com/silenthg/ccv2bot/blob/main/src/internal/config.js): env config · Centralized runtime configuration from environment values. · `src/internal/config.js`
- [Teams bot](https://github.com/silenthg/ccv2bot/blob/main/src/teamsBot.js): activity handler · Non-command Teams activity extension point. · `src/teamsBot.js`

### Commands

One module per Teams command, with command-specific logic.

- [Build cmd](https://github.com/silenthg/ccv2bot/blob/main/src/createBuildCommandHandler.js): command handler · Handles createBuild command requests. · `src/createBuildCommandHandler.js`
- [Deploy cmd](https://github.com/silenthg/ccv2bot/blob/main/src/createDeploymentCommandHandler.js): command handler · Handles createDeployment command requests. · `src/createDeploymentCommandHandler.js`
- [Build status](https://github.com/silenthg/ccv2bot/blob/main/src/getBuildProgressCommandHandler.js): command handler · Handles build progress lookup. · `src/getBuildProgressCommandHandler.js`
- [Deploy status](https://github.com/silenthg/ccv2bot/blob/main/src/getDeploymentProgressCommandHandler.js): command handler · Handles deployment progress lookup. · `src/getDeploymentProgressCommandHandler.js`
- [Environments](https://github.com/silenthg/ccv2bot/blob/main/src/getEnvironmentsCommandHandler.js): command handler · Handles environment discovery and listing. · `src/getEnvironmentsCommandHandler.js`
- [Help cmd](https://github.com/silenthg/ccv2bot/blob/main/src/helpCommandHandler.js): command handler · Handles help output for the bot. · `src/helpCommandHandler.js`
- [Token setup](https://github.com/silenthg/ccv2bot/blob/main/src/setupApiTokenCommandHandler.js): command handler · Handles API token setup. · `src/setupApiTokenCommandHandler.js`
- [Get admin](https://github.com/silenthg/ccv2bot/blob/main/src/getBotAdminCommandHandler.js): command handler · Handles bot admin lookup. · `src/getBotAdminCommandHandler.js`
- [Update admin](https://github.com/silenthg/ccv2bot/blob/main/src/updateBotAdminCommandHandler.js): command handler · Handles bot admin changes. · `src/updateBotAdminCommandHandler.js`
- [Create access](https://github.com/silenthg/ccv2bot/blob/main/src/giveCreateAccessCommandHandler.js): command handler · Handles create-access permission changes. · `src/giveCreateAccessCommandHandler.js`

### Cards

Adaptive Card templates used by structured responses.

- [Help card](https://github.com/silenthg/ccv2bot/blob/main/src/adaptiveCards/helpCommand.json): adaptive card · Structured help response template. · `src/adaptiveCards/helpCommand.json`
- [Env card](https://github.com/silenthg/ccv2bot/blob/main/src/adaptiveCards/getEnvironmentsCommand.json): adaptive card · Structured environment-list response template. · `src/adaptiveCards/getEnvironmentsCommand.json`

### Deploy

Teams packaging, environment values, and Azure provisioning.

- [Manifest](https://github.com/silenthg/ccv2bot/blob/main/appPackage/manifest.json): teams app manifest · Defines Teams exposure, metadata, and supported commands. · `appPackage/manifest.json`
- [App lifecycle](https://github.com/silenthg/ccv2bot/blob/main/teamsapp.yml): teams toolkit yaml · Main provisioning, deployment, and local debug specification. · `teamsapp.yml`
- [Local override](https://github.com/silenthg/ccv2bot/blob/main/teamsapp.local.yml): teams toolkit yaml · Local development override for the lifecycle spec. · `teamsapp.local.yml`
- [Env values](https://github.com/silenthg/ccv2bot/blob/main/env/.env.dev): environment file · Environment-specific configuration consumed by runtime and infrastructure. · `env/.env.dev`
- [Azure infra](https://github.com/silenthg/ccv2bot/blob/main/infra/azure.bicep): bicep template · Primary Azure provisioning template. · `infra/azure.bicep`
- [Azure params](https://github.com/silenthg/ccv2bot/blob/main/infra/azure.parameters.json): parameter file · Parameters for Azure provisioning. · `infra/azure.parameters.json`
- [Bot reg](https://github.com/silenthg/ccv2bot/blob/main/infra/botRegistration/azurebot.bicep): bicep template · Provisions the Azure/Teams bot registration. · `infra/botRegistration/azurebot.bicep`

### Other components

- **Teams users**: client · People issuing bot commands inside Microsoft Teams.
- **Teams platform**: channel · Routes chat activities to the registered bot endpoint.
- **Bot host**: runtime host · Azure-hosted HTTP endpoint for the bot.

## Connections

- Teams users → Teams platform: send command · Users type commands in Teams.
- Teams platform → Bot host: route activity · Teams routes the message to the bot endpoint.
- Bot host → Entry point: host · The bot runs as the App Service-hosted Node process.
- Entry point → Config: load config · Startup reads environment-driven configuration.
- Entry point → Bootstrap: bootstrap · Entrypoint builds and starts the bot runtime.
- Entry point → Teams bot: activity hook · Non-command activity handling is attached here.
- Bootstrap → Build cmd: register · Command dispatcher wires the build creation handler.
- Bootstrap → Deploy cmd: register · Command dispatcher wires the deployment creation handler.
- Bootstrap → Build status: register · Command dispatcher wires build progress lookup.
- Bootstrap → Deploy status: register · Command dispatcher wires deployment progress lookup.
- Bootstrap → Environments: register · Command dispatcher wires environment listing.
- Bootstrap → Help cmd: register · Command dispatcher wires help output.
- Bootstrap → Token setup: register · Command dispatcher wires token setup.
- Bootstrap → Get admin: register · Command dispatcher wires admin lookup.
- Bootstrap → Update admin: register · Command dispatcher wires admin updates.
- Bootstrap → Create access: register · Command dispatcher wires create-access changes.
- Help cmd → Help card: render · Help responses use an Adaptive Card template.
- Environments → Env card: render · Environment listing uses an Adaptive Card template.
- App lifecycle → Manifest: package · Lifecycle spec drives the Teams app package and manifest.
- App lifecycle → Azure infra: provision · Lifecycle spec invokes Azure provisioning.
- App lifecycle → Bot reg: register · Lifecycle spec includes bot registration provisioning.
- App lifecycle → Env values: configure · Lifecycle spec consumes environment values.
- Local override → App lifecycle: override · Local settings override the base lifecycle spec.
- Azure infra → Azure params: parametrize · Azure provisioning is driven by parameters.
- Env values → Entry point: runtime env · Environment values feed application startup.
- Env values → Azure infra: infra env · Environment values also feed infrastructure provisioning.
- Manifest → Teams platform: declare bot · Manifest defines how Teams exposes the bot and commands.
