Skip to content

About

Resources

Stars

5 stars

Watchers

1 watching

Forks

Latest commit

 

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate.me AI

Open-source AI image and video generation for creators. Sign in, pick a model, describe what you want, and generate — pay with platform credits (Stripe) or bring your own provider API keys (BYOK). Live at https://generate.me.

Features

  • Image generation — GPT Image (OpenAI). Stability SD3.5 Turbo, FLUX.2 Pro (Replicate), and Ideogram 3.0 stay registered but are hidden (hidden: true in MODEL_REGISTRY) until their integrations are fixed
  • Style controls — art style, color, lighting, perspective, composition, medium, mood; aspect ratios; negative prompt (where supported); multi-image counts
  • Image-to-image reference upload for supported models
  • Video — D-ID talking avatars and RunwayML image-to-video. The finished video is saved on a gallery cover, and that page can turn it into a GIF with FFmpeg
  • Utilities — AI prompt optimization, AI tag suggestions (OpenAI), and background removal (Bria AI). Each of those shows its credit cost before it runs. Typing a prompt does not spend credits. Voice prompt input uses the Web Speech API
  • Gallery — personal history with tag filtering and per-image detail pages
  • Sharing — publish to a public URL (optional non-secret password), social share, download
  • Profile — credit balance, per-provider BYOK keys, payment history
  • Auth — Firebase Google, email/password, and passwordless email-link sign-in
  • Payments — Stripe PaymentIntent credit packs

Tech stack

Layer Tech
Framework Next.js ^16.4.5 (App Router, Turbopack dev)
UI React ^19.3.1, Tailwind CSS ^4.3.4, Framer Motion ^14.9, Lucide ^1.68, react-icons
Language TypeScript ^6.0.3 (lint cannot run on TypeScript 7 yet; @types/node stays on the Node 24 line)
State Zustand ^5.0.16
Backend Firebase client ^13.2.0 + Firebase Admin ^14.5.0 (Auth, Firestore, Storage). jwks-rsa is pinned to jose 5.10.0
AI Vercel AI SDK (ai ^7.0.162, @ai-sdk/openai ^4.0.108), Replicate SDK, direct REST (Stability, Ideogram, D-ID, RunwayML, Bria)
Payments Stripe ^23.1 (API 2026-10-28.endive) + @stripe/react-stripe-js ^7
Validation Zod ^4.6.7
Media fluent-ffmpeg + ffmpeg-static, dom-to-image (sharp comes with Next.js for self-hosted image optimization)
Tests / quality Vitest ^5 (with Vite ^8 as its peer), ESLint 10, React Doctor

Project structure

src/
  app/                 # Pages + API route handlers
    api/
      auth/sync/       # Sign-in metadata
      generate/        # image (NDJSON stream), video, gif, tags, optimize-prompt, background-removal
      images/[imageId] # GET/PATCH/DELETE + /share
      payments/        # intent, process, validate
      profile/         # profile + payments list
      history/         # save generation record
      previews/        # model/style preview listing
  actions/             # Client wrappers that call /api/* (not server actions)
  lib/api/             # apiGet/apiPost helpers + withAuth / ActionResult envelope
  strategies/          # Image provider Strategy Pattern (dalle, stability, replicate, ideogram)
  constants/           # modelRegistry (source of truth), options, routes
  firebase/            # Client + Admin SDK setup
  components/          # UI by domain (generate, gallery, auth, profile, …)
  zustand/             # Auth, profile, generation, payments stores
  utils/               # Auth, credits, validation, storage helpers
firestore.rules  storage.rules  .env.example

Architecture notes: privileged work runs in Node API routes with Firebase Admin. The edge src/proxy.ts only soft-checks for an auth cookie; real auth verifies the Firebase ID token server-side. Image generation streams NDJSON progress events.

Getting started

Prerequisites

  • Node.js 24 (engines.node; CI and Vercel use the same major)
  • npm
  • Firebase project (Auth, Firestore, Storage)
  • Stripe account (for credit purchases)
  • Provider API keys for the models you want to enable

Install

git clone https://github.com/brown2020/generatemeai.git
cd generatemeai
cp .env.example .env.local
# Fill in values (see table below) — never commit real secrets
npm ci
npm run dev

Open http://localhost:3000.

Deploy Firestore and Storage rules from this repo (firebase.json points at firestore.rules and storage.rules) to your Firebase project before relying on production-like security.

Environment variables

Copy .env.example to .env.local. Use placeholders only — never commit real keys.

