# zeetelenore-fiverr/facebook-auto-bot architecture

> Architecture diagram of the GitHub repository zeetelenore-fiverr/facebook-auto-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zeetelenore-fiverr/facebook-auto-bot
- Repository: https://github.com/zeetelenore-fiverr/facebook-auto-bot

## Overview

Facebook Auto Bot is a single-admin tool for creating, scheduling, and publishing Facebook Page posts, with an optional scheduled autopilot. The main workflow is topic selection, copy and image generation, draft or scheduled-post management, and publishing; OAuth connects a Page and supplies publishing credentials. The graph separates dashboard entry points, orchestration, generation and topic sources, persistence, and external services. Some API route excerpts omit sections, so uncertain wiring is left out; documented product capabilities are retained where their exact callers are not visible.

Main entry points: [`src/app/api/[...path]/route.ts`](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/api/%5B...path%5D/route.ts) (API routes), [`src/lib/autopilot.ts`](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/autopilot.ts) (Autopilot), [`src/lib/facebook/client.ts`](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/facebook/client.ts) (Facebook client), [`src/lib/db/settings.ts`](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/db/settings.ts) (App settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_dashboard_screens["Dashboard screens"]
  node_generate_screen["Generate post<br/>[page.tsx]"]
  node_topics_screen["Topic management<br/>[page.tsx]"]
  node_settings_screen["Settings<br/>[page.tsx]"]
end

subgraph group_orchestration["Application flow"]
  node_api["API routes<br/>[route.ts]"]
  node_proxy["Session gate<br/>[proxy.ts]"]
  node_session["Signed sessions<br/>[session.ts]"]
  node_autopilot["Autopilot<br/>[autopilot.ts]"]
end

subgraph group_creation["Post creation"]
  node_text["Copy generation<br/>[text.ts]"]
  node_image["Image generation<br/>[image.ts]"]
  node_topic_sources["Topic sources<br/>[trends.ts]"]
end

subgraph group_data["Persistence"]
  node_topic_db["Topic rotation<br/>[topics.ts]"]
  node_posts_db["Post records<br/>[posts.ts]"]
  node_settings_db["App settings<br/>[settings.ts]"]
end

subgraph group_integrations["External services"]
  node_supabase[("Supabase<br/>[server.ts]")]
  node_facebook_oauth["Facebook OAuth<br/>[oauth.ts]"]
  node_facebook_client["Facebook client<br/>[client.ts]"]
  node_publisher["Post publisher<br/>[publish.ts]"]
  node_meta["Meta Graph API"]
  node_image_services["Image providers"]
end

node_admin(("Admin"))
node_cron(("Scheduler"))

node_admin -->|"opens app"| node_proxy
node_proxy -->|"verifies cookie"| node_session
node_admin -->|"uses dashboard"| node_dashboard_screens
node_admin -->|"creates post"| node_generate_screen
node_admin -->|"manages topics"| node_topics_screen
node_admin -->|"configures app"| node_settings_screen
node_generate_screen -->|"requests generation"| node_api
node_topics_screen -->|"manages topics"| node_api
node_settings_screen -->|"loads settings"| node_api
node_api -->|"creates session"| node_session
node_api -->|"generates copy"| node_text
node_api -->|"fetches trends"| node_topic_sources
node_api -->|"exchanges tokens"| node_facebook_oauth
node_api -->|"lists Pages"| node_facebook_client
node_api -->|"publishes now"| node_publisher
node_api -->|"reads and updates"| node_posts_db
node_api -->|"reads and updates"| node_settings_db
node_api -->|"reads and updates"| node_topic_db
node_cron -->|"triggers queue run"| node_api
node_api -->|"runs autopilot"| node_autopilot
node_autopilot -->|"reads settings"| node_settings_db
node_autopilot -->|"selects and marks"| node_topic_db
node_autopilot -->|"gets trends"| node_topic_sources
node_autopilot -->|"generates copy"| node_text
node_autopilot -->|"generates image"| node_image
node_autopilot -->|"creates post"| node_posts_db
node_autopilot -->|"publishes post"| node_publisher
node_publisher -->|"publishes photo"| node_facebook_client
node_facebook_client -->|"loads credentials"| node_settings_db
node_facebook_oauth -->|"exchanges tokens"| node_meta
node_facebook_client -->|"calls Graph API"| node_meta
node_image -.->|"gets images"| node_image_services
node_posts_db -->|"reads and writes"| node_supabase
node_topic_db -->|"reads and writes"| node_supabase
node_settings_db -->|"reads and writes"| node_supabase

click node_dashboard_screens "https://github.com/zeetelenore-fiverr/facebook-auto-bot/tree/main/src/app/dashboard"
click node_generate_screen "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/dashboard/generate/page.tsx"
click node_topics_screen "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/dashboard/topics/page.tsx"
click node_settings_screen "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/dashboard/settings/page.tsx"
click node_api "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/api/%5B...path%5D/route.ts"
click node_proxy "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/proxy.ts"
click node_session "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/auth/session.ts"
click node_autopilot "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/autopilot.ts"
click node_text "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/ai/text.ts"
click node_image "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/ai/image.ts"
click node_topic_sources "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/trends.ts"
click node_topic_db "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/db/topics.ts"
click node_posts_db "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/db/posts.ts"
click node_settings_db "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/db/settings.ts"
click node_supabase "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/supabase/server.ts"
click node_facebook_oauth "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/facebook/oauth.ts"
click node_facebook_client "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/facebook/client.ts"
click node_publisher "https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/facebook/publish.ts"

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_dashboard_screens,node_generate_screen,node_topics_screen,node_settings_screen toneBlue
class node_api,node_proxy,node_session,node_autopilot toneAmber
class node_text,node_image,node_topic_sources toneMint
class node_topic_db,node_posts_db,node_settings_db,node_cron toneRose
class node_supabase,node_facebook_oauth,node_facebook_client,node_publisher,node_meta,node_image_services,node_admin toneIndigo
```

## Components

### Dashboard

- [Dashboard screens](https://github.com/zeetelenore-fiverr/facebook-auto-bot/tree/main/src/app/dashboard): `src/app/dashboard`
- [Generate post](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/dashboard/generate/page.tsx): `src/app/dashboard/generate/page.tsx`
- [Topic management](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/dashboard/topics/page.tsx): `src/app/dashboard/topics/page.tsx`
- [Settings](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/dashboard/settings/page.tsx): `src/app/dashboard/settings/page.tsx`

### Application flow

- [API routes](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/app/api/%5B...path%5D/route.ts): `src/app/api/[...path]/route.ts`
- [Session gate](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/proxy.ts): `src/proxy.ts`
- [Signed sessions](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/auth/session.ts): `src/lib/auth/session.ts`
- [Autopilot](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/autopilot.ts): `src/lib/autopilot.ts`

### Post creation

- [Copy generation](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/ai/text.ts): `src/lib/ai/text.ts`
- [Image generation](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/ai/image.ts): `src/lib/ai/image.ts`
- [Topic sources](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/trends.ts): `src/lib/trends.ts`

### Persistence

- [Topic rotation](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/db/topics.ts): `src/lib/db/topics.ts`
- [Post records](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/db/posts.ts): `src/lib/db/posts.ts`
- [App settings](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/db/settings.ts): `src/lib/db/settings.ts`

### External services

- [Supabase](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`
- [Facebook OAuth](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/facebook/oauth.ts): `src/lib/facebook/oauth.ts`
- [Facebook client](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/facebook/client.ts): `src/lib/facebook/client.ts`
- [Post publisher](https://github.com/zeetelenore-fiverr/facebook-auto-bot/blob/main/src/lib/facebook/publish.ts): `src/lib/facebook/publish.ts`
- **Meta Graph API**
- **Image providers**

### Other components

- **Admin**
- **Scheduler**

## Connections

- Admin → Session gate: opens app
- Session gate → Signed sessions: verifies cookie
- Admin → Dashboard screens: uses dashboard
- Admin → Generate post: creates post
- Admin → Topic management: manages topics
- Admin → Settings: configures app
- Generate post → API routes: requests generation
- Topic management → API routes: manages topics
- Settings → API routes: loads settings
- API routes → Signed sessions: creates session
- API routes → Copy generation: generates copy
- API routes → Topic sources: fetches trends
- API routes → Facebook OAuth: exchanges tokens
- API routes → Facebook client: lists Pages
- API routes → Post publisher: publishes now
- API routes → Post records: reads and updates
- API routes → App settings: reads and updates
- API routes → Topic rotation: reads and updates
- Scheduler → API routes: triggers queue run
- API routes → Autopilot: runs autopilot
- Autopilot → App settings: reads settings
- Autopilot → Topic rotation: selects and marks
- Autopilot → Topic sources: gets trends
- Autopilot → Copy generation: generates copy
- Autopilot → Image generation: generates image
- Autopilot → Post records: creates post
- Autopilot → Post publisher: publishes post
- Post publisher → Facebook client: publishes photo
- Facebook client → App settings: loads credentials
- Facebook OAuth → Meta Graph API: exchanges tokens
- Facebook client → Meta Graph API: calls Graph API
- Image generation → Image providers: gets images
- Post records → Supabase: reads and writes
- Topic rotation → Supabase: reads and writes
- App settings → Supabase: reads and writes
