How officedev/microsoft-teams-apps-company-communicator works
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.