# vaishnavi-newalkar/contentmesh_content_generator architecture

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

- Interactive diagram: https://gitdiagram.com/vaishnavi-newalkar/contentmesh_content_generator
- Repository: https://github.com/vaishnavi-newalkar/contentmesh_content_generator

## Overview

#### Purpose and Entry Points
ContentMesh is an AI-driven enterprise content pipeline: it creates content from a brief, reviews it for compliance, localizes it, adapts it to delivery channels, and distributes or simulates distribution. It can run as a CrewAI CLI workflow or a FastAPI service with a static demo dashboard.

Primary entry points:
- API server and frontend serving: `app.py`
- CrewAI/CLI execution: `src/contentmesh/main.py`
- One-command container/service startup: `scripts/start.sh`
- Browser demo UI: `frontend/index.html`

#### HTTP API and User-Facing Execution Boundary
`app.py` is the service boundary. It exposes generation, demo-result, health, and server-sent progress endpoints, and serves the frontend. A client submits a structured brief containing topic, audience, tone, requested locales/channels, compliance rules, and optional recipient email.

The API path separates interactive clients from the agent runtime:
- Request/response schemas are centralized in `src/contentmesh/schemas.py`.
- Progress can be streamed independently of final pipeline output.
- The prebuilt demo result permits UI use without LLM or delivery credentials.

#### Sequential Multi-Agent Orchestration
`src/contentmesh/crew.py` defines the CrewAI `@CrewBase` orchestration layer. It constructs the five-agent pipeline with a sequential process, so each downstream task receives earlier task context rather than independently regenerating the brief.

Architecture-defining stages are configured rather than hard-coded:
1. Content creation
2. Compliance review
3. Localization
4. Per-channel formatting
5. Distribution

The runtime implementation is in `src/contentmesh/crew.py`; agent identities and task dependencies live in:
- `src/contentmesh/config/agents.yaml`
- `src/contentmesh/config/tasks.yaml`

#### Configuration-Driven Agent and Task Contracts
The YAML files are the pipeline’s primary behavioral contract. `agents.yaml` supplies each agent’s role, goal, and backstory; `tasks.yaml` supplies prompts, expected output, owning agent, and upstream context. This makes agent behavior and stage ordering editable without restructuring Python orchestration.

`src/contentmesh/main.py` invokes the crew for CLI execution, including the standard CrewAI-compatible path that produces workflow output. `src/contentmesh/llm_config.py` is the likely central boundary for selecting/configuring the LLM provider and credentials.

#### Validation, Guardrails, and Observability
Structured data contracts and safety controls are separate from agent prompts:
- `src/contentmesh/schemas.py` defines typed input/output shapes for API and pipeline payloads.
- `src/contentmesh/guardrails.py` contains policy or output-validation logic around generated enterprise content.
- `src/contentmesh/token_tracker.py` records model-token consumption; `token_usage_log.json` is the persisted usage artifact.
- `src/contentmesh/analytics.py` provides a distinct analytics layer for pipeline or distribution metrics.
- `src/contentmesh/database.py` is the persistence boundary if run-state, results, or analytics require storage.

#### Distribution and External Integrations
The final distribution stage is isolated behind tools in `src/contentmesh/tools/distributor_tools.py`. It supports email, Slack posting, and distribution logging, allowing the agent workflow to invoke delivery operations without embedding transport logic in orchestration.

Material external dependencies and runtimes:
- Anthropic-backed LLM access via `ANTHROPIC_API_KEY`.
- Optional SMTP server for email delivery.
- Optional Slack Incoming Webhook for Slack delivery.
- FastAPI/Uvicorn for HTTP serving and SSE.
- CrewAI for multi-agent execution.
- Docker deployment through `Dockerfile` and `docker-compose.yml`.

Absent SMTP or Slack credentials, distribution remains a demo/simulated operation rather than blocking the content-generation pipeline.