Name Purpose Where to get it
FIREBASE_TYPE Admin service account type (usually service_account) Firebase Console → Project settings → Service accounts
FIREBASE_PROJECT_ID Admin project id Same
FIREBASE_PRIVATE_KEY_ID Admin private key id Same
FIREBASE_PRIVATE_KEY Admin private key (PEM) Same
FIREBASE_CLIENT_EMAIL Admin client email Same
FIREBASE_CLIENT_ID Admin client id Same
FIREBASE_AUTH_URI OAuth auth URI Usually Google default in .env.example
FIREBASE_TOKEN_URI OAuth token URI Usually Google default in .env.example
FIREBASE_AUTH_PROVIDER_X509_CERT_URL Cert URL Usually Google default in .env.example
FIREBASE_CLIENT_CERTS_URL Client certs URL Service account JSON
FIREBASE_UNIVERSE_DOMAIN Universe domain Usually googleapis.com
NEXT_PUBLIC_FIREBASE_APIKEY Client Firebase API key Firebase Console → Project settings
NEXT_PUBLIC_FIREBASE_AUTHDOMAIN Client auth domain Same
NEXT_PUBLIC_FIREBASE_PROJECTID Client project id Same
NEXT_PUBLIC_FIREBASE_STORAGEBUCKET Storage bucket Same
NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID Messaging sender id Same
NEXT_PUBLIC_FIREBASE_APPID App id Same
NEXT_PUBLIC_FIREBASE_MEASUREMENTID Analytics measurement id (optional) Same
NEXT_PUBLIC_COOKIE_NAME Name of the HttpOnly auth ID-token cookie. The server sets it from POST /api/auth/session; the fallback name is generateAuthToken Choose a stable cookie name
OPENAI_API_KEY OpenAI / GPT Image + prompt/tag helpers platform.openai.com
OPENAI_ORG_ID OpenAI org id (optional) Same
STABILITY_API_KEY Stability SD3.5 Turbo (model hidden) platform.stability.ai
REPLICATE_API_KEY FLUX via Replicate (model hidden) replicate.com
IDEOGRAM_API_KEY Ideogram 3.0 (model hidden) ideogram.ai
DID_API_KEY D-ID video d-id.com
RUNWAYML_API_SECRET RunwayML video runwayml.com
BRIA_AI_API_KEY Background removal bria.ai
NEXT_PUBLIC_STRIPE_KEY Stripe publishable key Stripe Dashboard
STRIPE_SECRET_KEY Stripe secret key Stripe Dashboard
STRIPE_WEBHOOK_SECRET Stripe webhook signing secret. Optional: when unset, POST /api/payments/webhook returns 503 and does not change balances Stripe Dashboard → Webhooks
NEXT_PUBLIC_STRIPE_PRODUCT_NAME Display name for credit product Your choice / Stripe product
NEXT_PUBLIC_CREDITS_PER_DALL_E_IMAGE Credits charged per GPT Image Your pricing
NEXT_PUBLIC_CREDITS_PER_STABILITY_SD3_TURBO_IMAGE Credits charged per Stability image (model hidden) Your pricing
NEXT_PUBLIC_CREDITS_PER_FLUX_SCHNELL Credits charged per FLUX image (model hidden) Your pricing
NEXT_PUBLIC_CREDITS_PER_IDEOGRAM Credits charged per Ideogram image (model hidden) Your pricing
NEXT_PUBLIC_CREDITS_PER_D_ID Credits charged per D-ID video Your pricing
NEXT_PUBLIC_CREDITS_PER_RUNWAY Credits charged per RunwayML video Your pricing
NEXT_PUBLIC_CREDITS_PER_BRIA_IMAGE Credits charged per background removal Your pricing
NEXT_PUBLIC_CREDITS_PER_CHATGPT Credits charged per prompt optimization or tag suggestion Your pricing
NEXT_PUBLIC_ENABLE_PREVIEW_MARKING Toggle preview sample saving true / false
PREVIEW_ADMIN_UIDS Comma-separated Firebase uids allowed to save preview samples. When unset, nobody can Your admin uid

Scripts

Script Description
npm run dev Next.js dev server with Turbopack
npm run build Production build
npm start Serve production build
npm run lint ESLint
npm run typecheck tsc --noEmit
npm test Vitest
npm run test:rules Firestore rules suite in the emulator (needs Java 21)
npm run doctor React Doctor checks

Testing and CI

  • Unit tests (Vitest) cover model registry, routes, credit reserve, and related API helpers.
  • .github/workflows/ci.yml on dev / main: lint → typecheck → unit tests → React Doctor → production build (build env from Actions secrets only), plus a Firestore rules job that runs npm run test:rules in the emulator.
  • A separate malware IOC scan workflow runs via scripts/malware-scan.sh.

Firebase / services setup

  1. Enable Email/Password, Google, and Email link auth as needed.
  2. Deploy firestore.rules and storage.rules from firebase.json (the browser only uses Firebase Auth; gallery reads and all writes go through API routes with the Admin SDK).
  3. Configure Storage CORS if browsers upload/download across origins (cors.json / firebase-cors.json are included as references).
  4. Wire Stripe products/prices to match your credit packs (src/constants/creditPack.ts).

Deployment

Designed for Vercel (or any Node-capable Next.js host). Set the same env vars in the host dashboard. Point custom domains (e.g. generate.me) at the deployment. Do not embed secrets in workflow YAML — use host / Actions secrets.

Contributing

  1. Branch from dev.
  2. Prefer new API route handlers over server actions; keep MODEL_REGISTRY as the single source of truth for models.
  3. Run npm run lint, npm run typecheck, and npm test before opening a PR.
  4. Never commit .env.local or real API keys.

License

GNU Affero General Public License v3.0 — see LICENSE.md.

About

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages