Create NestJS Hexagonal & Clean Architecture
Description
Nest boilerplate which apply the hexagonal & clean architecture
Start
$ npx create-nestjs-hexagonal <project>
Installation
$ npm install
Running the app
# development mode
$ npm run start:dev
# production mode
$ npm run start:prod
Folder Structure
Global
The Global Folder contains global properties like, global used interface, error type, external module configuration and etc..
abstract
abstract folder include interface of factory / mapper / model / use-case and etc you can add interface file which used global
config
config folder include setting file to connection other server like DB, MQ, GRPC
It also include the constant folder which used globally
Error
error folder include custom error settings
Lib
Lib folder contain the external module custom library which can use the adapter files.
Construct of functional folder
We Declare the functional folder is set of implemented the backend function which seperated by DDD rules
you can change user folder to other name or add new folder, like product, order. It's only example of this template. I recommend to make folder follow the DDD rule
The User folder construct adaptor, core, port folder
Port
port(hexagonal architecture) folder include the port file that expressed interface file
Adapter
adapter is implemented by port interface file. It contains controller, repository and etc
Core
adapter is implemented by port interface file. It contains controller, repository and etc
application
The application folder include business logic implement which contain the use-case, factory, mapper files.
domain
The domain folder include core model logic files
type
Type folder include the Core of type like model properties type, etd