Overview
@xond/api is the backend engine of the Xond framework. It codifies the patterns we
use across Nufaza projects for building secure, type-safe REST services on top of
Prisma and Express.
Key capabilities
- Reverse engineering: point the generator at an existing database to capture tables, relations and views as Prisma models.
- Code generation: scaffold controllers, repositories, DTO validators and service layers that respect Nufaza coding standards.
- Authentication & authorization: JWT middleware, role-based helpers and audit logging built in.
- Data helpers: pagination, sorting, filter builders and query normalization used by our React UI.
- Extensibility hooks: override lifecycle events (
beforeCreate,afterUpdate, etc.) so generated code can stay intact while your domain logic evolves.
What lives here
/src/core– shared utilities for repositories, Prisma helpers, error formatting, logging and request contexts./src/modules– generated modules (controllers, services, DTOs). Custom logic lives alongside generated files, and can be re-generated without overwriting overrides./prisma– schema files, migrations and seed data that drive both Prisma and the code generation pipeline.
Common tasks
- Check environment and database
pnpm --filter your-api-app xond-api check - Create database structure
pnpm --filter your-api-app xond-api create - Generate code from Prisma schema
pnpm --filter your-api-app xond-api generate - Insert dummy data from Excel
pnpm --filter your-api-app xond-api insert - Apply database updates
pnpm --filter your-api-app xond-api update
Documentation Structure
- Getting Started – Installation and quick start guide
- Commands Reference – Complete CLI command documentation
- REST JSON API – How to call the generated REST APIs
- Code Generation – How code generation works
- Reverse Engineering – Working with existing databases
- Configuration – Customizing code generation
Database Naming Convention
@xond/api follows a strict naming convention:
- Database Standard: All database tables and columns use snake_case (lowercase with underscores)
- Example:
user_table,first_name,created_at
- Example:
- Reverse Engineering: When reverse engineering from an existing database, Prisma schema will be generated in snake_case format
- Code Generation: During
xond-api generate, field names are automatically converted from snake_case to CamelCase for:- Model names (e.g.,
user_table→UserTable) - Field labels and headers (e.g.,
first_name→First Name) - TypeScript interfaces and types
- Model names (e.g.,
- Relation Names: The
xond-api shortencommand shortens long relation names that may cause Prisma errors
This convention ensures:
- Database consistency – All databases follow the same naming standard
- Developer-friendly code – Generated code uses familiar CamelCase conventions
- Type safety – Full TypeScript types from database to frontend
Architecture
@xond/api follows a code generation approach:
- Design your database schema in snake_case (SQL DDL or visual design tool)
- Create the database structure using
xond-api create - Reverse engineer Prisma schema from database (yields snake_case)
- Shorten relation names if needed using
xond-api shorten - Generate REST services and frontend models using
xond-api generate(converts to CamelCase) - Customize generated code by adding business logic in separate files
This approach ensures:
- Type safety – Full TypeScript types from database to frontend
- Consistency – Same patterns across all projects
- Maintainability – Regenerate code without losing customizations
- Speed – Rapid development with minimal boilerplate