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 exposes three server-side API route groups built with Next.js 15 Route Handlers: image generation via Cloudflare Workers AI, community post management backed by MongoDB, and OAuth-powered authentication via NextAuth.js. All API routes live under /api/ and share consistent JSON request/response conventions.
These are Next.js Route Handler endpoints — server-side functions that run inside your Next.js application, not a standalone REST service. They are deployed and served as part of the same Next.js process and inherit the full Node.js / Edge runtime context.

Base URL

All routes are relative to your application’s base URL, configured via the NEXT_PUBLIC_BASE_URL environment variable.
EnvironmentBase URL
Local developmenthttp://localhost:3000
ProductionValue of NEXT_PUBLIC_BASE_URL
Set this in your .env.local file:
NEXT_PUBLIC_BASE_URL=https://your-domain.com

Authentication

Akari Art uses NextAuth.js JWT sessions. When a user signs in with Google OAuth, NextAuth sets a signed next-auth.session-token cookie. All subsequent browser requests to protected API routes automatically include this cookie — no extra Authorization header is needed. The middleware.ts file enforces protection at the edge. Every route is intercepted and checked for a valid JWT token except the following public paths:
  • / — landing page
  • /signin — sign-in page
  • /api/auth/* — NextAuth internal routes
Any request to a protected route without a valid token is redirected to /signin. Requests originating from authenticated browser sessions pass through automatically.
When calling the API from server components or server actions, use getServerSession(authOptions) to retrieve the session without relying on cookies being forwarded automatically. See the Auth reference for an example.

API Endpoints Summary

MethodPathDescriptionAuth Required
POST/api/image-generationGenerate an image from a text promptYes
GET/api/postList all community postsNo (server-side fetch)
POST/api/postCreate a new community postYes
GET/api/auth/[...nextauth]OAuth sign-in flow & session endpointsNo
POST/api/auth/[...nextauth]OAuth callback & sign-outNo

Error Handling

All error responses return JSON with one of two shapes, depending on the route: Simple error (image generation):
{
  "error": "A human-readable error message"
}
Structured error (posts):
{
  "success": false,
  "message": "A human-readable message",
  "error": "Underlying error details"
}
HTTP status codes used across all routes:
StatusMeaning
200Request succeeded
201Resource created successfully
400Bad request — missing or invalid fields
500Internal server error

Content-Type

All API requests must include Content-Type: application/json in the request headers when sending a body. All responses are returned as application/json.
fetch('/api/image-generation', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ prompt: '...' }),
});

Build docs developers (and LLMs) love