Next.js Application
Maintenance note: Update this file when API routes, conat bridge, or schema validation patterns change.
Package: packages/next Build: cd packages/next && pnpm build-dev
Role
The Next.js app serves two purposes:
Server-side rendered pages — Public-facing pages, share pages, landing
API routes — REST endpoints for external clients and internal use
API Routes
v2 REST API
Location: packages/next/pages/api/v2/
Standard REST endpoints for account management, billing, projects, etc.
Key areas:
api/v2/accounts/— Account operationsapi/v2/auth/— Authentication endpointsapi/v2/billing/— Billing operationsapi/v2/compute/— (deprecated, phasing out)api/v2/jupyter/— Jupyter operationsapi/v2/licenses/— License managementapi/v2/llm/— LLM/AI endpointsapi/v2/messages/— User messagingapi/v2/news/— News/announcements
Conat Bridge
Location: packages/next/pages/api/conat/
The conat bridge translates HTTP requests into conat messages, enabling external clients (like the Python API) to call hub and project APIs.
Hub Bridge (api/conat/hub.ts)
Project Bridge (api/conat/project.ts)
Schema Validation
Location: packages/next/lib/api/schema/
API endpoints use Zod schemas for request/response validation.
Schema Organization
Example Schema
apiRoute Framework
packages/next/lib/api/framework.ts integrates Zod with next-rest-framework:
IMPORTANT: When adding fields to API requests, update both:
The Zod schema in
packages/next/lib/api/schema/The frontend types used by
apiPostorapi()
Frontend API Callers
packages/next/lib/api/post.ts—apiPost()for Next.js internal usepackages/frontend/client/api.ts—api()for frontend use
Parameter Extraction
packages/next/lib/api/get-params.ts — Only POST requests are accepted (GET is rejected for security). Parameters are extracted from the POST body.