# sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation architecture

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

- Interactive diagram: https://gitdiagram.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation
- Repository: https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation

## Overview

OmniMarket AI is a merchant-facing social marketing platform. Its main workflow is to enter product details, generate marketing content and product imagery, then save, schedule, or publish posts to a connected Facebook Page. Separate capabilities include account and Page connection, analytics, scheduled publishing, connection health, and webhook-driven auto-replies. The excerpts show the photocard orchestration and parts of post, Facebook, and authentication flows; several other feature implementations are unsampled, so their internal links are omitted.

Main entry points: [`backend/controllers/photocardController.js`](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/photocardController.js) (Photocard workflow), [`backend/app.js`](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/app.js) (API application), [`backend/controllers/facebookController.js`](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/facebookController.js) (Facebook controller), [`backend/controllers/postController.js`](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/postController.js) (Post controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Merchant app"]
  node_app["App and routes<br/>[App.jsx]"]
  node_rag["Post generator"]
  node_rag_hook["Generation state<br/>[useRAGPost.js]"]
  node_frontend_ai["AI client<br/>[aiService.js]"]
  node_frontend_posts["Post client<br/>[postService.js]"]
end

subgraph group_access["Accounts and Pages"]
  node_frontend_auth["Auth context<br/>[AuthContext.jsx]"]
  node_auth_client["Auth client<br/>[authService.js]"]
  node_api["API application<br/>[app.js]"]
  node_auth_controller["Auth controller<br/>[authController.js]"]
  node_auth_service["Auth service<br/>[authService.js]"]
  node_user[("User records<br/>[User.js]")]
  node_auth_middleware["Auth middleware<br/>[authMiddleware.js]"]
end

subgraph group_content["Content creation"]
  node_ai_controller["AI controller<br/>[aiController.js]"]
  node_ai_service["AI generation<br/>[aiService.js]"]
  node_rag_service["Product RAG<br/>[ragService.js]"]
  node_photocard_controller["Photocard workflow"]
  node_analysis["Product analysis"]
  node_templates["Template selection<br/>[templateService.js]"]
  node_image_gen["Background generation<br/>[imageGenService.js]"]
  node_compositor["Image composition"]
  node_cloudinary["Image storage"]
  node_photocard_store[("Photocard records<br/>[Photocard.js]")]
end

subgraph group_publishing["Publishing and engagement"]
  node_facebook_controller["Facebook controller"]
  node_page_service["Facebook Pages"]
  node_publisher["Post publisher<br/>[publishService.js]"]
  node_scheduled["Scheduled posts"]
  node_post_controller["Post controller<br/>[postController.js]"]
  node_post_store[("Post records<br/>[Post.js]")]
  node_marketing_store[("Marketing content")]
end

subgraph group_insights["Operations and insights"]
  node_analytics["Analytics services"]
  node_health["Connection health"]
  node_autoreply["Auto-reply rules"]
end

node_merchant(("Merchant"))
node_facebook{{"Meta Graph API"}}

node_merchant -->|"uses"| node_app
node_app -->|"renders"| node_rag
node_rag -->|"uses"| node_rag_hook
node_rag_hook -->|"requests generation"| node_frontend_ai
node_rag_hook -->|"uploads images"| node_frontend_posts
node_frontend_auth -->|"uses"| node_auth_client
node_auth_client -->|"requests auth endpoints"| node_api
node_api -->|"mounts auth routes"| node_auth_controller
node_auth_controller -->|"delegates"| node_auth_service
node_auth_service -->|"reads and updates"| node_user
node_auth_service -->|"exchanges Page tokens"| node_page_service
node_auth_middleware -->|"loads user"| node_user
node_api -->|"mounts Facebook routes"| node_facebook_controller
node_facebook_controller -->|"manages Pages"| node_page_service
node_facebook_controller -->|"requests publishing"| node_publisher
node_publisher -.->|"publishes"| node_facebook
node_facebook_controller -.->|"handles webhook events"| node_autoreply
node_api -->|"mounts AI routes"| node_ai_controller
node_rag_hook -.->|"requests generation"| node_ai_service
node_ai_controller -.->|"delegates"| node_ai_service
node_ai_service -->|"uses product context"| node_rag_service
node_rag_service -->|"requests generation"| node_ai_service
node_api -->|"mounts photocard routes"| node_photocard_controller
node_photocard_controller -->|"analyzes product"| node_analysis
node_photocard_controller -->|"selects template"| node_templates
node_photocard_controller -->|"gets background"| node_image_gen
node_photocard_controller -->|"composes image"| node_compositor
node_photocard_controller -.->|"stores image"| node_cloudinary
node_photocard_controller -->|"saves photocard"| node_photocard_store
node_photocard_controller -->|"auto-saves post"| node_post_store
node_api -->|"mounts post routes"| node_post_controller
node_post_controller -->|"schedules and lists"| node_scheduled
node_scheduled -->|"reads and writes"| node_post_store
node_scheduled -->|"uses Page connections"| node_page_service
node_scheduled -.->|"publishes scheduled posts"| node_facebook
node_post_controller -->|"reads and updates"| node_post_store
node_post_controller -->|"reads content"| node_marketing_store
node_post_controller -->|"uses Page connection"| node_page_service
node_api -->|"mounts analytics routes"| node_analytics
node_facebook_controller -->|"checks connection"| node_health
node_facebook_controller -->|"reads history"| node_marketing_store

click node_app "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/App.jsx"
click node_rag "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/components/RAGPostGenerator.jsx"
click node_rag_hook "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/hooks/useRAGPost.js"
click node_frontend_ai "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/services/aiService.js"
click node_frontend_posts "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/services/postService.js"
click node_frontend_auth "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/context/AuthContext.jsx"
click node_auth_client "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/services/authService.js"
click node_api "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/app.js"
click node_auth_controller "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/authController.js"
click node_auth_service "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/authService.js"
click node_user "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/models/User.js"
click node_auth_middleware "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/middleware/authMiddleware.js"
click node_facebook_controller "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/facebookController.js"
click node_page_service "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/facebookPageService.js"
click node_publisher "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/publishService.js"
click node_scheduled "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/scheduledPostService.js"
click node_post_controller "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/postController.js"
click node_post_store "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/models/Post.js"
click node_marketing_store "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/models/MarketingContent.js"
click node_ai_controller "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/aiController.js"
click node_ai_service "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/aiService.js"
click node_rag_service "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/ragService.js"
click node_photocard_controller "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/photocardController.js"
click node_analysis "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/geminiAnalysisService.js"
click node_templates "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/templateService.js"
click node_image_gen "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/imageGenService.js"
click node_compositor "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/sharpCompositorService.js"
click node_cloudinary "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/cloudinaryService.js"
click node_photocard_store "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/models/Photocard.js"
click node_analytics "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/analyticsService.js"
click node_health "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/connectionHealthService.js"
click node_autoreply "https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/autoReplyService.js"

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_app,node_rag,node_rag_hook,node_frontend_ai,node_frontend_posts toneBlue
class node_frontend_auth,node_auth_client,node_api,node_auth_controller,node_auth_service,node_user,node_auth_middleware toneAmber
class node_ai_controller,node_ai_service,node_rag_service,node_photocard_controller,node_analysis,node_templates,node_image_gen,node_compositor,node_cloudinary,node_photocard_store,node_facebook toneMint
class node_facebook_controller,node_page_service,node_publisher,node_scheduled,node_post_controller,node_post_store,node_marketing_store toneRose
class node_analytics,node_health,node_autoreply,node_merchant toneIndigo
```

## Components

### Merchant app

- [App and routes](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Post generator](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/components/RAGPostGenerator.jsx): `frontend/src/components/RAGPostGenerator.jsx`
- [Generation state](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/hooks/useRAGPost.js): `frontend/src/hooks/useRAGPost.js`
- [AI client](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/services/aiService.js): `frontend/src/services/aiService.js`
- [Post client](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/services/postService.js): `frontend/src/services/postService.js`

### Accounts and Pages

- [Auth context](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Auth client](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/frontend/src/services/authService.js): `frontend/src/services/authService.js`
- [API application](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/app.js): `backend/app.js`
- [Auth controller](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Auth service](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/authService.js): `backend/services/authService.js`
- [User records](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/models/User.js): `backend/models/User.js`
- [Auth middleware](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`

### Content creation

- [AI controller](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/aiController.js): `backend/controllers/aiController.js`
- [AI generation](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/aiService.js): `backend/services/aiService.js`
- [Product RAG](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/ragService.js): `backend/services/ragService.js`
- [Photocard workflow](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/photocardController.js): `backend/controllers/photocardController.js`
- [Product analysis](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/geminiAnalysisService.js): `backend/services/geminiAnalysisService.js`
- [Template selection](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/templateService.js): `backend/services/templateService.js`
- [Background generation](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/imageGenService.js): `backend/services/imageGenService.js`
- [Image composition](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/sharpCompositorService.js): `backend/services/sharpCompositorService.js`
- [Image storage](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/cloudinaryService.js): `backend/services/cloudinaryService.js`
- [Photocard records](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/models/Photocard.js): `backend/models/Photocard.js`

### Publishing and engagement

- [Facebook controller](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/facebookController.js): `backend/controllers/facebookController.js`
- [Facebook Pages](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/facebookPageService.js): `backend/services/facebookPageService.js`
- [Post publisher](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/publishService.js): `backend/services/publishService.js`
- [Scheduled posts](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/scheduledPostService.js): `backend/services/scheduledPostService.js`
- [Post controller](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/controllers/postController.js): `backend/controllers/postController.js`
- [Post records](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/models/Post.js): `backend/models/Post.js`
- [Marketing content](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/models/MarketingContent.js): `backend/models/MarketingContent.js`

### Operations and insights

- [Analytics services](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/analyticsService.js): `backend/services/analyticsService.js`
- [Connection health](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/connectionHealthService.js): `backend/services/connectionHealthService.js`
- [Auto-reply rules](https://github.com/sheikhrasel35/ai_powered_autonomous_e-commerce_product_marketing_automation/blob/moufik_391/backend/services/autoReplyService.js): `backend/services/autoReplyService.js`

### Other components

- **Merchant**
- **Meta Graph API**

## Connections

- Merchant → App and routes: uses
- App and routes → Post generator: renders (evidence: `frontend/src/App.jsx`)
- Post generator → Generation state: uses (evidence: `frontend/src/components/RAGPostGenerator.jsx`)
- Generation state → AI client: requests generation (evidence: `frontend/src/hooks/useRAGPost.js`)
- Generation state → Post client: uploads images (evidence: `frontend/src/hooks/useRAGPost.js`)
- Auth context → Auth client: uses (evidence: `frontend/src/context/AuthContext.jsx`)
- Auth client → API application: requests auth endpoints (evidence: `frontend/src/services/authService.js`)
- API application → Auth controller: mounts auth routes (evidence: `backend/app.js`)
- Auth controller → Auth service: delegates (evidence: `backend/controllers/authController.js`)
- Auth service → User records: reads and updates (evidence: `backend/services/authService.js`)
- Auth service → Facebook Pages: exchanges Page tokens (evidence: `backend/services/authService.js`)
- Auth middleware → User records: loads user (evidence: `backend/middleware/authMiddleware.js`)
- API application → Facebook controller: mounts Facebook routes (evidence: `backend/app.js`)
- Facebook controller → Facebook Pages: manages Pages (evidence: `backend/controllers/facebookController.js`)
- Facebook controller → Post publisher: requests publishing (evidence: `backend/controllers/facebookController.js`)
- Post publisher → Meta Graph API: publishes
- Facebook controller → Auto-reply rules: handles webhook events (evidence: `backend/controllers/facebookController.js`)
- API application → AI controller: mounts AI routes (evidence: `backend/app.js`)
- Generation state → AI generation: requests generation
- AI controller → AI generation: delegates
- AI generation → Product RAG: uses product context (evidence: `backend/services/ragService.js`)
- Product RAG → AI generation: requests generation (evidence: `backend/services/ragService.js`)
- API application → Photocard workflow: mounts photocard routes (evidence: `backend/app.js`)
- Photocard workflow → Product analysis: analyzes product (evidence: `backend/controllers/photocardController.js`)
- Photocard workflow → Template selection: selects template (evidence: `backend/controllers/photocardController.js`)
- Photocard workflow → Background generation: gets background (evidence: `backend/controllers/photocardController.js`)
- Photocard workflow → Image composition: composes image (evidence: `backend/controllers/photocardController.js`)
- Photocard workflow → Image storage: stores image (evidence: `backend/controllers/photocardController.js`)
- Photocard workflow → Photocard records: saves photocard (evidence: `backend/controllers/photocardController.js`)
- Photocard workflow → Post records: auto-saves post (evidence: `backend/controllers/photocardController.js`)
- API application → Post controller: mounts post routes (evidence: `backend/app.js`)
- Post controller → Scheduled posts: schedules and lists (evidence: `backend/controllers/postController.js`)
- Scheduled posts → Post records: reads and writes (evidence: `backend/services/scheduledPostService.js`)
- Scheduled posts → Facebook Pages: uses Page connections (evidence: `backend/services/scheduledPostService.js`)
- Scheduled posts → Meta Graph API: publishes scheduled posts
- Post controller → Post records: reads and updates (evidence: `backend/controllers/postController.js`)
- Post controller → Marketing content: reads content (evidence: `backend/controllers/postController.js`)
- Post controller → Facebook Pages: uses Page connection (evidence: `backend/controllers/postController.js`)
- API application → Analytics services: mounts analytics routes (evidence: `backend/app.js`)
- Facebook controller → Connection health: checks connection (evidence: `backend/controllers/facebookController.js`)
- Facebook controller → Marketing content: reads history (evidence: `backend/controllers/facebookController.js`)
