Back to articles
Featured

Nestier – A Production-Ready NestJS Starter

Nestier is an opinionated NestJS boilerplate built for real-world projects. It ships with hexagonal architecture, generic repository pattern, JWT authentication, Docker support, and CI/CD pipelines out of the box.

·4 min read·Brahim Abdelli
NestJSTypeORMDDD (Domain-Driven Design)Generic Repository PatternTypeScriptBackendOpen-SourceDockerMongoDB

Why Nestier?

Starting a new NestJS project often means copying the same boilerplate from a previous one: authentication, database config, generic layers, Docker files, CI pipelines, and so on. As the project scales toward enterprise level, shortcuts accumulate, spaghetti code spreads, and the codebase becomes increasingly difficult to maintain.

Nestier puts an end to that by providing a clean, production-ready foundation you can clone and start building on right away — with solid architecture and best practices baked in from day one.

Architecture

The project follows a strict hexagonal architecture (ports & adapters) with four distinct layers:

LayerPurposeContents
DomainBusiness logic & rulesEntities, Value Objects, Repository Interfaces, Domain Errors
ApplicationUse cases & orchestrationServices, Use Cases, Port Interfaces
InfrastructureExternal concernsTypeORM Repositories, Entity Mappers, Adapters, Middleware
PresentationHTTP interfaceControllers, DTOs, DTO Mappers, Validation

Generic Base Pattern

The heart of Nestier is a set of reusable generic components that any module can extend:

BaseController<T>      →  CRUD endpoints + search + pagination
BaseService<T>         →  Business logic for all CRUD operations
BaseRepository<T>      →  Abstract repository interface (port)
TypeOrmBaseRepository   →  Concrete TypeORM implementation (adapter)
BaseEntity             →  Common entity fields (id, timestamps)

Three example modules demonstrate different levels of customization:

ModulePatternDescription
CategoryBase ImplementationUses generic base components directly for simple CRUD
ProductExtended BaseExtends base with custom use cases and repository methods
UserCustom ImplementationFull custom implementation with JWT auth and email features

What's Inside

Authentication & Authorization

Nestier implements JWT-based authentication with a complete password reset flow. Sign up, login, forgot-password and reset-password endpoints are ready to use. An AuthMiddleware protects routes that require a valid token.

Database Layer

The project uses TypeORM with MongoDB. The generic repository pattern abstracts all database operations behind a clean interface — swap the underlying database without touching your business logic.

Advanced Search

Every module gets powerful search capabilities out of the box:

{
  "attributes": [
    { "key": "name", "value": "test", "comparator": "LIKE" },
    { "key": "price", "value": 100, "comparator": "GREATER_THAN" }
  ],
  "orders": { "name": "ASC" },
  "type": "AND",
  "take": 10,
  "isPaginable": true
}

Dynamic filtering supports multiple comparators (EQUALS, LIKE, GREATER_THAN, etc.), pagination, and sorting.

AutoMapper Integration

Entity-to-domain and domain-to-DTO mapping is handled automatically via @automapper/nestjs, keeping layers decoupled and reducing boilerplate.

Docker & DevOps

A multi-stage Dockerfile produces a minimal production image. docker-compose.yml spins up the app alongside MongoDB and SonarQube. GitHub Actions handle CI (lint, test, build) and CD.

ServicePortDescription
Backend3000NestJS application
MongoDB27017Database
SonarQube9000Code quality dashboard

Testing

Unit tests cover services and guards. Integration tests hit actual endpoints through supertest. The test setup mirrors production as closely as possible — same database driver, same environment variable structure.

Security

  • Helmet for security headers
  • Rate limiting at 10,000 requests per 15 minutes
  • CORS configured out of the box
  • Input validation via class-validator with custom pipes

Project Structure

src/
├── modules/
│   ├── base/                 # Generic base module
│   │   ├── application/      # BaseService, port interfaces
│   │   ├── domain/           # BaseEntity, BaseRepository interface
│   │   ├── infrastructure/   # TypeOrmBaseRepository adapter
│   │   └── presentation/     # BaseController factory, base DTOs
│   │
│   ├── category/             # Simple CRUD example
│   ├── product/              # Extended CRUD with custom use cases
│   └── user/                 # Custom auth implementation
│
└── shared/
    ├── common/               # Error handling, logger, validators
    └── config/               # Environment, database, auth, email

Getting Started

git clone https://github.com/BrahimAbdelli/nestier.git
cd nestier
cp .env.example .env
npm install
docker-compose up -d
npm run start:dev

The API is live at http://localhost:3000/api. Swagger docs are available at /docs.

Tech Stack

CategoryTechnology
FrameworkNestJS 11
LanguageTypeScript 5.9
DatabaseMongoDB via TypeORM
AuthenticationJWT
Validationclass-validator + class-transformer
Mapping@automapper/nestjs
LoggingWinston
EmailMailjet
DocumentationSwagger / OpenAPI
TestingJest + Supertest
Code QualityESLint, Prettier, SonarQube
ContainerizationDocker + Docker Compose

What's Next

Nestier is actively maintained. Planned additions include WebSocket support, file upload with S3 pre-signed URLs, audit module, a message broker logic, Contributions are welcome — check the repo for open issues.

Brahim Abdelli