Main entry points: [`src/contentmesh/crew.py`](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/crew.py) (Sequential crew), [`app.py`](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/app.py) (FastAPI service), [`src/contentmesh/tools/distributor_tools.py`](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/tools/distributor_tools.py) (Distribution tools), [`frontend/index.html`](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/frontend/index.html) (Static dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Entry points"]
  node_browser(("Demo browser<br/>client"))
  node_frontend["Static dashboard<br/>frontend<br/>[index.html]"]
  node_api["FastAPI service<br/>HTTP/SSE boundary<br/>[app.py]"]
  node_cli["CrewAI CLI<br/>CLI entry point<br/>[main.py]"]
  node_startup["Container startup<br/>startup script<br/>[start.sh]"]
end

subgraph group_runtime["Pipeline runtime"]
  node_crew["Sequential crew<br/>CrewAI orchestration<br/>[crew.py]"]
  node_agents["Agent contracts<br/>agent configuration<br/>[agents.yaml]"]
  node_tasks["Task contracts<br/>task configuration<br/>[tasks.yaml]"]
  node_llm{{"Anthropic LLM<br/>external LLM<br/>[llm_config.py]"}}
end

subgraph group_contracts["Contracts and controls"]
  node_schemas["Payload schemas<br/>typed contracts<br/>[schemas.py]"]
  node_guardrails["Content guardrails<br/>validation policy<br/>[guardrails.py]"]
  node_token_tracker["Token tracking<br/>usage observer<br/>[token_tracker.py]"]
  node_token_log["Token usage log<br/>usage artifact"]
end

subgraph group_delivery["Distribution and operations"]
  node_analytics["Analytics layer<br/>metrics service<br/>[analytics.py]"]
  node_database[("Persistence boundary<br/>database access<br/>[database.py]")]
  node_distribution["Distribution tools<br/>delivery adapter"]
  node_channels{{"SMTP and Slack<br/>external delivery"}}
  node_deployment["Docker deployment<br/>container deployment"]
  node_compose["Compose service<br/>service topology<br/>[docker-compose.yml]"]
end

node_browser -->|"loads"| node_frontend
node_frontend -->|"briefs, results, SSE"| node_api
node_api -->|"validates payloads"| node_schemas
node_api -->|"starts generation"| node_crew
node_cli -->|"runs workflow"| node_crew
node_startup -->|"starts service"| node_api
node_crew -->|"loads identities"| node_agents
node_crew -->|"loads sequential stages"| node_tasks
node_crew -->|"generates content"| node_llm
node_crew -->|"validates output"| node_guardrails
node_crew -->|"final delivery stage"| node_distribution
node_crew -->|"records usage"| node_token_tracker
node_token_tracker -->|"persists tokens"| node_token_log
node_distribution -->|"delivers when configured"| node_channels
node_distribution -->|"emits metrics"| node_analytics
node_analytics -.->|"persists metrics"| node_database
node_api -.->|"stores runs/results"| node_database
node_compose -->|"builds service"| node_deployment
node_deployment -->|"runs"| node_startup

click node_frontend "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/frontend/index.html"
click node_api "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/app.py"
click node_cli "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/main.py"
click node_startup "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/scripts/start.sh"
click node_schemas "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/schemas.py"
click node_guardrails "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/guardrails.py"
click node_crew "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/crew.py"
click node_agents "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/config/agents.yaml"
click node_tasks "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/config/tasks.yaml"
click node_llm "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/llm_config.py"
click node_token_tracker "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/token_tracker.py"
click node_token_log "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/token_usage_log.json"
click node_analytics "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/analytics.py"
click node_database "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/database.py"
click node_distribution "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/tools/distributor_tools.py"
click node_deployment "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/Dockerfile"
click node_compose "https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/docker-compose.yml"

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_browser,node_frontend,node_api,node_cli,node_startup toneBlue
class node_crew,node_agents,node_tasks,node_llm toneAmber
class node_schemas,node_guardrails,node_token_tracker,node_token_log toneMint
class node_analytics,node_database,node_distribution,node_channels,node_deployment,node_compose toneRose
```

## Components

### Entry points

- **Demo browser**: client · Submits briefs and consumes progress/results.
- [Static dashboard](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/frontend/index.html): frontend · `frontend/index.html`
- [FastAPI service](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/app.py): HTTP/SSE boundary · Serves the dashboard, API endpoints, demo results, and progress streams. · `app.py`
- [CrewAI CLI](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/main.py): CLI entry point · `src/contentmesh/main.py`
- [Container startup](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/scripts/start.sh): startup script · `scripts/start.sh`

### Pipeline runtime

- [Sequential crew](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/crew.py): CrewAI orchestration · Runs five context-carrying stages in order. · `src/contentmesh/crew.py`
- [Agent contracts](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/config/agents.yaml): agent configuration · Roles, goals, and backstories for pipeline agents. · `src/contentmesh/config/agents.yaml`
- [Task contracts](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/config/tasks.yaml): task configuration · Prompts, owners, expected outputs, and upstream context. · `src/contentmesh/config/tasks.yaml`
- [Anthropic LLM](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/llm_config.py): external LLM · Selected and configured with provider credentials. · `src/contentmesh/llm_config.py`

### Contracts and controls

- [Payload schemas](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/schemas.py): typed contracts · Structured brief and pipeline input/output shapes. · `src/contentmesh/schemas.py`
- [Content guardrails](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/guardrails.py): validation policy · `src/contentmesh/guardrails.py`
- [Token tracking](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/token_tracker.py): usage observer · `src/contentmesh/token_tracker.py`
- [Token usage log](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/token_usage_log.json): usage artifact · `token_usage_log.json`

### Distribution and operations

- [Analytics layer](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/analytics.py): metrics service · `src/contentmesh/analytics.py`
- [Persistence boundary](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/database.py): database access · Stores run state, results, or analytics when enabled. · `src/contentmesh/database.py`
- [Distribution tools](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/src/contentmesh/tools/distributor_tools.py): delivery adapter · Email, Slack, and simulated distribution logging. · `src/contentmesh/tools/distributor_tools.py`
- **SMTP and Slack**: external delivery · Optional credentials enable live delivery; otherwise distribution is simulated.
- [Docker deployment](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/Dockerfile): container deployment · `Dockerfile`
- [Compose service](https://github.com/vaishnavi-newalkar/contentmesh_content_generator/blob/main/docker-compose.yml): service topology · `docker-compose.yml`

## Connections

- Demo browser → Static dashboard: loads
- Static dashboard → FastAPI service: briefs, results, SSE
- FastAPI service → Payload schemas: validates payloads
- FastAPI service → Sequential crew: starts generation
- CrewAI CLI → Sequential crew: runs workflow
- Container startup → FastAPI service: starts service
- Sequential crew → Agent contracts: loads identities
- Sequential crew → Task contracts: loads sequential stages
- Sequential crew → Anthropic LLM: generates content
- Sequential crew → Content guardrails: validates output
- Sequential crew → Distribution tools: final delivery stage
- Sequential crew → Token tracking: records usage
- Token tracking → Token usage log: persists tokens
- Distribution tools → SMTP and Slack: delivers when configured
- Distribution tools → Analytics layer: emits metrics
- Analytics layer → Persistence boundary: persists metrics
- FastAPI service → Persistence boundary: stores runs/results
- Compose service → Docker deployment: builds service
- Docker deployment → Container startup: runs
