A production-ready Clean Architecture foundation for enterprise TypeScript applications
- Overview
- Features
- Prerequisites
- Quick Start
- Project Structure
- Available Scripts
- Environment Variables
- API Documentation
- Security
- Monitoring
- Testing
- CI/CD
- Docker Support
- Contributing
- Project Roadmap
- License
- Support
- Acknowledgments
TypeScript Enterprise Nexus is a comprehensive Clean Architecture API built with TypeScript, featuring enterprise-grade capabilities including contracts to integrate with any database provider (e.g., MongoDB, Redis, PostgreSQL), to any communication protocol (e.g., HTTP, gRPC, Message), OpenAPI documentation, comprehensive monitoring, security middleware, dependency injection, and extensive testing support.
- β¨ Clean Architecture implementation with clear separation of concerns
- π TypeScript for enhanced type safety and developer experience
- π Dependency Injection using InversifyJS
- ποΈ MongoDB integration with Mongoose
- π OpenAPI Documentation using Swagger
- π Authentication & Authorization with JWT
- π‘οΈ Comprehensive Security Features
- Helmet for HTTP headers security
- Rate limiting
- XSS protection
- CORS
- HPP (HTTP Parameter Pollution) protection
- π Monitoring & Logging
- Express Status Monitor
- Prometheus metrics
- Winston logger
- Morgan HTTP request logging
- π§ͺ Testing
- Jest for unit and integration tests
- Supertest for E2E testing
- Test containers for integration tests
- π οΈ Development Tools
- ESLint & Prettier
- Husky for git hooks
- Dependency cruiser for architecture validation
- TypeDoc for documentation generation
- Node.js >= 18.0.0
- NPM >= 9.0.0
- MongoDB >= 5.0
- Docker (optional)
- Clone the repository
git clone https://github.com/yourusername/typescript-enterprise-nexus.git
cd typescript-enterprise-nexus
- Install dependencies
npm install
- Environment setup
cp .env.example .env
Edit the .env
file with your configuration.
- Start MongoDB
# Using Docker
docker run --name mongodb -d -p 27017:27017 mongo:latest
# Or use your local MongoDB installation
- Run the application
# Development mode
npm run dev
# Production mode
npm run build && npm run start:prod
-
application/
: Contains application-specific business rules and use cases- Implements the core application logic
- Defines interfaces for external dependencies
- Manages application state and flow
-
enterprise/
: Houses domain entities/events/dtos- Contains business entities and logic
- Independent of external frameworks
- Defines core business rules and constraints
-
infrastructure/
: Implements technical capabilities and frameworks- Handles database operations
- Manages external services integration
- Provides technical implementations of interfaces
- Contains framework-specific code
-
interface/
: Handles external communication- Manages HTTP requests and responses
- Implements API endpoints
- Handles data transformation
- Contains presentation logic
-
__tests__/
: Contains all test-related files- Organized by test type
- Includes test helpers and fixtures
- Follows the same structure as source code
index.ts
: Application entry pointApplication.ts
: Main application classtypes/
: Global type definitionsutils/
: Shared utility functions
- Follows Clean Architecture principles
- Maintains separation of concerns
- Dependencies flow inward
- External dependencies are isolated in infrastructure layer
- Business logic is framework-agnostic
This structure promotes:
- Modularity
- Testability
- Maintainability
- Scalability
- Clear separation of concerns
npm run dev
- Start development server with hot-reloadnpm run build
- Build for productionnpm run start:prod
- Start production server
npm test
- Run all testsnpm run test:coverage
- Run tests with coverage reportnpm run test:integration
- Run integration testsnpm run test:e2e
- Run end-to-end tests
npm run lint
- Run ESLintnpm run lint:fix
- Fix ESLint errorsnpm run format
- Format code with Prettier
npm run docs:generate
- Generate TypeDoc documentationnpm run deps:graph
- Generate dependency graph
npm run security:audit
- Run security auditnpm run deps:check
- Check for unused dependenciesnpm run fresh-install
- Clean install dependencies
Key environment variables required for the application:
PORT=3000
MONGODB_URL=mongodb://127.0.0.1:27017/typescript-enterprise-nexus
JWT_SECRET=your-jwt-secret
SMTP_HOST=email-server
# See .env.example for all required variables
When the application is running, access the OpenAPI documentation at:
- Swagger UI:
http://localhost:3000/api/v1/docs
This project implements various security best practices:
- JWT-based authentication
- Rate limiting
- HTTP Security Headers
- XSS Protection
- CORS Configuration
- Parameter Pollution Protection
- Security Audit Tools
The application includes several monitoring endpoints:
/api/v1/status
- Application status/api/v1/metrics
- Prometheus metrics/api/v1/monitor
- Real-time monitoring dashboard
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run specific test adapters
npm run test:integration
npm run test:e2e
The project includes configurations for:
- GitHub Actions workflows
- Husky pre-commit hooks
- ESLint and Prettier checks
- Automated testing
- Security audits
# Build the image
docker build -t typescript-enterprise-nexus .
# Run the container
docker run -p 3000:3000 --memory=2g --cpus=2 typescript-enterprise-nexus
# Development with Docker Compose
docker-compose up
We welcome contributions to TypeScript Enterprise Nexus! Please check out our Contributing Guide for guidelines about how to proceed.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Our vision for TypeScript Enterprise Nexus includes:
- GraphQL support
- Microservices communication patterns
- Event sourcing implementation
- CQRS pattern support
- Enhanced observability features
- Multi-tenant architecture support
- Expanded database adapters
- Kubernetes deployment templates
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository or contact the maintainers.
- Clean Architecture principles by Robert C. Martin
- Express.js community
- TypeScript team
- All contributors and maintainers
Built with β€οΈ using TypeScript and Clean Architecture principles
β If you find TypeScript Enterprise Nexus useful, please consider giving it a star on GitHub! β