Skip to content

Architecture Overview

OpenSNS follows a clean separation between frontend, backend, and AI services.

┌─────────────────────────────────────────────────────────────────┐
│ Client Layer │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Next.js 15 Frontend │ │
│ │ • React Query for data fetching │ │
│ │ • shadcn/ui components │ │
│ │ • WebSocket for real-time updates │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ API Layer │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ FastAPI Backend │ │
│ │ • REST API endpoints │ │
│ │ • JWT authentication │ │
│ │ • WebSocket handlers │ │
│ │ • Rate limiting │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Service Layer │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Research │ │ Pipeline │ │ Engines │ │
│ │ Service │ │ Orchestrator│ │ Registry │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Agent Layer │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ LangGraph Workflow │ │
│ │ │ │
│ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ │
│ │ │Rsrch │──▶│Strat │──▶│Copy │──▶│Image │──▶│Video │ │ │
│ │ └──────┘ └──────┘ └──────┘ └──────┘ └──────┘ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ External Services │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ OpenAI │ │ Fal.ai │ │ Ollama │ │ ComfyUI │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────────────┘
ComponentPurpose
App RouterFile-based routing with layouts
React QueryServer state management
shadcn/uiAccessible UI components
Tailwind CSSUtility-first styling
WebSocketReal-time agent updates
ComponentPurpose
API RoutesREST endpoints for all operations
SQLModelORM with Pydantic validation
JWT AuthStateless authentication
WebSocketBroadcast agent logs
Rate LimitingPrevent abuse

The AI pipeline uses LangGraph for:

  • Stateful execution - Tracks progress across nodes
  • Checkpointing - Resume from interrupts
  • Parallel execution - Run independent tasks concurrently
  • Error handling - Graceful fallbacks

Pluggable AI backends:

engine_registry.register_llm_engine("openai", OpenAIAdapter)
engine_registry.register_llm_engine("ollama", OllamaAdapter)
engine_registry.register_image_engine("fal", FalImageAdapter)
  1. User creates campaign → API receives request
  2. Background task starts → Pipeline orchestrator begins
  3. Research node → Scrapes product URL
  4. Strategy node → Generates marketing angles
  5. Copy node → Creates ad copy for each angle/platform
  6. Image node → Generates product images
  7. Video node → Converts images to videos
  8. Assets saved → Stored in database
  9. WebSocket broadcast → UI updates in real-time
User (1) ──────────────────── (N) Campaign
│ │
│ │
└── (1) UserSettings (N) Asset
(N) AgentLog
  • JWT tokens in Authorization header
  • Encrypted API keys stored with Fernet
  • Rate limiting on sensitive endpoints
  • SSRF protection on asset export

Generate ad creatives from any product URL. Open source, self-hostable, free tier available.

Try OpenSNS Free →