GHOSTAPI

GhostAPI Docs

Build against a mock backend from an OpenAPI contract.

A practical guide to importing schemas, running mock endpoints, testing requests, configuring projects, inviting teammates, and operating GhostAPI locally.

Start

Quickstart

Watch the full setup run end to end below — then run the same five commands on your machine.

Setup, end to end~3 min on a warm cache
  1. 01

    Install dependencies

    Run pnpm install from the repository root.

  2. 02

    Start PostgreSQL and Redis

    Run docker compose up -d.

  3. 03

    Prepare Prisma

    Generate Prisma Client, then run migrations so the database has every column used by the server.

  4. 04

    Start the workspace

    Run pnpm dev. Public web runs on 3000, server on 3001, protected app on 3002.

  5. 05

    Create the first mock API

    Register, create a project, upload api.json or another OpenAPI 3.x schema, then open Playground.

Local setup
pnpm install
docker compose up -d
pnpm --filter @ghostapi/server prisma:generate
pnpm --filter @ghostapi/server prisma:migrate
pnpm dev

Model

Core concepts

These terms explain the product faster than a feature list.

GhostAPI has one load-bearing mental model: an uploaded schema becomes normalized endpoints, and every product surface works from those endpoints.

Project
The workspace for one mock API. It owns schemas, endpoints, environments, logs, settings, and members.
Schema
An uploaded OpenAPI document. GhostAPI validates it and converts it into a normalized schema.
Endpoint
A normalized method/path operation generated from the schema and mounted under /mock/{projectId}.
Saved response
A response body you edit and persist for a status code and media type.
Mock defaults
Project-wide behavior such as latency, error chance, auth simulation, and response mode.
Activity log
A captured request/response record used to debug frontend traffic.

System

Architecture

OpenAPI-specific logic is isolated at the parser boundary. Everything downstream uses the normalized model.

OpenAPI upload
Parser
Normalized schema
Mock engine
Runtime
apps/web
Public Next.js site and docs.
apps/app
Protected Vite workspace for projects, playground, logs, and settings.
apps/server
Hono API, auth, Prisma, schema ingestion, Scalar docs, and runtime orchestration.
packages/parser
OpenAPI validation, dereferencing, and normalization.
packages/runtime
Dynamic route matching and mock request serving.
packages/mock-engine
Schema-aware sample response generation.
packages/types
Shared DTOs, Zod schemas, and NormalizedEndpoint contracts.

Build

Schemas

A schema upload is the source of truth for endpoint generation, response media types, parameters, request bodies, and docs metadata.

Duplicate handling is intentionally explicit. Keeping existing endpoints protects local mock edits; overriding updates the project to match the new contract.

GhostAPI accepts OpenAPI 3.x JSON or YAML. Uploads are validated before endpoints are persisted.

When replacing a schema, duplicate method/path pairs are detected. With override disabled, existing endpoints remain and only new endpoints are added. With override enabled, matching endpoints are replaced by the new schema.

Schema history keeps the active version inspectable and makes later replacement flows understandable.

No duplicate

Add the new endpoint.

Duplicate, override off

Keep current endpoint and discard the duplicate from the upload.

Duplicate, override on

Replace the current endpoint definition with the uploaded one.

Build

Playground

Playground is the full-screen request workspace for a project. The widget below is the real thing in miniature — every request fires against the GhostAPI server you'd run in production.

Try it livemock.demo
real network call

Endpoint

Behavior

Latency200ms
Error rate0%
Require auth

Request

GET/mock/demo/users/1?_latency=200
Press Send request to fire a real call against the demo runtime.

What you just did mirrors a real project: pick an endpoint, dial in mock behavior, send a request, read the response. The only difference is that real projects come from your uploaded OpenAPI schema instead of this seeded fixture.

In a real project, the endpoint list comes from your uploaded schema. Selecting an endpoint hydrates method, URL, params, headers, body, auth, and mock controls.

Shared project headers are inherited by every request. If a local endpoint header has the same key, the shared header wins and the local duplicate is hidden from the request view.

The body editor follows the selected media type, including JSON, text, no-body requests, and multiple schema-declared content types.

After sending, Playground shows status, latency, response headers, response body, saved response body, and copyable cURL.

