BackendCore is a Node.js backend template built with Express and TypeScript for my personal use. It provides a clean, scalable architecture with built-in support for request validation, structured logging, environment configuration, and Docker-based deployment.
- TypeScript-first development
- Zod v4 validation (type-safe request validation)
- Structured logging with request tracing
- Environment validation using Zod
- Clean architecture (Route → Controller → Service)
- Centralized error handling
- Dockerized setup for easy deployment
- Scalable modular structure
npm install
Create a .env file:
PORT=5000
NODE_ENV=development
LOG_LEVEL=info
npm run dev
Build and run with Docker
docker-compose up --build
Request validation is handled using Zod:
- Ensures type safety
- Sanitizes input
- Prevents invalid data from reaching controllers
- Structured JSON logs
- Request-level tracing with
requestId - Separate error and combined logs
- All environment variables are validated at startup
- App fails fast on invalid configuration
- Routes: define endpoints + middleware
- Controllers: handle HTTP layer
- Services: contain business logic
- Reduce setup time for new services
- Enforce consistency across projects
- Provide a scalable backend foundation