# safa-kaware/socialflow-ai architecture

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

- Interactive diagram: https://gitdiagram.com/safa-kaware/socialflow-ai
- Repository: https://github.com/safa-kaware/socialflow-ai

## Overview

SocialFlow is a Telegram content-generation and publishing application. A user creates a draft in the app, reviews or edits it, then approves and publishes it; the app also provides post history, queue, calendar, analytics, automation and settings views. The frontend calls serverless API endpoints for generation, post management and publishing, which share a Supabase client. The workflow files indicate additional generation/review and Telegram-publishing automation. Their internal connections are not established by the excerpts, so those links are omitted.

Main entry points: [`frontend/src/lib/api.js`](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/lib/api.js) (API client), [`frontend/src/pages/app/Create.jsx`](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/pages/app/Create.jsx) (Draft and review), [`frontend/src/App.jsx`](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/App.jsx) (Routes and layout), [`frontend/lib/db.js`](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/lib/db.js) (Database client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web application"]
  node_app["Routes and layout<br/>[App.jsx]"]
  node_landing["Landing page<br/>[Landing.jsx]"]
  node_create["Draft and review<br/>[Create.jsx]"]
  node_preview["Preview and review UI"]
  node_postviews["Post views"]
  node_postdata["Post data hook<br/>[usePosts.js]"]
  node_client["API client<br/>[api.js]"]
end

subgraph group_api["Application API"]
  node_generate["Generate endpoint<br/>[generate.js]"]
  node_posts["Post management endpoint<br/>[posts.js]"]
  node_publish["Publish endpoint<br/>[publish.js]"]
end

subgraph group_storage["Post storage"]
  node_dbclient["Database client<br/>[db.js]"]
  node_supabase[("Supabase")]
end

subgraph group_automation["Workflow automation"]
  node_genflow["Generate and review workflow"]
  node_pubflow["Telegram publish workflow"]
end

node_user(("Content creator"))
node_telegram(("Telegram"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_create
node_app -->|"routes to"| node_postviews
node_create -->|"requests generation"| node_client
node_create -->|"updates drafts"| node_client
node_create -->|"requests publishing"| node_client
node_create -->|"renders"| node_preview
node_postviews -->|"loads posts"| node_postdata
node_postdata -->|"lists posts"| node_client
node_client -->|"calls endpoint"| node_generate
node_client -->|"calls endpoint"| node_posts
node_client -->|"calls endpoint"| node_publish
node_generate -->|"uses"| node_dbclient
node_posts -->|"uses"| node_dbclient
node_publish -->|"uses"| node_dbclient

click node_app "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/pages/Landing.jsx"
click node_create "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/pages/app/Create.jsx"
click node_preview "https://github.com/safa-kaware/socialflow-ai/tree/main/frontend/src/components/app"
click node_postviews "https://github.com/safa-kaware/socialflow-ai/tree/main/frontend/src/pages/app"
click node_postdata "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/data/usePosts.js"
click node_client "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/lib/api.js"
click node_generate "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/api/generate.js"
click node_posts "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/api/posts.js"
click node_publish "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/api/publish.js"
click node_dbclient "https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/lib/db.js"
click node_genflow "https://github.com/safa-kaware/socialflow-ai/blob/main/n8n/workflows/generate-and-review.json"
click node_pubflow "https://github.com/safa-kaware/socialflow-ai/blob/main/n8n/workflows/SocialFlow%20-%20Publish%20to%20Telegram%20(1).json"

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_landing,node_create,node_preview,node_postviews,node_postdata,node_client toneBlue
class node_generate,node_posts,node_publish toneAmber
class node_dbclient,node_supabase toneMint
class node_genflow,node_pubflow toneRose
class node_user,node_telegram toneIndigo
```

## Components

### Web application

- [Routes and layout](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Landing page](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/pages/Landing.jsx): `frontend/src/pages/Landing.jsx`
- [Draft and review](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/pages/app/Create.jsx): `frontend/src/pages/app/Create.jsx`
- [Preview and review UI](https://github.com/safa-kaware/socialflow-ai/tree/main/frontend/src/components/app): `frontend/src/components/app`
- [Post views](https://github.com/safa-kaware/socialflow-ai/tree/main/frontend/src/pages/app): `frontend/src/pages/app`
- [Post data hook](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/data/usePosts.js): `frontend/src/data/usePosts.js`
- [API client](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### Application API

- [Generate endpoint](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/api/generate.js): `frontend/api/generate.js`
- [Post management endpoint](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/api/posts.js): `frontend/api/posts.js`
- [Publish endpoint](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/api/publish.js): `frontend/api/publish.js`

### Post storage

- [Database client](https://github.com/safa-kaware/socialflow-ai/blob/main/frontend/lib/db.js): `frontend/lib/db.js`
- **Supabase**

### Workflow automation

- [Generate and review workflow](https://github.com/safa-kaware/socialflow-ai/blob/main/n8n/workflows/generate-and-review.json): `n8n/workflows/generate-and-review.json`
- [Telegram publish workflow](https://github.com/safa-kaware/socialflow-ai/blob/main/n8n/workflows/SocialFlow%20-%20Publish%20to%20Telegram%20(1).json): `n8n/workflows/SocialFlow - Publish to Telegram (1).json`

### Other components

- **Content creator**
- **Telegram**

## Connections

- Content creator → Routes and layout: uses (evidence: `frontend/src/App.jsx`)
- Routes and layout → Landing page: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Draft and review: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Post views: routes to (evidence: `frontend/src/App.jsx`)
- Draft and review → API client: requests generation (evidence: `frontend/src/pages/app/Create.jsx`)
- Draft and review → API client: updates drafts (evidence: `frontend/src/pages/app/Create.jsx`)
- Draft and review → API client: requests publishing (evidence: `frontend/src/pages/app/Create.jsx`)
- Draft and review → Preview and review UI: renders (evidence: `frontend/src/pages/app/Create.jsx`)
- Post views → Post data hook: loads posts (evidence: `frontend/src/pages/app/Dashboard.jsx`)
- Post data hook → API client: lists posts (evidence: `frontend/src/data/usePosts.js`)
- API client → Generate endpoint: calls endpoint (evidence: `frontend/src/lib/api.js`)
- API client → Post management endpoint: calls endpoint (evidence: `frontend/src/lib/api.js`)
- API client → Publish endpoint: calls endpoint (evidence: `frontend/src/lib/api.js`)
- Generate endpoint → Database client: uses (evidence: `frontend/api/generate.js`)
- Post management endpoint → Database client: uses (evidence: `frontend/api/posts.js`)
- Publish endpoint → Database client: uses (evidence: `frontend/api/publish.js`)
