A scalable, modular TypeScript backend framework powered by Drizzle ORM.
๐ง Overview
Prexress is a backend framework built in TypeScript, designed with modularity and scalability in mind. It integrates with Drizzle ORM, embraces clean architecture principles, and leverages package separation to isolate core functionalities and database access.
๐ ๏ธ Installation
Install the CLI tool globally via pnpm:
pnpm add -g @prexress/cli
Verify the installation:
pxr --help
๐ฆ Project Initialization
To create a new Prexress project:
pxr init
This sets up the initial project structure with a basic configuration, default modules, and dependencies.
Start Working
- Install required dependencies
pnpm install
- Generate migration for database schema
pnpm run db:generate
- Push migration to database
pnpm run db:migrate
Prexress CLI
You will find proper cli documentation over here. @prexress/cli
๐๏ธ Architectural Highlights
1. Modular Folder Architecture
Prexress promotes a feature-first structure, where each domain (e.g., user, post) is treated as an isolated module.
src/
โโโ modules/
โ โโโ user/
โ โโโ user.controller.ts
โ โโโ user.service.ts
โ โโโ user.schema.ts
โ โโโ user.repository.ts
โ โโโ user.middleware.ts
โโโ middlewares/
โโโ registry.ts
โโโ app.ts
๐ฆ Package Separation
Core Package (`@prexress/core`)
- Base classes for controllers, services, selectors, and repositories
- Common decorators
- Dependency Injection and utility helpers
DB Package (`@prexress/db`)
- Drizzle ORM setup and configuration
- Connection pool management
Helpers (planned)
- Authorization (RBAC)
- JWT + Passport strategies
๐ Features
- โ๏ธ Drizzle ORM Integration: Lightweight, type-safe database access layer
- ๐งฉ Modular Design: Each domain is self-contained for better testability
- ๐งฑ Repository Pattern: Abstracts persistence layer from business logic
- ๐ Dependency Injection: Powered by
tsyringefor service registration - ๐งผ Decorators for Routing: Clean and declarative routing with decorators
- ๐งต Selector Layer: Efficient response shaping and security via field filtering
- ๐ Middleware Support: Built-in support for global, controller, and route-level middleware
- ๐ Automatic Route Discovery: Controllers are registered dynamically
- ๐ฅ Prexress CLI: An interactive cli to generate project files
๐ง Usage Philosophy
Repository
Encapsulates data access using Drizzle's db.select, db.insert, etc.
export class UserRepository extends BaseRepository {
async findByEmail(email: string) {
return this.db.query.users.findFirst({ where: eq(users.email, email) });
}
}
Service
Contains validation and orchestrates domain logic.
export class UserService extends BaseService {
async register(data: CreateUserDTO) {
if (!this.isEmailValid(data.email)) throw new ValidationError();
return this.create(data);
}
}
Controller
Maps routes to service methods using expressive decorators.
@autoInjectable()
@Controller("/api/v1/users")
export class UserController {
constructor(readonly userService: UserService) {}
@POST("/")
async create(req: Request, res: Response) {
const user = await this.userService.create(req.body);
return res.status(201).json(user);
}
}
๐ Middleware & Error Handling
Supports multi-layer middleware:
- Global (e.g., logging, auth)
- Controller-level
- Route-specific
@Use(authMiddleware)
@POST("/")
@Use(validateUserMiddleware)
Global error handler is included for graceful failures.
๐ฎ Future Scope
- Plugin system for auth, logging, metrics
- GraphQL integration
- Multi-tenancy support
- Multi-DB adapters
๐ License
MIT License โ see LICENSE file for details.