# 3ved9969/ai-marketing-platform- architecture

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

- Interactive diagram: https://gitdiagram.com/3ved9969/ai-marketing-platform-
- Repository: https://github.com/3ved9969/ai-marketing-platform-

## Overview

This is a full-stack marketing CRM: users manage leads, campaigns, accounts, and analytics in the React UI; the FastAPI backend handles CRM operations and calls AI and scraping services. The AI service provides lead processing, content generation, campaign planning/analysis, and retrieval over ChromaDB; scraping discovers and enriches businesses, while Celery automation coordinates service calls and scheduled work. The README documents service-level wiring; several route and workflow implementations were not sampled, so those links are cited to the README rather than inferred from names.

Main entry points: [`ai-service/api_server.py`](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/api_server.py) (AI REST API), [`ai-service/workflows/content_workflow.py`](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/workflows/content_workflow.py) (Content generation), [`backend/app/main.py`](https://github.com/3ved9969/ai-marketing-platform-/blob/main/backend/app/main.py) (CRM API), [`scraper-service/api_server.py`](https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/api_server.py) (Scraper REST API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["CRM interface"]
  node_webapp["CRM pages<br/>[App.jsx]"]
  node_webapi["API clients<br/>[client.js]"]
end

subgraph group_crm["CRM backend"]
  node_crmapi["CRM API<br/>[main.py]"]
  node_routes["CRM routes"]
  node_crmservices["CRM services"]
  node_auth["Authentication<br/>[auth_service.py]"]
  node_crmdata[("CRM database<br/>[database.py]")]
end

subgraph group_ai["AI services"]
  node_aigateway["AI REST API<br/>[api_server.py]"]
  node_leadai["Lead processing"]
  node_contentai["Content generation"]
  node_campaignai["Campaign planning"]
  node_models["Model routing<br/>[model_router.py]"]
  node_rag["RAG retrieval<br/>[retriever.py]"]
  node_vectordb[("ChromaDB<br/>[vector_store.py]")]
  node_session["Session memory<br/>[session_memory.py]"]
end

subgraph group_discovery["Discovery and automation"]
  node_scrapeapi["Scraper REST API<br/>[api_server.py]"]
  node_scrape["Lead discovery<br/>[orchestrator.py]"]
  node_profile["Business profiles"]
  node_browser["Browser manager<br/>[browser_manager.py]"]
  node_worker["Celery pipeline<br/>[pipeline.py]"]
end

node_user(("CRM user"))
node_ollama["Ollama models"]
node_redis["Redis broker"]

node_user -->|"uses"| node_webapp
node_webapp -.->|"requests data"| node_webapi
node_webapi -->|"calls API"| node_crmapi
node_crmapi -->|"mounts routes"| node_routes
node_routes -.->|"delegates"| node_crmservices
node_crmservices -.->|"reads and writes"| node_crmdata
node_auth -->|"reads and writes"| node_crmdata
node_crmapi -->|"calls over HTTP"| node_aigateway
node_crmapi -->|"calls over HTTP"| node_scrapeapi
node_aigateway -->|"serves lead tasks"| node_leadai
node_aigateway -->|"serves content tasks"| node_contentai
node_aigateway -->|"serves campaign tasks"| node_campaignai
node_leadai -->|"gets LLM"| node_models
node_contentai -->|"generates with"| node_models
node_campaignai -->|"uses workflow"| node_contentai
node_models -->|"routes inference"| node_ollama
node_leadai -->|"retrieves context"| node_rag
node_rag -->|"searches and indexes"| node_vectordb
node_contentai -->|"uses content memory"| node_rag
node_contentai -.->|"uses session state"| node_session
node_scrapeapi -->|"dispatches scraping"| node_scrape
node_scrapeapi -->|"dispatches profiling"| node_profile
node_scrape -.->|"scrapes with"| node_browser
node_profile -->|"analyzes with"| node_browser
node_worker -->|"requests leads"| node_scrapeapi
node_worker -->|"requests AI work"| node_aigateway
node_worker -->|"uses broker"| node_redis

click node_webapp "https://github.com/3ved9969/ai-marketing-platform-/blob/main/frontend/src/App.jsx"
click node_webapi "https://github.com/3ved9969/ai-marketing-platform-/blob/main/frontend/src/api/client.js"
click node_crmapi "https://github.com/3ved9969/ai-marketing-platform-/blob/main/backend/app/main.py"
click node_routes "https://github.com/3ved9969/ai-marketing-platform-/tree/main/backend/app/routes"
click node_crmservices "https://github.com/3ved9969/ai-marketing-platform-/tree/main/backend/app/services"
click node_auth "https://github.com/3ved9969/ai-marketing-platform-/blob/main/backend/app/services/auth_service.py"
click node_crmdata "https://github.com/3ved9969/ai-marketing-platform-/blob/main/backend/app/database.py"
click node_aigateway "https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/api_server.py"
click node_leadai "https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/chains/lead_generation_chain.py"
click node_contentai "https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/workflows/content_workflow.py"
click node_campaignai "https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/workflows/campaign_workflow.py"
click node_models "https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/llm/model_router.py"
click node_rag "https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/rag/retriever.py"
click node_vectordb "https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/rag/vector_store.py"
click node_session "https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/memory/session_memory.py"
click node_scrapeapi "https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/api_server.py"
click node_scrape "https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/scraper_engine/orchestrator.py"
click node_profile "https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/business_intelligence_v1/business_intelligence/orchestrator/profile_orchestrator.py"
click node_browser "https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/scraper_engine/anti_ban/browser_manager.py"
click node_worker "https://github.com/3ved9969/ai-marketing-platform-/blob/main/automation/pipeline.py"

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_webapp,node_webapi,node_user toneBlue
class node_crmapi,node_routes,node_crmservices,node_auth,node_crmdata,node_redis toneAmber
class node_aigateway,node_leadai,node_contentai,node_campaignai,node_models,node_rag,node_vectordb,node_session toneMint
class node_scrapeapi,node_scrape,node_profile,node_browser,node_worker toneRose
class node_ollama toneIndigo
```

## Components

### CRM interface

- [CRM pages](https://github.com/3ved9969/ai-marketing-platform-/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API clients](https://github.com/3ved9969/ai-marketing-platform-/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### CRM backend

- [CRM API](https://github.com/3ved9969/ai-marketing-platform-/blob/main/backend/app/main.py): `backend/app/main.py`
- [CRM routes](https://github.com/3ved9969/ai-marketing-platform-/tree/main/backend/app/routes): `backend/app/routes`
- [CRM services](https://github.com/3ved9969/ai-marketing-platform-/tree/main/backend/app/services): `backend/app/services`
- [Authentication](https://github.com/3ved9969/ai-marketing-platform-/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [CRM database](https://github.com/3ved9969/ai-marketing-platform-/blob/main/backend/app/database.py): `backend/app/database.py`

### AI services

- [AI REST API](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/api_server.py): `ai-service/api_server.py`
- [Lead processing](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/chains/lead_generation_chain.py): `ai-service/chains/lead_generation_chain.py`
- [Content generation](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/workflows/content_workflow.py): `ai-service/workflows/content_workflow.py`
- [Campaign planning](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/workflows/campaign_workflow.py): `ai-service/workflows/campaign_workflow.py`
- [Model routing](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/llm/model_router.py): `ai-service/llm/model_router.py`
- [RAG retrieval](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/rag/retriever.py): `ai-service/rag/retriever.py`
- [ChromaDB](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/rag/vector_store.py): `ai-service/rag/vector_store.py`
- [Session memory](https://github.com/3ved9969/ai-marketing-platform-/blob/main/ai-service/memory/session_memory.py): `ai-service/memory/session_memory.py`

### Discovery and automation

- [Scraper REST API](https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/api_server.py): `scraper-service/api_server.py`
- [Lead discovery](https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/scraper_engine/orchestrator.py): `scraper-service/scraper_engine/orchestrator.py`
- [Business profiles](https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/business_intelligence_v1/business_intelligence/orchestrator/profile_orchestrator.py): `scraper-service/business_intelligence_v1/business_intelligence/orchestrator/profile_orchestrator.py`
- [Browser manager](https://github.com/3ved9969/ai-marketing-platform-/blob/main/scraper-service/scraper_engine/anti_ban/browser_manager.py): `scraper-service/scraper_engine/anti_ban/browser_manager.py`
- [Celery pipeline](https://github.com/3ved9969/ai-marketing-platform-/blob/main/automation/pipeline.py): `automation/pipeline.py`

### Other components

- **CRM user**
- **Ollama models**
- **Redis broker**

## Connections

- CRM user → CRM pages: uses (evidence: `frontend/src/App.jsx`)
- CRM pages → API clients: requests data
- API clients → CRM API: calls API (evidence: `README.md`)
- CRM API → CRM routes: mounts routes (evidence: `backend/app/main.py`)
- CRM routes → CRM services: delegates
- CRM services → CRM database: reads and writes
- Authentication → CRM database: reads and writes (evidence: `backend/app/services/auth_service.py`)
- CRM API → AI REST API: calls over HTTP (evidence: `README.md`)
- CRM API → Scraper REST API: calls over HTTP (evidence: `README.md`)
- AI REST API → Lead processing: serves lead tasks (evidence: `README.md`)
- AI REST API → Content generation: serves content tasks (evidence: `README.md`)
- AI REST API → Campaign planning: serves campaign tasks (evidence: `README.md`)
- Lead processing → Model routing: gets LLM (evidence: `ai-service/chains/lead_generation_chain.py`)
- Content generation → Model routing: generates with
- Campaign planning → Content generation: uses workflow (evidence: `ai-service/workflows/campaign_workflow.py`)
- Model routing → Ollama models: routes inference (evidence: `ai-service/llm/model_router.py`)
- Lead processing → RAG retrieval: retrieves context (evidence: `ai-service/chains/lead_generation_chain.py`)
- RAG retrieval → ChromaDB: searches and indexes (evidence: `ai-service/rag/retriever.py`)
- Content generation → RAG retrieval: uses content memory
- Content generation → Session memory: uses session state (evidence: `ai-service/workflows/content_workflow.py`)
- Scraper REST API → Lead discovery: dispatches scraping (evidence: `scraper-service/api_server.py`)
- Scraper REST API → Business profiles: dispatches profiling (evidence: `scraper-service/api_server.py`)
- Lead discovery → Browser manager: scrapes with
- Business profiles → Browser manager: analyzes with
- Celery pipeline → Scraper REST API: requests leads (evidence: `README.md`)
- Celery pipeline → AI REST API: requests AI work (evidence: `README.md`)
- Celery pipeline → Redis broker: uses broker (evidence: `README.md`)
