Overview
PyqDeck uses an API-first development model. Instead of manually writing API calling logic, we generate a TypeScript SDK directly from the backend’s OpenAPI (Swagger) definition.The Pipeline
The synchronization process follows these steps:- JSDoc Annotations: Backend routes and models are annotated with
@openapi(viaswagger-jsdoc). - Export Spec: Running
pnpm run openapi:exportin thebackend/directory generates a staticopenapi.jsonfile. - Generate SDK: Running
pnpm run gen:apiin thefrontend/directory consumes theopenapi.jsonand generatesfrontend/src/lib/api-generated.ts.
Tools Used
- swagger-jsdoc: Extracts OpenAPI definitions from source code comments.
- swagger-typescript-api: Generates the TypeScript classes, interfaces, and request logic from the OpenAPI spec.
Using the SDK
The generated SDK provides a typedApi class.
Maintenance
Whenever a backend route is added or a model schema changes:- Update the JSDoc in the backend.
- Run the export command in the backend.
- Run the generation command in the frontend.
- Commit the updated
api-generated.ts.

