AdLaunch is a bulk Meta (Facebook & Instagram) ad launching and workflow automation platform built for performance marketing teams. It acts as an optimization layer sitting on top of the Meta Marketing API, removing the slow, manual, and repetitive actions of Meta Ads Manager.
AdLaunch enables marketers to stage campaign creative assets, auto-map dimensions to placement groups, enforce strict naming conventions via tokens, and deploy hundreds of campaign variants in seconds using either a 2-Click Quick Launcher or a Spreadsheet-style bulk sheets interface supporting raw clipboard imports.
AdLaunch utilizes Next.js 14/16 (App Router), Prisma ORM (with PostgreSQL/SQLite adapter configurations), and NextAuth.js v5.
graph TD
subgraph Client ["Browser / Client-Side"]
UI["React Frontend (shadcn/ui)"]
Grid["Interactive Sheets Grid"]
Uploader["File Staging Uploader"]
end
subgraph AppServer ["Next.js Server Runtime (Node.js)"]
AuthFull["Full Auth Setup (auth.ts)"]
MetaAPI["Meta API Client (lib/meta)"]
Queue["Background Worker (launcher-worker.ts)"]
PrismaClient["Prisma Client & Pool (lib/db.ts)"]
end
subgraph EdgeRuntime ["Edge Runtime (Next.js Middleware)"]
AuthEdge["Edge Auth Setup (auth.config.ts)"]
Middleware["Route Guard (middleware.ts)"]
end
subgraph Services ["External Services & Databases"]
Postgres[("PostgreSQL Database")]
MetaGraph["Meta Graph API"]
GDrive["Google Drive API"]
end
%% Client Interactions
UI --> AuthFull
Grid -->|POST /api/launch/sheet| AppServer
Uploader -->|POST /api/creatives/upload| AppServer
%% Middleware Guard
UI -->|Route Request| Middleware
Middleware -->|Verify Session| AuthEdge
%% Server Integrations
AuthFull -->|Query/Write Users| PrismaClient
Queue -->|Fetch & Update Rows| PrismaClient
Queue -->|Push Assets & Ads| MetaAPI
MetaAPI -->|Graph API Requests| MetaGraph
PrismaClient -->|CRUD Operations| Postgres
AppServer -.->|Fetch Staging| GDrive
βββ prisma/
β βββ schema.prisma # Prisma 7 Database schema models
β βββ prisma.config.ts # Prisma 7 Database connection configuration
βββ src/
β βββ app/
β β βββ api/ # API Route handlers (Auth, Sync, Staging, Launchers)
β β βββ (dashboard)/ # Secured dashboard shell layouts and views
β β βββ login/ # Login and user registration interface
β β βββ onboarding/ # Step-by-step configuration wizard
β βββ components/ # Shared frontend interfaces
β β βββ dashboard/ # Sidebar, topbar, selectors, and trackers
β βββ lib/ # Backend services & utility wrappers
β β βββ creative/ # Aspect-ratio placement mapper
β β βββ meta/ # Meta API client wrapper & Auto-Naming resolver
β β βββ queue/ # Background worker deployment processor
β β βββ db.ts # HMR-safe Prisma 7 Client instantiation
β βββ auth.config.ts # Edge-compatible NextAuth configurations
β βββ auth.ts # Database-loaded NextAuth full configurations
β βββ middleware.ts # Secure path routing filters
βββ public/
β βββ uploads/ # Local directory staging area for assets
βββ .env # Environment credentials variables
When assets are dragged-and-dropped into the library or synced from Google Drive, the aspect-ratio classifier detects the dimensions and auto-maps files to standard Meta placement groups.
flowchart TD
A[Staging Event: Local Upload or GDrive Sync] --> B[Calculate File Dimensions W x H]
B --> C[Analyze Aspect Ratio]
C -->|Ratio = 1:1 or 4:5| D[Auto-Map: Feeds & Streams]
C -->|Ratio = 9:16| E[Auto-Map: Stories & Reels]
C -->|Ratio = 16:9| F[Auto-Map: In-Stream & Audience]
D & E & F --> G[Render Placement Grid Matrix]
G --> H{User Overrides Mapping?}
H -->|Yes| I[Update detectedPlacementGroup in DB]
H -->|No| J[Keep Auto-Map defaults]
I & J --> K[Staged & Ready for Campaign Deployment]
To prevent HTTP thread blockage during large launches, requests return a tracking ID immediately while a background runner handles sequential API uploads.
sequenceDiagram
participant User as Marketing User
participant Router as API Router
participant DB as Postgres DB
participant Worker as Launcher Worker
participant Meta as Meta Graph API
User->>Router: Click "Launch All" (Quick/Sheet parameters)
Router->>DB: Write LaunchJob (QUEUED) & LaunchRows (DRAFT)
Router-->>User: Return 200 OK + Job Tracker ID
Note over Worker, Meta: Non-blocking Background Execution
Router->>Worker: executeLaunchJob(jobId)
Worker->>DB: Update LaunchJob status to (LAUNCHING)
Worker->>Meta: Create Campaign (/campaigns)
Meta-->>Worker: Return Campaign ID
loop for each LaunchRow (Creative Asset)
Worker->>DB: Update LaunchRow status to (PENDING)
Worker->>Meta: Create AdSet (/adsets)
Worker->>Meta: Upload Image/Video & Create AdCreative (/adcreatives)
Worker->>Meta: Create final Ad under AdSet (/ads)
Meta-->>Worker: Return Ad IDs
Worker->>DB: Update Row (SUCCESS, metaAdId) & increment subscription quota
end
Worker->>DB: Update LaunchJob status to (COMPLETED)
Next.js Middleware runs inside the Edge Runtime, which does not support Node.js-specific modules (like fs, path, or native binary bindings like standard database drivers or password encryptors). To allow page protection inside middleware.ts without triggering runtime evaluation errors, AdLaunch splits the NextAuth v5 configuration:
graph TD
subgraph ConfigSplitting ["NextAuth v5 Config Splitting"]
ConfigEdge["auth.config.ts (Edge Safe) <br>- JWT session config<br>- Login pages routing paths<br>- OAuth Providers (Facebook, Google)"]
ConfigNode["auth.ts (Node Runtime Only) <br>- Extends auth.config.ts<br>- Database PrismaAdapter<br>- Credentials provider (bcryptjs lookup)<br>- linkAccount token insertion events"]
end
Middleware["middleware.ts (Runs on Edge)"] -->|Imports config| ConfigEdge
APIHandlers["/api/auth/[...nextauth]/route.ts"] -->|Imports handlers| ConfigNode
DashboardLayout["(dashboard)/layout.tsx"] -->|Calls server auth()| ConfigNode
- Node.js (v20+ recommended)
- NPM (v10+)
- A running PostgreSQL instance (or you can use an online database provider like Neon/Supabase)
Clone the repository and install the dependencies:
npm install --legacy-peer-depsCreate a .env file in the root directory:
DATABASE_URL="postgresql://username:password@localhost:5432/adlaunch?schema=public"
NEXTAUTH_SECRET="your-32-character-secret-key-goes-here"
NEXTAUTH_URL="http://localhost:3000"
# Meta App Credentials
META_APP_ID="your_facebook_app_id"
META_APP_SECRET="your_facebook_app_secret"
# Google Drive Credentials
GOOGLE_CLIENT_ID="your_google_client_id"
GOOGLE_CLIENT_SECRET="your_google_client_secret"Initialize database schema migrations and compile the Prisma client:
# Push schema structures to target database
npx prisma db push
# Generate client hooks
npx prisma generateVerify the placement classifier and token-naming engines:
npx tsx src/lib/test-runner.tsBoot up the local dev server:
npm run devOpen http://localhost:3000 inside your browser.
To build and test without active Meta Developer accounts or Google OAuth access, AdLaunch runs in Mock Mode automatically if the environment token matches standard placeholders:
- OAuth simulation: The Onboarding Wizard and login interfaces feature a "Simulate Connection" trigger. This writes mock access credentials to the database, syncing mock Ad Accounts (e.g.
act_1010203040) for dashboard population. - API simulation: If the connected access token is a placeholder, the
MetaApiClientprints the JSON request payloads to the console and returns successful simulated Meta IDs (e.g.,mock_meta_id_395829472) immediately. You can test complete bulk sheets launcher uploads with full row success and failure status changes.