Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/Akari-Art/llms.txt

Use this file to discover all available pages before exploring further.

Akari Art connects to five external services — Google OAuth, MongoDB, Cloudinary, Cloudflare Workers AI, and NextAuth.js session management — each of which requires its own set of credentials. None of these values are bundled with the source code; they are read exclusively from environment variables at runtime. This page explains exactly where to find or generate each credential and how to place it in your .env.local file.

Service Configuration

NextAuth.js uses these credentials to authenticate users via Google’s OAuth 2.0 flow. On successful sign-in, user information (name, email, profile image) is stored in MongoDB.
  1. Open the Google Cloud Console and create a new project (or select an existing one).
  2. Go to APIs & Services → OAuth consent screen, choose External, and fill in the required app name and support email fields. Save and continue through each section.
  3. Go to APIs & Services → Credentials and click + Create Credentials → OAuth 2.0 Client ID.
  4. Set the Application type to Web application.
  5. Under Authorized redirect URIs, add:
    http://localhost:3000/api/auth/callback/google
    
    If you later deploy to production, add your production URI here as well (e.g., https://yourdomain.com/api/auth/callback/google).
  6. Click Create. Copy the Client ID and Client Secret into your .env.local file:
    GOOGLE_CLIENT_ID=your-client-id-here
    GOOGLE_CLIENT_SECRET=your-client-secret-here
    
NEXTAUTH_SECRET is used by NextAuth.js to sign and encrypt JWT session tokens. It must be a cryptographically secure random string. NEXTAUTH_URL tells NextAuth.js the canonical URL of your deployment.Generate a secure secret with one of the following commands:
# Using OpenSSL (recommended)
openssl rand -base64 32

# Using the NextAuth CLI
npx auth secret
Then set both variables:
NEXTAUTH_SECRET=your-generated-secret
NEXTAUTH_URL=http://localhost:3000
For production deployments, update NEXTAUTH_URL to match your live domain (e.g., https://akari-art.vercel.app).
Akari Art uses Mongoose to persist user accounts and image metadata. The application expects a standard MongoDB connection string in MONGODB_URL.Using MongoDB Atlas (recommended):
  1. Create a free cluster at mongodb.com/cloud/atlas.
  2. Under Database Access, create a database user with read/write permissions.
  3. Under Network Access, allow connections from your IP (or 0.0.0.0/0 for development).
  4. Click Connect → Drivers and copy the connection string. It will look like:
    mongodb+srv://<user>:<pass>@cluster0.xxxxx.mongodb.net/akari-art
    
  5. Replace <user> and <pass> with your database user credentials and set:
    MONGODB_URL=mongodb+srv://<user>:<pass>@cluster0.xxxxx.mongodb.net/akari-art
    
The dbConnect helper in lib/database.ts caches the connection across serverless function invocations using a module-level cache with a maxPoolSize of 10, so you will not exhaust connections during development.
Cloudinary stores every image generated by Akari Art. The Next.js config already allows the res.cloudinary.com domain in next.config.ts so that images render in <Image> components without any extra setup.
  1. Sign up or log in at cloudinary.com.
  2. From your Cloudinary dashboard, navigate to the Settings → API Keys panel (or look at the Dashboard home — all three values are displayed there).
  3. Note down your Cloud name, API Key, and API Secret.
  4. Add them to .env.local:
    CLOUDINARY_CLOUD_NAME=your-cloud-name
    CLOUDINARY_API_KEY=your-api-key
    CLOUDINARY_API_SECRET=your-api-secret
    
The lib/cloudinary.ts module calls cloudinary.config() with these values at import time, so they must be present before the server starts.
Akari Art calls the Cloudflare Workers AI REST API directly from the /api/image-generation route using the endpoint:
https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ID}/ai/run/@cf/black-forest-labs/flux-1-schnell
Finding your Account ID:
  1. Log in to the Cloudflare dashboard.
  2. Select any domain (or the Workers & Pages section). Your Account ID is displayed in the right-hand sidebar on the Overview page.
Creating an API token:
  1. Go to My Profile → API Tokens → Create Token.
  2. Use the Create Custom Token option.
  3. Under Permissions, add Account → Workers AI → Edit (or Read if you only need inference).
  4. Click Continue to Summary → Create Token and copy the token value — it is only shown once.
CLOUDFLARE_ID=your-account-id
CLOUDFLARE_API_KEY=your-api-token

Complete .env.local Example

Create this file in the root of your cloned repository. All 11 variables are required — the application will throw at startup if MONGODB_URL is missing, and requests to generate images will fail if the Cloudflare or Cloudinary credentials are absent.
.env.local
# ── Google OAuth ───────────────────────────────────────────
GOOGLE_CLIENT_ID=123456789-abcdefghijklmnop.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxxxxxxxxxx

# ── NextAuth.js ────────────────────────────────────────────
NEXTAUTH_SECRET=replace-with-output-of-openssl-rand-base64-32
NEXTAUTH_URL=http://localhost:3000

# ── MongoDB ────────────────────────────────────────────────
MONGODB_URL=mongodb+srv://myuser:mypassword@cluster0.xxxxx.mongodb.net/akari-art

# ── Cloudinary ─────────────────────────────────────────────
CLOUDINARY_CLOUD_NAME=my-cloud-name
CLOUDINARY_API_KEY=123456789012345
CLOUDINARY_API_SECRET=abcdefghijklmnopqrstuvwxyz12

# ── Cloudflare Workers AI ──────────────────────────────────
CLOUDFLARE_ID=abcdef1234567890abcdef1234567890
CLOUDFLARE_API_KEY=your-cloudflare-api-token

# ── Application ────────────────────────────────────────────
NEXT_PUBLIC_BASE_URL=http://localhost:3000
Never commit .env.local to version control. It is already listed in the default .gitignore created by create-next-app, but double-check before pushing to a public repository. Exposing your NEXTAUTH_SECRET, database credentials, or Cloudflare API token will compromise your entire deployment.

Environment Variable Reference

VariableRequiredDescription
GOOGLE_CLIENT_ID✅ YesOAuth 2.0 Client ID from Google Cloud Console
GOOGLE_CLIENT_SECRET✅ YesOAuth 2.0 Client Secret from Google Cloud Console
NEXTAUTH_SECRET✅ YesRandom secret used to sign and encrypt JWT session tokens
NEXTAUTH_URL✅ YesCanonical URL of the app (e.g., http://localhost:3000)
MONGODB_URL✅ YesMongoDB connection string; app throws on startup if missing
CLOUDINARY_CLOUD_NAME✅ YesYour Cloudinary account’s cloud name
CLOUDINARY_API_KEY✅ YesCloudinary API key for uploading generated images
CLOUDINARY_API_SECRET✅ YesCloudinary API secret (server-side only, never exposed to the browser)
CLOUDFLARE_ID✅ YesCloudflare Account ID used to build the Workers AI API URL
CLOUDFLARE_API_KEY✅ YesCloudflare API token with Workers AI Run permission
NEXT_PUBLIC_BASE_URL✅ YesPublic base URL used for client-side absolute URL construction

Build docs developers (and LLMs) love