An enterprise-grade payroll management system built with NestJS and Next.js, designed for high scalability and maintainability. This solution automates payroll processing by integrating with third-party attendance management APIs, eliminating manual data handling and reducing errors.
It supports weekly, bi-weekly, and monthly payroll calculations for over 100,000 companies, processing inputs like worked hours, overtime, medical leaves, and absences. Engineered with clean architecture and best practices, this system enhances payroll administrators' efficiency, especially when managing multiple companies.
Nicolás Silva (@nicolascine)
This project showcases modern software engineering practices through a real-world payroll system implementation:
- Clean Architecture principles
- Queue-based processing for scalability
- Real-time monitoring
- Test-driven development
- Comprehensive documentation
---
config:
layout: fixed
---
graph TB
subgraph "Frontend Layer"
A[Next.js Client] --> B[React Components]
B --> C[API Client]
end
subgraph "API Gateway"
D[NestJS API] --> E[Guards/Middleware]
E --> F[Controllers]
F --> G[Services]
end
subgraph "Business Logic"
G --> H[Repositories]
G --> I[Queue Producers]
end
subgraph "Background Processing"
I --> J[Bull Queue]
J --> K[Queue Consumers]
K --> L[Payroll Processor]
end
subgraph "Data Layer"
H --> M[(PostgreSQL)]
L --> M
end
subgraph "External Services"
N[Partner Attendance API]
O[Excel Parser Service]
end
subgraph "Infrastructure"
P[(Redis)]
end
C --> D
G --> N
G --> O
J --> P
I --> P
K --> P
style A fill:#94e2cd
style D fill:#94b5e2
style M fill:#e29494
style P fill:#e2d894
-
Frontend Flow
- Next.js client renders UI components
- React components handle user interactions
- API client manages backend communication
-
API Gateway
- Guards/Middleware handle authentication and validation
- Controllers route requests to appropriate services
- Services orchestrate business logic
-
Business Logic
- Repositories manage data persistence
- Queue producers handle async job creation via Bull Queue
- External service integration
-
Background Processing
- Bull Queue manages job queuing in Redis
- Queue consumers process async tasks
- Payroll processor handles calculations
-
Data Layer
- PostgreSQL stores application data
- Redis manages queue state and job processing
- Data consistency across services
- Next.js 14+
- React 18
- TailwindCSS
- TypeScript
- NestJS
- Bull Queue
- TypeORM
- Class Validator
- Swagger/OpenAPI
- PostgreSQL (Main Database)
- Redis (Queue Management)
- Docker & Docker Compose
- Environment Configuration
- Health Checks
- Async Processing: Bull Queue implementation for payroll calculations
- Real-time Monitoring: Bull Board integration
- API Documentation: OpenAPI/Swagger integration
- Type Safety: TypeScript throughout the stack
- Data Validation: Class-validator implementation
- Error Handling: Global exception filters
- Security: JWT, Helmet, Rate limiting
# Clone repository
git clone https://github.com/nicolascine/payroll-system
cd payroll-system
# Start services
make build
make up
Access points:
- 🖥️ Frontend: http://localhost:3000
- 🔌 API: http://localhost:3001
- 📊 Queue Monitor: http://localhost:3001/admin/queues
- 📚 API Docs: http://localhost:3001/api
# Install dependencies
make install
# Run tests
make test
# Run linter
make lint
# Access containers
make shell-backend
make shell-frontend
.
├── backend/
│ ├── src/
│ │ ├── payroll/ # Payroll domain
│ │ ├── attendance/ # Attendance domain
│ │ ├── common/ # Shared utilities
│ │ └── main.ts # Application entry
│ └── test/ # Test suites
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Next.js pages
│ │ └── services/ # API services
│ └── tests/ # Frontend tests
└── docker-compose.yml # Container orchestration
-
Clean Architecture
- Domain-driven design
- Separation of concerns
- Dependency injection
-
Testing Strategy
- Unit tests
- Integration tests
- E2E tests
-
Code Quality
- ESLint configuration
- Prettier formatting
- Git hooks (husky)
-
Performance
- Async job processing
- Caching strategies
- Database indexing
-
Security
- Input validation
- Rate limiting
- JWT authentication
- CORS protection
- Demo Guide - Interactive demonstration
- API Documentation - OpenAPI/Swagger
- Queue Monitor - Bull Board
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License - see the LICENSE file for details