A powerful and flexible TypeScript backend boilerplate built on top of Express and PostgreSQL, designed with a NestJS-inspired modular architecture — offering both structure and freedom.
This starter brings the best of both worlds:
- NestJS-style project structure (with
guards,filters,decorators,dto,repositories, etc.) - Express-level flexibility
- Class-based architecture with Dependency Injection (DI) for easy scalability and plugin-based extensibility.
- ⚙️ TypeScript — Strong typing for reliability and better DX.
- 🚀 Express — Lightweight, unopinionated, and extremely flexible.
- 🧩 NestJS-inspired architecture — Organized modules with
controllers,services,guards,filters, and more. - 🧠 Dependency Injection (DI) — Loosely coupled components for easier testing and plugin integration.
- 🗄️ PostgreSQL + Prisma ORM — Powerful schema management and migrations.
- 🔐 Guards, Filters, Decorators — Extendable request handling and validation patterns.
- 📦 DTOs and Validators (Zod) — Type-safe input validation.
- 🐳 Docker Support — Instantly spin up PostgreSQL locally.
- 🧰 Utility-first design — Clean structure for middlewares, repositories, and helpers.
- 📜 OpenAPI/Swagger — Auto-generated API documentation.
backend/
├── dist/
├── node_modules/
├── prisma/
├── src/
│ ├── configs/
│ ├── controllers/
│ ├── decorators/
│ ├── dto/
│ ├── errors/
│ ├── filters/
│ ├── guards/
│ ├── interfaces/
│ ├── middlewares/
│ ├── repositories/
│ ├── routes/
│ ├── services/
│ ├── types/
│ ├── utils/
│ ├── validators/
│ ├── container.ts # Dependency Injection container
│ ├── index.ts # Application entry point
│ └── openApiSpec.ts # Swagger/OpenAPI definition
├── .env
├── .env.example
├── package.json
├── tsconfig.json
└── README.md
This structure follows the NestJS philosophy of modular separation, but keeps Express’s unopinionated nature, giving you full control over middleware and routing.
git clone https://github.com/MeerUzairWasHere/TypePEN.git
cd TypePENcd backend && npm installUse either a remote PostgreSQL provider (Neon, Supabase, ElephantSQL) or local Docker setup.
Rename .env.example → .env and add your connection string:
DATABASE_URL=your-postgresql-urlnpm run dbnpm run dev:migratenpm run devServer will start on http://localhost:3000
This boilerplate uses a class-based architecture with a DI container (container.ts), enabling clean dependency management between services, repositories, and controllers.
Example:
// user.service.ts
export class UserService {
constructor(private userRepository: UserRepository) {}
async findAll() {
return this.userRepository.findMany();
}
}This design allows future plugins or modules (e.g., EmailService, CacheService) to be added seamlessly.
- NestJS-like modularity for organization.
- Express-like flexibility for freedom.
- Class-based design for scalability.
- DI-first approach for maintainability.
Licensed under the MIT License.