Overview
PyqDeck uses an API-first approach where the backend defines the contract, and the frontend consumes it through a generated, type-safe SDK. This eliminates manualfetch calls, ensures type safety, and prevents API drift.
How It Works
1. OpenAPI Spec Generation
Backend routes are documented with JSDoc@swagger annotations. The openapi:export script processes these annotations and outputs backend/openapi.json.
backend/src/routes/papers.js):
2. SDK Generation
The frontend’sgen:api script orchestrates the full pipeline:
- Runs
openapi:exportin the backend to regenerate the spec. - Uses
swagger-typescript-apito generate a TypeScript client. - Outputs to
frontend/src/lib/api-generated.ts.
api-generated.ts - it will be overwritten on the next run.
3. Using the SDK in React
The generated client is wrapped in a React hook that handles authentication:API Contract Enforcement
The CI pipeline ensures the OpenAPI spec stays in sync:- Backend Tests: Verify logic.
- Contract Check: Verify
openapi.jsonhasn’t drifted from the code. - Frontend Build: Runs
gen:apito validate SDK generation and TypeScript types.

