# reyothedev/clipandpost_api architecture

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

- Interactive diagram: https://gitdiagram.com/reyothedev/clipandpost_api
- Repository: https://github.com/reyothedev/clipandpost_api

## Overview

ClipAndPost is an Express API for managing uploaded project clips and publishing them to Instagram. The main workflow is authenticated API requests for project and clip management, direct-to-R2 uploads with metadata persisted in Supabase, then schedule or publish operations that fetch media and submit it to Instagram. The README documents the project, clip, schedule, and connected-account data model; the supplied source excerpts do not show video clipping or generation, so that capability is not represented as an implemented stage. Some route wiring and controller relationships are supported by the SOURCE INDEX rather than full excerpts.

Main entry points: [`src/routes/index.js`](https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/index.js) (API route map), [`src/services/supabase/db.service.js`](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/supabase/db.service.js) (Persistence service), [`src/services/publishing/publishing.service.js`](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/publishing/publishing.service.js) (Publish orchestration), [`src/services/storage/r2.service.js`](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/storage/r2.service.js) (Media storage service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_app["Express app<br/>[app.js]"]
  node_route_index["API route map<br/>[index.js]"]
  node_auth["User authentication<br/>[auth.middleware.js]"]
  node_health["Health endpoint"]
  node_instagram_routes["Instagram routes"]
end

subgraph group_projects["Projects and uploads"]
  node_projects_routes["Project routes<br/>[projects.routes.js]"]
  node_projects_controller["Project API"]
  node_upload_routes["Upload routes<br/>[upload.routes.js]"]
  node_upload_controller["Clip upload API"]
end

subgraph group_publishing["Scheduling and publishing"]
  node_schedule_routes["Schedule routes<br/>[schedule.routes.js]"]
  node_schedule_controller["Schedule API"]
  node_publishing_routes["Publishing routes"]
  node_publishing_controller["Publishing API"]
  node_publishing_service["Publish orchestration"]
end

subgraph group_integrations["External integrations"]
  node_instagram_controller["Instagram account API"]
  node_instagram_service["Instagram OAuth and API"]
  node_meta_publisher["Instagram publisher"]
  node_r2_service["Media storage service<br/>[r2.service.js]"]
  node_db_service["Persistence service<br/>[db.service.js]"]
  node_token_crypto["Token encryption"]
  node_supabase_config["Supabase client<br/>[supabase.js]"]
  node_supabase_db[("Supabase PostgreSQL")]
  node_r2_store[("Cloudflare R2")]
  node_meta_api["Meta Instagram API"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts API"| node_route_index
node_app -->|"returns errors"| node_client
node_route_index -->|"routes health"| node_health
node_route_index -->|"mounts routes"| node_instagram_routes
node_route_index -->|"mounts routes"| node_projects_routes
node_route_index -->|"mounts routes"| node_upload_routes
node_route_index -->|"mounts routes"| node_schedule_routes
node_route_index -->|"mounts routes"| node_publishing_routes
node_instagram_routes -->|"dispatches to"| node_instagram_controller
node_instagram_controller -->|"calls OAuth"| node_instagram_service
node_instagram_controller -->|"persists account"| node_supabase_config
node_instagram_service -->|"calls API"| node_meta_api
node_projects_routes -->|"authenticates"| node_auth
node_projects_routes -->|"dispatches to"| node_projects_controller
node_projects_controller -->|"manages project data"| node_db_service
node_projects_controller -->|"manages media"| node_r2_service
node_upload_routes -->|"authenticates"| node_auth
node_upload_routes -->|"dispatches to"| node_upload_controller
node_upload_controller -->|"presigns and deletes"| node_r2_service
node_upload_controller -->|"persists clip metadata"| node_db_service
node_schedule_routes -->|"authenticates"| node_auth
node_schedule_routes -->|"dispatches to"| node_schedule_controller
node_schedule_controller -->|"reads and saves schedules"| node_db_service
node_publishing_routes -->|"authenticates"| node_auth
node_publishing_routes -->|"dispatches to"| node_publishing_controller
node_publishing_controller -->|"starts publishing"| node_publishing_service
node_publishing_controller -->|"reads publishing data"| node_db_service
node_publishing_service -->|"loads and updates state"| node_db_service
node_publishing_service -->|"checks and signs media"| node_r2_service
node_publishing_service -->|"publishes containers"| node_meta_publisher
node_meta_publisher -->|"submits media"| node_meta_api
node_db_service -->|"uses client"| node_supabase_config
node_db_service -->|"uses encryption"| node_token_crypto
node_supabase_config -->|"connects to"| node_supabase_db
node_r2_service -->|"reads and writes"| node_r2_store

click node_app "https://github.com/reyothedev/clipandpost_api/blob/main/src/app.js"
click node_route_index "https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/index.js"
click node_auth "https://github.com/reyothedev/clipandpost_api/blob/main/src/middleware/auth.middleware.js"
click node_health "https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/health.controller.js"
click node_instagram_routes "https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/instagram.routes.js"
click node_instagram_controller "https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/instagram.controller.js"
click node_instagram_service "https://github.com/reyothedev/clipandpost_api/blob/main/src/services/instagram.service.js"
click node_projects_routes "https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/projects.routes.js"
click node_projects_controller "https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/projects.controller.js"
click node_upload_routes "https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/upload.routes.js"
click node_upload_controller "https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/upload.controller.js"
click node_schedule_routes "https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/schedule.routes.js"
click node_schedule_controller "https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/schedule.controller.js"
click node_publishing_routes "https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/publishing.routes.js"
click node_publishing_controller "https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/publishing.controller.js"
click node_publishing_service "https://github.com/reyothedev/clipandpost_api/blob/main/src/services/publishing/publishing.service.js"
click node_meta_publisher "https://github.com/reyothedev/clipandpost_api/blob/main/src/services/instagram/instagramPublisher.service.js"
click node_r2_service "https://github.com/reyothedev/clipandpost_api/blob/main/src/services/storage/r2.service.js"
click node_db_service "https://github.com/reyothedev/clipandpost_api/blob/main/src/services/supabase/db.service.js"
click node_token_crypto "https://github.com/reyothedev/clipandpost_api/blob/main/src/services/encryption/tokenCrypto.service.js"
click node_supabase_config "https://github.com/reyothedev/clipandpost_api/blob/main/src/config/supabase.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_route_index,node_auth,node_health,node_instagram_routes,node_client toneBlue
class node_projects_routes,node_projects_controller,node_upload_routes,node_upload_controller toneAmber
class node_schedule_routes,node_schedule_controller,node_publishing_routes,node_publishing_controller,node_publishing_service toneMint
class node_instagram_controller,node_instagram_service,node_meta_publisher,node_r2_service,node_db_service,node_token_crypto,node_supabase_config,node_supabase_db,node_r2_store,node_meta_api toneRose
```

## Components

### API and access

- [Express app](https://github.com/reyothedev/clipandpost_api/blob/main/src/app.js): `src/app.js`
- [API route map](https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/index.js): `src/routes/index.js`
- [User authentication](https://github.com/reyothedev/clipandpost_api/blob/main/src/middleware/auth.middleware.js): `src/middleware/auth.middleware.js`
- [Health endpoint](https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/health.controller.js): `src/controllers/health.controller.js`
- [Instagram routes](https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/instagram.routes.js): `src/routes/instagram.routes.js`

### Projects and uploads

- [Project routes](https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/projects.routes.js): `src/routes/projects.routes.js`
- [Project API](https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/projects.controller.js): `src/controllers/projects.controller.js`
- [Upload routes](https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/upload.routes.js): `src/routes/upload.routes.js`
- [Clip upload API](https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/upload.controller.js): `src/controllers/upload.controller.js`

### Scheduling and publishing

- [Schedule routes](https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/schedule.routes.js): `src/routes/schedule.routes.js`
- [Schedule API](https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/schedule.controller.js): `src/controllers/schedule.controller.js`
- [Publishing routes](https://github.com/reyothedev/clipandpost_api/blob/main/src/routes/publishing.routes.js): `src/routes/publishing.routes.js`
- [Publishing API](https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/publishing.controller.js): `src/controllers/publishing.controller.js`
- [Publish orchestration](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/publishing/publishing.service.js): `src/services/publishing/publishing.service.js`

### External integrations

- [Instagram account API](https://github.com/reyothedev/clipandpost_api/blob/main/src/controllers/instagram.controller.js): `src/controllers/instagram.controller.js`
- [Instagram OAuth and API](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/instagram.service.js): `src/services/instagram.service.js`
- [Instagram publisher](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/instagram/instagramPublisher.service.js): `src/services/instagram/instagramPublisher.service.js`
- [Media storage service](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/storage/r2.service.js): `src/services/storage/r2.service.js`
- [Persistence service](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/supabase/db.service.js): `src/services/supabase/db.service.js`
- [Token encryption](https://github.com/reyothedev/clipandpost_api/blob/main/src/services/encryption/tokenCrypto.service.js): `src/services/encryption/tokenCrypto.service.js`
- [Supabase client](https://github.com/reyothedev/clipandpost_api/blob/main/src/config/supabase.js): `src/config/supabase.js`
- **Supabase PostgreSQL**
- **Cloudflare R2**
- **Meta Instagram API**

### Other components

- **API client**

## Connections

- API client → Express app: sends requests (evidence: `README.md`)
- Express app → API route map: mounts API (evidence: `src/app.js`)
- Express app → API client: returns errors (evidence: `src/app.js`)
- API route map → Health endpoint: routes health (evidence: `src/routes/index.js`)
- API route map → Instagram routes: mounts routes (evidence: `src/routes/index.js`)
- API route map → Project routes: mounts routes (evidence: `src/routes/index.js`)
- API route map → Upload routes: mounts routes (evidence: `src/routes/index.js`)
- API route map → Schedule routes: mounts routes (evidence: `src/routes/index.js`)
- API route map → Publishing routes: mounts routes (evidence: `src/routes/index.js`)
- Instagram routes → Instagram account API: dispatches to (evidence: `src/routes/instagram.routes.js`)
- Instagram account API → Instagram OAuth and API: calls OAuth (evidence: `src/controllers/instagram.controller.js`)
- Instagram account API → Supabase client: persists account (evidence: `src/controllers/instagram.controller.js`)
- Instagram OAuth and API → Meta Instagram API: calls API (evidence: `src/services/instagram.service.js`)
- Project routes → User authentication: authenticates (evidence: `src/routes/projects.routes.js`)
- Project routes → Project API: dispatches to (evidence: `src/routes/projects.routes.js`)
- Project API → Persistence service: manages project data (evidence: `src/controllers/projects.controller.js`)
- Project API → Media storage service: manages media (evidence: `src/controllers/projects.controller.js`)
- Upload routes → User authentication: authenticates (evidence: `src/routes/upload.routes.js`)
- Upload routes → Clip upload API: dispatches to (evidence: `src/routes/upload.routes.js`)
- Clip upload API → Media storage service: presigns and deletes (evidence: `src/controllers/upload.controller.js`)
- Clip upload API → Persistence service: persists clip metadata (evidence: `src/controllers/upload.controller.js`)
- Schedule routes → User authentication: authenticates (evidence: `src/routes/schedule.routes.js`)
- Schedule routes → Schedule API: dispatches to (evidence: `src/routes/schedule.routes.js`)
- Schedule API → Persistence service: reads and saves schedules (evidence: `src/controllers/schedule.controller.js`)
- Publishing routes → User authentication: authenticates (evidence: `src/routes/publishing.routes.js`)
- Publishing routes → Publishing API: dispatches to (evidence: `src/routes/publishing.routes.js`)
- Publishing API → Publish orchestration: starts publishing (evidence: `src/controllers/publishing.controller.js`)
- Publishing API → Persistence service: reads publishing data (evidence: `src/controllers/publishing.controller.js`)
- Publish orchestration → Persistence service: loads and updates state (evidence: `src/services/publishing/publishing.service.js`)
- Publish orchestration → Media storage service: checks and signs media (evidence: `src/services/publishing/publishing.service.js`)
- Publish orchestration → Instagram publisher: publishes containers (evidence: `src/services/publishing/publishing.service.js`)
- Instagram publisher → Meta Instagram API: submits media (evidence: `src/services/instagram/instagramPublisher.service.js`)
- Persistence service → Supabase client: uses client (evidence: `src/services/supabase/db.service.js`)
- Persistence service → Token encryption: uses encryption (evidence: `src/services/supabase/db.service.js`)
- Supabase client → Supabase PostgreSQL: connects to (evidence: `src/config/supabase.js`)
- Media storage service → Cloudflare R2: reads and writes (evidence: `src/services/storage/r2.service.js`)
