A modern Node.js API server built with TypeScript, Express, and Clean Architecture principles.
- TypeScript - Full type safety and modern JavaScript features
- Express.js - Fast, unopinionated web framework
- Clean Architecture - Well-structured, maintainable codebase
- ESLint - Code quality and consistency
- Jest - Comprehensive testing framework
- Husky - Git hooks for code quality
- Commitlint - Conventional commit message validation
- pnpm - Fast, disk space efficient package manager
- Prisma - Modern database toolkit and ORM
- MySQL - Robust relational database
- Nodemailer - Email functionality
- Docker - Containerized development and deployment
- Node.js >= 18.0.0
- pnpm >= 8.0.0
- Clone the repository:
git clone <repository-url>
cd nexus_aaaimx_api_server- Install dependencies:
pnpm install- Set up Git hooks:
pnpm run prepare| Script | Description |
|---|---|
pnpm dev |
Start development server with hot reload |
pnpm build |
Build the project for production |
pnpm start |
Start production server |
pnpm test |
Run tests |
pnpm test:watch |
Run tests in watch mode |
pnpm test:coverage |
Run tests with coverage report |
pnpm lint |
Run ESLint |
pnpm lint:fix |
Fix ESLint issues automatically |
pnpm type-check |
Run TypeScript type checking |
Start the development server:
pnpm devThe server will be available at http://localhost:3000
# Run the test suite
pnpm test
# Run tests in watch mode
pnpm test:watch
# Generate coverage report
pnpm test:coverage# Lint your code
pnpm lint
# Fix linting issues automatically
pnpm lint:fix
# Check TypeScript types
pnpm type-check# Generate Prisma client
pnpm db:generate
# Push schema changes to database
pnpm db:push
# Create and apply migrations
pnpm db:migrate
# Open Prisma Studio
pnpm db:studio
# Seed database with sample data
pnpm run prisma:seedThe project includes comprehensive seeders for initial data:
- Roles: committee, president, leader, co-leader, senior member, member
- Divisions: software, robotics, artificial_intelligence, cybersecurity, dep_ops, video_games
- Clubs: videogames
- Tags: 51+ technology-related tags (programming languages, frameworks, tools, etc.)
# Run all seeders
pnpm run prisma:seed
# Run individual seeders
tsx src/infrastructure/orm/seeders/roles.seeder.ts
tsx src/infrastructure/orm/seeders/divisions.seeder.ts
tsx src/infrastructure/orm/seeders/clubs.seeder.ts
tsx src/infrastructure/orm/seeders/tags.seeder.ts# Run all seeders
docker exec -it nexus_aaaimx_api_server bash -c "cd /usr/src/app && npx tsx src/infrastructure/orm/seeders/index.ts"
# Run individual seeders
docker exec -it nexus_aaaimx_api_server bash -c "cd /usr/src/app && npx tsx src/infrastructure/orm/seeders/roles.seeder.ts"
docker exec -it nexus_aaaimx_api_server bash -c "cd /usr/src/app && npx tsx src/infrastructure/orm/seeders/divisions.seeder.ts"
docker exec -it nexus_aaaimx_api_server bash -c "cd /usr/src/app && npx tsx src/infrastructure/orm/seeders/clubs.seeder.ts"
docker exec -it nexus_aaaimx_api_server bash -c "cd /usr/src/app && npx tsx src/infrastructure/orm/seeders/tags.seeder.ts"When running the application in Docker containers, use these commands to interact with the database:
# Push schema changes to database
docker exec -it nexus_aaaimx_api_server pnpm prisma db push --schema=src/infrastructure/orm/schema.prisma
# Generate Prisma client
docker exec -it nexus_aaaimx_api_server pnpm prisma generate --schema=src/infrastructure/orm/schema.prisma
# Create and apply migrations
docker exec -it nexus_aaaimx_api_server pnpm prisma migrate dev --schema=src/infrastructure/orm/schema.prisma
# Open Prisma Studio
docker exec -it nexus_aaaimx_api_server pnpm prisma studio --schema=src/infrastructure/orm/schema.prisma
# Seed database with sample data
docker exec -it nexus_aaaimx_api_server bash -c "cd /usr/src/app && npx tsx src/infrastructure/orm/seeders/index.ts"
# Connect to MySQL directly
docker exec -it nexus_aaaimx_mysql_db mysql -u nexus_aaaimx -p nexus_aaaimx_db
# View database logs
docker logs nexus_aaaimx_mysql_dbImportant Note: When using Docker, the database hostname
dbis only accessible from within the Docker network. Always use thedocker execcommands above to interact with the database from your local machine.
# Build and start services
pnpm docker:build
# Start services in development mode
pnpm docker:dev
# Start services with Docker Compose
pnpm docker:compose:up
# Stop Docker Compose services
pnpm docker:compose:down
# View Docker Compose logs
pnpm docker:compose:logs
# Restart services
pnpm docker:compose:restartsrc/
βββ application/ # Application layer (use cases, services)
βββ domain/ # Domain layer (entities, repositories)
βββ infrastructure/ # Infrastructure layer (external services, ORM)
βββ interfaces/ # Interface layer (controllers, routes, DTOs)
βββ shared/ # Shared utilities and constants
βββ tests/ # Test files
This project uses Husky to enforce code quality:
- pre-commit: Runs linting and tests before each commit
- commit-msg: Validates commit message format using conventional commits
Follow the Conventional Commits specification:
type(scope): description
Examples:
feat: add user authentication
fix(auth): resolve login validation issue
docs: update API documentation
style: format code according to style guide
refactor: restructure user service
test: add unit tests for auth module
chore: update dependencies
tsconfig.json- TypeScript configurationjest.config.js- Jest testing configuration.eslintrc.js- ESLint rules and configurationcommitlint.config.js- Commit message validation rules.husky/- Git hooks configuration
express- Web framework@prisma/client- Database ORMmysql- Database drivernodemailer- Email functionalitywinston- Loggingzod- Schema validation
typescript- TypeScript compiler@types/node- Node.js type definitions@types/express- Express type definitionseslint- Code lintingjest- Testing frameworkts-jest- TypeScript support for Jesthusky- Git hookscommitlint- Commit message validationtsx- TypeScript execution for development