How narender-rk10/marketing-ai-studio works
1. Overall shape
- This is a monorepo with a React/Vite frontend and a FastAPI/Python backend.
- The backend is the system of record and orchestration layer; the frontend is primarily a visual control surface for managing campaigns, agents, assets, and workspace state.
2. Frontend boundary
- The frontend lives under frontend/src and is organized around workspace/canvas UX, agent configuration/forms, asset and prompt management, and analytics views.
- State is managed with Zustand, API calls go through frontend/src/services/api.ts, and realtime updates use useWebSocket.
- The UI is built around many agent-specific output components and form definitions, which means the frontend is tightly coupled to the backend’s agent catalog and output schemas.
3. Backend entrypoints and API surface
- backend/app/main.py is the application entrypoint.
- The backend is split into routers for auth, campaigns, workspaces, analytics, agents, and websocket handling.
- backend/app/agents/api_router.py and v3_registry.py suggest a dedicated agent API layer that dispatches requests into the agent system rather than embedding logic directly in generic CRUD endpoints.
4. Core orchestration layer
- The heart of the system is the agent orchestration stack in backend/app/agents.
- Key coordination pieces include:
- executor.py for running agent tasks,
- registry.py / v3_registry.py for agent discovery and routing,
- base.py for shared agent behavior,
- control/ for intent detection, requirement discovery, and conversation state,
- fallback_forms.py and tools/dynamic_form.py for structured input handling.
- This layer is what turns a user request into a specific specialized agent invocation with the right prompt, tools, and output schema.
5. Specialized agent domains
- The repository’s main functional breadth is in the large set of agent domains:
- Brand, creative, content, social, SEO, video, audio, ads, growth, image, visual, and adaptation.
- Each domain contains multiple focused agents, and the naming indicates a pattern: one agent per marketing task or channel-specific output.
- This makes the architecture catalog-driven: the system is not one generic assistant, but a large collection of constrained, task-specific agent workflows.
6. Prompt and tool architecture
- Agent behavior is heavily prompt-driven through backend/app/prompts/agents/*.yaml and backend/app/prompts/tools/*.yaml.
- The tools layer in backend/app/tools and backend/app/agents/tools provides reusable capabilities such as brand tools, creative tools, feedback tools, media tools, and scraping tools.
- This is an important boundary: prompts define the task logic and output contract, while tools provide the agent’s actionable capabilities.
7. Model/provider integration
- External AI/model access is abstracted in backend/app/providers.
- The provider set includes Gemini, Veo, GCS, and specialized adapters like nano_banana.
- backend/app/core/llm.py and the config files indicate model selection is environment-driven, with separate models for text, image, video, edge/experimental use cases.
- Architecturally, this is a multi-model backend where different agent classes route to different model capabilities depending on the task.
8. Persistence and domain data
- MongoDB is the primary application database, as reflected by the README and the presence of model/repository layers.
- backend/app/models defines the domain objects: users, workspaces, campaigns, conversations, messages, assets, versions, prompt library, analytics logs, agent logs, and related workspace/context records.
- backend/app/db/repositories.py and backend/app/database.py indicate a repository-style persistence boundary between API/service logic and storage.
- The data model suggests the platform keeps both operational state (workspace/campaign/user) and observability/history (logs, versions, analytics).
9. Workspace, campaign, and asset flows
- backend/app/workspaces and backend/app/campaigns are separate product areas.
- Workspaces appear to hold the “canvas” or operating environment: documents, prompts, scraper inputs, and assets.
- Campaign services coordinate marketing deliverables, while the workspace/asset layers manage the artifacts produced by agents.
- Google Cloud Storage (providers/gcs.py) is used for durable media storage, which is especially important for generated images, mockups, and videos.
10. Realtime interaction and collaboration
- backend/app/websocket provides a realtime channel, likely used for streaming agent progress, workspace updates, and live UI synchronization.
- backend/app/core/context_vars.py, middleware.py, and session_manager.py imply request/session scoping and conversational context tracking across agent runs.
- This supports the product’s interactive feel: users can launch agent tasks and see results or partial progress without waiting for a purely synchronous request/response cycle.
11. Analytics and feedback loop
- backend/app/analytics and services/analytics.py capture usage and performance data.
- backend/app/agents/feedback includes optimizer, quality suggestion, and version management, which indicates a built-in improvement loop around generated outputs.
- The architecture therefore includes not just generation, but measurement and refinement of agent outputs over time.
12. Supporting services
- backend/app/services contains the operational glue:
- campaign_manager and context_manager for orchestration,
- kb_processor for knowledge base/document processing,
- scraper for external content ingestion,
- image_generator, video_generator, and audio_generator for media pipeline execution,
- prompt_utils and session_manager for prompt/session handling.
- These services sit between the API/router layer and the agents/providers, giving the system its domain-specific orchestration.
13. Auth and security boundary
- backend/app/auth plus backend/app/core/security.py and dependencies.py define the authentication and authorization layer.
- This protects workspace, campaign, and generation endpoints, and likely scopes data by user/workspace.
- In an architecture diagram, auth should be shown as a cross-cutting gate in front of the product API, not as a separate subsystem.
14. Deployment/runtime
- The project is containerized with Docker, including a root Dockerfile, backend Dockerfile, frontend Dockerfile, and docker-compose.yml.
- The README indicates deployment on Python 3.12, FastAPI, React 18, and Google Cloud services.
- The external infrastructure dependencies that materially affect architecture are MongoDB, Google Cloud Storage, and the Google AI model APIs.
15. How to draw the main data flow
- A useful diagram would show:
- Frontend UI → FastAPI routers → agent orchestration / service layer → provider APIs and tools → MongoDB / GCS
- with WebSocket returning live status and generated results back to the UI.
- The key architectural idea is that the system is a marketing workflow platform built around a registry of specialized AI agents, not a single chat interface.
Main entry points: App.tsx App shell · main.py API app · executor.py Orchestrator · api_router.py Agent API
Components 21
Frontend
React/Vite control surface
- App shell · Top-level UI composition and route switching
frontend/src/App.tsx - Canvas UX · Workspace, canvas, and panel interactions
frontend/src/components/ReactFlow/CanvasPanel.tsx - Agent forms · Shared forms and prompt selection for agent runs
frontend/src/components/Core/AgentForm.tsx - Agent outputs · Agent-specific output views and result formatting
frontend/src/components/Core/agents/GenericOutput.tsx - App state · Client-side workspace, agent, and UI state
frontend/src/store/appStore.ts - API client · Frontend service layer for backend requests
frontend/src/services/api.ts - Realtime hook · Streams live task progress and workspace updates
frontend/src/hooks/useWebSocket.ts
Backend
FastAPI orchestration layer
- API app · Application bootstrap and router wiring
backend/app/main.py - Auth · Authentication and authorization boundary
backend/app/auth/router.py - Product APIs · Campaign and workspace API surface
backend/app/workspaces/router.py - WebSocket · Streaming and live session handlers
backend/app/websocket/handlers.py - Agent API · Routes requests into the specialized agent system
backend/app/agents/api_router.py - Orchestrator · Executes agent tasks and manages conversation state
backend/app/agents/executor.py - Agent registry · Agent discovery, routing, and versioned registration
backend/app/agents/v3_registry.py - Agent domains · Brand, content, creative, social, SEO, video, image, and growth agents
backend/app/agents/brand/brand_identity.py - Prompts & tools · YAML prompts and reusable tool definitions
backend/app/prompts/agents/brand_identity.yaml - Services · Campaign, context, media, scraping, and session helpers
backend/app/services/campaign_manager.py - Data layer · Mongo-style domain models, repositories, and seed data
backend/app/db/repositories.py
External
Model, storage, and database dependencies
- Model APIs · Gemini, Veo, and other AI provider integrations
backend/app/providers/gemini.py - Storage · Durable media and artifact storage
backend/app/providers/gcs.py - MongoDB · Primary persistence for users, workspaces, campaigns, assets, logs, and versions
backend/app/core/database.py
Connections 23
- App shell → Canvas UX: renders · Main application mounts workspace and canvas views
- App shell → Agent forms: uses · Agent launch and configuration forms
- App shell → Agent outputs: shows · Result rendering for agent outputs
- App shell → App state: reads/writes · UI state and selection state flow through Zustand
- App shell → API client: calls · Primary backend HTTP client
- App shell → Realtime hook: subscribes · Realtime updates from backend
- API client → API app: HTTP · Frontend requests land in FastAPI
- Realtime hook → WebSocket: WS · Live streaming and progress events
- API app → Auth: protects · Auth gate in front of product routes
- API app → Product APIs: mounts · Workspace and campaign endpoints
- API app → Agent API: mounts · Agent invocation surface
- API app → WebSocket: mounts · Realtime endpoint registration
- Agent API → Agent registry: dispatches to · Resolves agent handlers from catalog
- Agent API → Orchestrator: executes via · Runs specialized agent workflows
- Orchestrator → Services: coordinates · Uses shared services for campaign, media, scraper, and session work
- Orchestrator → Prompts & tools: loads · Prompt templates and tool contracts
- Agent registry → Agent domains: indexes · Specialized marketing agent implementations
- Agent domains → Model APIs: invokes · Model-backed generation and reasoning
- Services → Storage: stores media · Generated assets and large artifacts
- Services → Data layer: persists · Operational and historical domain records
- Data layer → MongoDB: writes/reads · Primary application database
- Product APIs → Data layer: loads · Workspace and campaign state
- WebSocket → Orchestrator: streams · Emits progress from running agents