eHiring là một hệ thống tuyển dụng toàn diện được xây dựng với kiến trúc microservices, sử dụng Angular cho frontend và NestJS cho backend. Dự án được quản lý bằng Nx workspace và triển khai với Docker containers.
- Docker: là một nền tảng ảo hóa cấp ứng dụng (application-level virtualization platform) cho phép đóng gói (package) và chạy ứng dụng trong các container – môi trường nhẹ, độc lập và nhất quán trên mọi hệ thống.
- OIDC: (OpenID Connect) là một lớp nhận dạng (identity layer) xây dựng trên OAuth 2.0. Nó giúp các ứng dụng xác thực người dùng một cách an toàn thông qua các nhà cung cấp danh tính (Identity Provider – IdP) như Google, Microsoft, Facebook hoặc hệ thống nội bộ
Áp dụng vào hệ thống: FE gọi qua OIDC Provider để đănng nhập, sau đó OIDC Provider trả về Access Token và dùng Access Token đó gắn vào các API gọi đến BE. BE sẽ gọi qua OIDC Provider để xác thực token và lấy thông tin user
- RESTful API: RESTful API là một kiểu thiết kế API (Application Programming Interface) dựa trên nguyên tắc REST (Representational State Transfer) – một kiến trúc dùng cho giao tiếp giữa các hệ thống qua giao thức HTTP.
Áp dụng vào hệ thống: tất cả các API từ FE gọi xuống BE đều dùng RESTful API, và hệ thống dùng thư viện nestjsx crud để xử lý query giữa FE và BE Xem thêm
- NATS: NATS là một hệ thống nhắn tin (messaging system) mã nguồn mở, được thiết kế để kết nối các dịch vụ, ứng dụng và thiết bị theo mô hình pub/sub (publish-subscribe) hoặc request/reply, với hiệu năng rất cao và độ trễ cực thấp.
Áp dụng vào hệ thống: các BE muốn giao tiếp với nhau thì dùng NATS để giao tiếp
- Commitizen: Commitizen (hay viết tắt là cz) là một công cụ hỗ trợ viết commit message chuẩn hóa theo một convention (quy ước) nhất định, thường dùng trong các dự án phần mềm để đảm bảo tính nhất quán và dễ tự động hóa (ví dụ: generate changelog, semantic versioning).
Ví dụ:
feat(auth): add login with Google feature
fix(ui): fix button not displaying on mobile
docs(readme): update installation guide
- Angular 19: Framework chính cho ứng dụng web
- TypeScript: Ngôn ngữ lập trình chính
- RxJS: Quản lý reactive programming và async operations
- ng-zorro-antd: Thư viện UI components chính (Ant Design cho Angular)
- ngx-echarts: Thư viện biểu đồ và visualization
- angular-auth-oidc-client: Xử lý OIDC authentication
- @ngneat/transloco: Đa ngôn ngữ và localization
- @angular/common/locales: Hỗ trợ locale data
- @ngrx/store: State management pattern
- @ngrx/effects: Side effects management
- Angular HTTP Client: API communication
- Angular CLI: Command line interface
- Webpack: Module bundler
- ESLint: Code linting
- Prettier: Code formatting
- NestJS: Node.js framework chính cho microservices
- TypeScript: Ngôn ngữ lập trình
- Express.js: HTTP server framework (underlying)
- MongoDB: Database chính
- Mongoose ODM cho data modeling
- Multi-tenant database architecture
- PostgreSQL: Database dùng để lưu cache các thông tin cho dashboard
- NATS: Message broker cho inter-service communication
- @nestjs/microservices: NestJS microservices package
- Transport.NATS: NATS transport layer
- Passport.js: Authentication middleware
- JWT Strategy: JSON Web Token authentication
- OIDC (OpenID Connect): Identity provider integration
- Keycloak: Identity and access management
- jwks-rsa: JSON Web Key Set handling
- Swagger/OpenAPI: API documentation
- @nestjs/swagger: NestJS Swagger integration
- REST APIs: RESTful service architecture
- OpenTelemetry: Distributed tracing và monitoring
- Prometheus: Metrics collection
- @smc/open-telemetry: Custom telemetry module
- MinIO: Object storage service
- Multer: File upload handling
- Sharp: Image processing
- Consul: Service discovery và configuration
- Directus: Headless CMS integration
- Third-party APIs: Various external service integrations
- Nx: Monorepo management và build system
- Nx Cloud: Distributed caching và CI optimization
- Docker: Container platform
- Docker Compose: Multi-container applications
- Kubernetes: Container orchestration (production)
- Helm Charts: Kubernetes package manager
- Jest: Unit testing framework
- Cypress: End-to-end testing
- Supertest: API testing
- Angular Testing Utilities: Component testing
- ESLint: JavaScript/TypeScript linting
- Prettier: Code formatting
- Husky: Git hooks
- lint-staged: Pre-commit linting
- GitLab CI: Continuous integration
- Docker Registry: Container image storage
- Trivy & Grype: Container security scanning
- Node.js: v18+ (khuyến nghị v20)
- npm/yarn: Package manager
- Docker: v20+ và Docker Compose
- Git: Version control
- MongoDB: v6 (local hoặc Docker)
- PostgreSQL: v16 (cho services dashboard)
- NATS: Message broker
git clone <repository-url>
cd ehiring
# Cài đặt tất cả dependencies
yarn install
Tạo file .env trong thư mục root:
# Database Configuration
MONGODB_USERNAME=your_username
MONGODB_PASSWORD=your_password
MONGODB_HOSTNAME=localhost
MONGODB_PORT=27017
MONGODB_DATABASE=ehiring
MONGODB_URI=mongodb://localhost:27017/ehiring
# PostgreSQL
TYPEORM_TYPE=postgres
TYPEORM_HOST=localhost
TYPEORM_PORT=5432
TYPEORM_USERNAME=postgres
TYPEORM_PASSWORD=postgres
TYPEORM_DATABASE=ehiring
# NATS Configuration
NATS_SERVERS_1=nats://localhost:4222
# Authentication
OIDC_CLIENT_ID=ehiring
OIDC_JWKS_URI=https://your-keycloak/jwks
OIDC_ISSUER=https://your-keycloak
OIDC_CA_FILE=""
OIDC_SYNC_USER_INFO=true
# Application
APP_TENANT=default
APP_BACKEND_URL=http://localhost:3000
EHIRING_DOMAINS=localhost:4200
APP_LOGGER_LEVEL=debug
# Security
EHIRING_DYNAMIC_TOKEN_SECRET=your_secret_key
EHIRING_DYNAMIC_TOKEN_STEP=30
EHIRING_DYNAMIC_TOKEN_WINDOW=1
EHIRING_DYNAMIC_TOKEN_LENGTH=6
¶ Development Commands
# Khởi động Angular development server
yarn nx serve ehiring-host
# Build frontend
yarn nx build ehiring-host
# Run tests
yarn nx test ehiring-host
# E2E tests
yarn nx e2e ehiring-host-e2e
# Khởi động specific backend service
yarn nx serve users-backend
yarn nx serve portal-backend
yarn nx serve recruitment-backend
# Build backend service
yarn nx build users-backend
# Run tests
yarn nx test users-backend
# Khởi động các microservices
yarn nx serve services-cv-parser
yarn nx serve services-gpt
yarn nx serve services-integration-adapter
yarn nx serve services-notifications
# Build specific service container
yarn nx run users-backend:container
yarn nx run ehiring-host:container
# Build tất cả containers
yarn nx run-many --target=container --all
# Khởi động toàn bộ stack
docker-compose -f docker-compose.dev.yml up
# Khởi động services cụ thể
docker-compose up frontend backend-users backend-portal
-
Port Conflicts
- Frontend: http://localhost:4200
- Backend services: 3000-3300 range
- MongoDB: 27017
- PostgreSQL: 5432
- NATS: 4222
-
Database Connection Issues
- Kiểm tra MongoDB/PostgreSQL đang chạy
- Verify connection strings trong
.env
- Check firewall settings
-
Authentication Issues
- Verify OIDC configuration
- Check Keycloak connectivity
- Validate JWT tokens
¶ Useful Commands
# Kiểm tra service health
curl http://localhost:3000/health
# Clean và rebuild
yarn nx reset
yarn install
yarn nx build-many --target=build --all
- Kubernetes cluster
- Helm charts trong
/helm directory
- GitLab CI/CD pipelines
- Container registry:
rc.paas.ttgt.vn/ehiring/
¶ Deployment Commands
# Deploy với Helm
helm upgrade --install ehiring ./helm/ehiring
# Scale services
kubectl scale deployment users-backend --replicas=3
- Single Page Application (SPA) với Angular
- Micro-frontend approach với lazy-loaded modules
- Shared UI libraries trong
libs/ui
- Feature-based routing và module organization
- Microservices pattern với NestJS
- Event-driven communication qua NATS
- Multi-tenant architecture với database separation
- API Gateway pattern cho external access
- Frontend → API Gateway → Backend Services
- Services ↔ NATS ↔ Other Services
- Services → MongoDB/PostgreSQL
- Authentication → Keycloak/OIDC