A modern TypeScript boilerplate using InversifyJS, FastifyJS, TSOA, Swagger, Zod, and Prisma following clean architecture principles with hexagonal design.
- TypeScript: Fully typed codebase using ECMAScript 2024
- Clean Architecture: Domain-driven design with hexagonal architecture principles
- InversifyJS: Powerful dependency injection
- FastifyJS: High performance web framework
- TSOA: TypeScript OpenAPI generator with automatic routes
- Swagger: API documentation
- Zod: Schema validation for request/response
- Prisma: Type-safe ORM with PostgreSQL
- Jest: Testing framework
- Docker: Container support for both development and production
├── prisma/ # Prisma schema and migrations
├── src/
│ ├── application/ # Application layer: use cases and DTOs
│ │ ├── dtos/ # Data transfer objects
│ │ ├── services/ # Application services
│ │ └── useCases/ # Business use cases
│ ├── domain/ # Domain layer: business logic
│ │ ├── entities/ # Domain entities
│ │ ├── repositories/ # Repository interfaces
│ │ ├── services/ # Domain services
│ │ └── valueObjects/ # Value objects
│ ├── infrastructure/ # Infrastructure layer: frameworks and tools
│ │ ├── config/ # Application configuration
│ │ ├── database/ # Database connection
│ │ ├── repositories/ # Repository implementations
│ │ └── server/ # Server implementation
│ ├── interface/ # Interface layer: controllers and routes
│ │ ├── controllers/ # API controllers
│ │ ├── middleware/ # HTTP middleware
│ │ └── validators/ # Request validators
│ ├── shared/ # Shared resources
│ │ ├── types/ # Type definitions
│ │ └── utils/ # Utility functions
│ └── generated/ # Auto-generated files
└── index.ts # Application entry point
- Node.js 18+ (LTS recommended)
- Docker and Docker Compose
- Clone the repository:
git clone https://github.com/yourusername/inversifyjs-fastifyjs-boilerplate.git
cd inversifyjs-fastifyjs-boilerplate- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env
# Edit .env file as needed- Start the database:
docker-compose up -d- Run database migrations:
npm run prisma:migrate- Generate TSOA routes and swagger specs:
npm run swagger:generate- Start the development server:
npm run devVisit http://localhost:3000/docs to view the Swagger documentation.
npm run buildnpm testTo build and run the application using Docker:
# Build the image
docker build -t inversifyjs-fastifyjs-app .
# Run the container
docker run -p 3000:3000 --env-file .env inversifyjs-fastifyjs-appOr use Docker Compose:
docker-compose up --buildMIT