Operate

Mock runtime

Runtime requests hit /mock/{projectId}/{path}. The widget below is a synthetic feed — drag the sliders and watch real status codes, latencies, and 5xx/401 counts respond live.

Runtime, behavingsynthetic feed

Project defaults

Latency220ms
Error rate8%
Auth required
0
rows
0
5xx
0
401
Waiting for the first request…

The runtime should behave like a backend, but remain configurable enough to force loading, error, auth, and empty-state paths in the frontend.

Route matching
OpenAPI paths become runtime matchers, including path parameters.
Response choice
Saved responses win first; generated schema-aware responses fill gaps.
Latency
Project defaults or endpoint overrides delay responses for loading-state testing.
Error chance
Configurable failure simulation exercises frontend error states.
Auth simulation
Endpoints can require configured headers without implementing business auth.

Operate

Project settings

Settings are divided by responsibility so teams know where to change behavior.

General
Project identity, icon, active schema summary, and base environment snapshot.
Environments
Base URLs, reusable variables, shared headers, and CORS-related context.
Mock
Default latency, error chance, auth simulation, and response strategy.
Schema
Metadata, version history, validation, servers, and replacement flow.
Members
Invite preview, role selection, pending invites, and member removal.
Danger Zone
Replace schema, reset mocks, clear logs, archive, restore, and delete.

Operate

Members and invitations

Project invitations handle people who already have GhostAPI accounts and people who need to create one.

Invite preview checks whether the email is already a user, already a member, or already pending.

Existing users receive a project invite and accept after signing in with the invited email.

New users receive a combined platform and project invitation. After creating the account and verifying email, they join the project with the selected role.

Owner

Full control, including project deletion.

Admin

Manage settings, schemas, environments, mock behavior, logs, and members.

Editor

Edit schemas, endpoint responses, mock behavior, environments, and logs.

Viewer

Read-only access to project data, docs, Playground, and logs.

Reference

Authentication

The app uses cookie-backed sessions and CSRF protection. Mock API auth is simulated separately per project or endpoint.

Sessions
Access and refresh cookies identify the signed-in app user.
CSRF
Mutating browser requests must send x-csrf-token.
Verification
New accounts verify email before normal sign-in.
Password reset
Reset tokens expire and avoid account enumeration.
Invitations
Invite tokens expire and must match the invited email.

Reference

Backend API

Use this page for product behavior. Use the live Scalar reference for exact schemas.

Is the backend alive?
http://localhost:3001/health
Press Ping /health to confirm your backend is reachable.
GET/health

Backend health check.

POST/auth/register

Create account and send email verification.

POST/auth/login

Create authenticated session.

GET/projects

List visible projects.

POST/projects

Create a project.

POST/projects/{projectId}/schemas

Upload and normalize schema.

GET/projects/{projectId}/endpoints

List generated endpoints.

GET/projects/{projectId}/activity

Read request logs.

GET/projects/{projectId}/members

List members and invites.

POST/projects/{projectId}/members/invitations

Send project invite.

ANY/mock/{projectId}/{path}

Serve mock API traffic.

Reference

Local development

Use package-scoped commands while building, then run broader checks before handoff.

Public site
pnpm --filter @ghostapi/web dev on port 3000.
Protected app
pnpm --filter @ghostapi/app dev on port 3002.
Backend
pnpm --filter @ghostapi/server dev on port 3001.
Prisma
pnpm --filter @ghostapi/server prisma:generate and prisma:migrate.
Checks
pnpm lint, pnpm typecheck, pnpm test, pnpm build, and pnpm format:check.

Reference

Troubleshooting

Most failures come from database drift, stale generated clients, wrong URLs, or email configuration.

Prisma P2022 missing column

Run pending migrations and regenerate Prisma Client.

App cannot reach server

Check VITE_API_URL, NEXT_PUBLIC_API_URL, CORS, cookies, and port 3001.

Invite email lands in spam

Verify SPF, DKIM, DMARC, sender domain alignment, and reputation.

Mock route returns 404

Confirm schema upload succeeded and the endpoint exists under the selected project.

Duplicate request headers

Shared headers override local endpoint headers by case-insensitive name.