# officedev/microsoft-teams-apps-company-communicator architecture

> Architecture diagram of the GitHub repository officedev/microsoft-teams-apps-company-communicator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/officedev/microsoft-teams-apps-company-communicator
- Repository: https://github.com/officedev/microsoft-teams-apps-company-communicator

## Overview

##### Project Type & Purpose
- This is a full‐stack cloud-based Teams app that allows corporate users to create and send messages (including adaptive cards and notifications) to large audiences via Microsoft Teams chats.
- The template supports various messaging scenarios (channel messages, 1:1 chats, and broadcast notifications) while integrating with Microsoft Graph, adaptive cards, and telemetry services.
- The README also emphasizes deployment alternatives (using PowerShell, certificates, etc.) and a rich set of features such as audience selection and localization.

##### Analyzing the File Structure – Key Directory Clusters
- Source/ClientApp – Contains the front-end of the Teams app built (likely) on React (see package.json, tsx files, etc.). This is the user interface for message composition, preview, and status.
- Source/CompanyCommunicator – Contains backend MVC components (Controllers, Models, Pages, and Services) that expose API endpoints, handle authentication, manage localization, and orchestrate business logic.
- Source/CompanyCommunicator.Common – A library with common adapters, clients, configuration, repository patterns, and shared services for interacting with Microsoft Graph, message queues, blob storage, and adaptive cards.
- Azure Functions Projects – There are separate Azure Function apps like:
- CompanyCommunicator.Data.Func (data cleanup, processing data queues)
- CompanyCommunicator.Prep.Func (orchestrators for preparing to send, aggregating recipients, and related workflow activities)
- CompanyCommunicator.Send.Func (sending messages/notifications)
- Deployment – Contains various ARM templates (azuredeploy.json files for different environments like DOD, GCCH, GCC) and PowerShell scripts for automated deployment. This folder also has infrastructure-related artifacts (AAD manifests, certificate scripts, etc.).
- Additional folders for tests, documentation (Wiki), licensing, and support scripts complete the overall organization.

##### Main Components and Their Relationships
- Frontend (ClientApp):
– A Teams tab for composing, previewing, and collaborating on messages.
– It communicates with backend APIs.
- Backend Web API (CompanyCommunicator):
– Hosts Controllers that expose endpoints for authentication, message management (draft, sent, delete notifications), and health checks.
– Uses services from the Common library for business logic.
– Integrates with authentication mechanisms (AAD, MSGraph).
- Common Library (CompanyCommunicator.Common):
– Implements repositories (for storing notification data, user data, team data, etc.) based on Azure Table storage or similar data sources.
– Provides services and adapters (e.g., Bot adapter, Microsoft Graph services, adaptive card creators) that serve both the backend and Azure Functions.
– Contains retry policies (PollyPolicy) and utility extensions to ease cross-component usage.
- Azure Functions:
– Data.Func: Handles periodic or trigger-based cleanup and data management tasks.
– Prep.Func: Manages orchestration workflows (e.g., queued jobs for preparing messages, aggregating recipients data, synchronizing data from Teams) before messages are sent.
– Send.Func: Responsible for the final sending of notifications (using queued messages and interfacing with Teams).
- Messaging and Integration Components:
– Message Queue services (send, data, export, prepare-to-send queues) are used heavily to decouple and orchestrate processing between components.
– Microsoft Graph integration for handling teams, users, and channels.
- Infrastructure/Deployment:
– ARM templates and scripts exist to provision the necessary Azure resources (app services, function apps, storage accounts, AAD apps, and Application Insights).

##### Architectural Patterns and Design Principles
- Modular Design: Separation of concerns by splitting the solution into separate projects/libraries (Common, Web API, Azure Functions, ClientApp).
- Microservice/Function-based Processing: Distinct responsibilities distributed among multiple Azure Function apps that perform background processing tasks.
- Repository and Adapter Patterns: Clear abstraction layers for accessing storage and handling external APIs.
- Messaging/Queue-Based Orchestration: Asynchronous communication and job orchestration using queues to handle message send workflows.
- Cloud Infrastructure-as-Code: Deployment artifacts (ARM templates, PowerShell scripts) enable repeatable, environment-specific deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        A("Teams Client App (React)"):::frontend
    end

    %% Backend Layer
    subgraph "Backend API"
        B("Web API (Controllers, Services, Pages)"):::backend
        C("Common Library (Repositories, Adapters, Policies)"):::common
    end

    %% Messaging / Queueing
    subgraph "Messaging & Queue Services"
        D("Message Queues"):::queue
    end

    %% Azure Functions Processing
    subgraph "Azure Functions"
        E("Data Function (Cleanup & Processing)"):::azure
        F("Prep Function (Job Orchestration)"):::azure
        G("Send Function (Message Dispatcher)"):::azure
    end

    %% External Services
    subgraph "External Services"
        H("Microsoft Graph & External APIs"):::external
        I("Azure Storage, Application Insights & AAD"):::external
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        J("ARM Templates & Deployment Scripts"):::deployment
    end

    %% Connections
    A -->|"API_call"| B
    B -->|"Uses"| C
    B -->|"PushesJobs"| D
    C -->|"Implements"| D
    D -->|"Triggers"| E
    D -->|"Triggers"| F
    D -->|"Triggers"| G
    E -->|"StatusUpdates"| B
    F -->|"StatusUpdates"| B
    G -->|"SendsNotifications"| H
    G -->|"Telemetry"| I
    B -->|"AuthCalls"| H
    C -->|"StorageAccess"| I
    J -->|"Provisions"| B
    J -->|"Provisions"| C
    J -->|"Provisions"| E
    J -->|"Provisions"| F
    J -->|"Provisions"| G
    J -->|"Provisions"| I

    %% Click Events
    click A "https://github.com/officedev/microsoft-teams-apps-company-communicator/tree/main/Source/CompanyCommunicator/ClientApp"
    click B "https://github.com/officedev/microsoft-teams-apps-company-communicator/tree/main/Source/CompanyCommunicator"
    click C "https://github.com/officedev/microsoft-teams-apps-company-communicator/blob/main/Source/CompanyCommunicator.Common"
    click D "https://github.com/officedev/microsoft-teams-apps-company-communicator/tree/main/Source/CompanyCommunicator.Common/Services/MessageQueues"
    click E "https://github.com/officedev/microsoft-teams-apps-company-communicator/blob/main/Source/CompanyCommunicator.Data.Func"
    click F "https://github.com/officedev/microsoft-teams-apps-company-communicator/blob/main/Source/CompanyCommunicator.Prep.Func"
    click G "https://github.com/officedev/microsoft-teams-apps-company-communicator/blob/main/Source/CompanyCommunicator.Send.Func"
    click J "https://github.com/officedev/microsoft-teams-apps-company-communicator/tree/main/Deployment"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef common fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef queue fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef azure fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef external fill:#fefefe,stroke:#6c757d,stroke-width:2px;
    classDef deployment fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
```
