A comprehensive microservices-based car rental platform with advanced features including face authentication, real-time reservations, insurance management, and fleet tracking.
E-Krini follows a microservices architecture with the following components:
- Frontend: React + Vite + TailwindCSS (Port: 5173)
- API Gateway: Request routing and rate limiting (Port: 4000)
- Auth Service: User authentication, JWT tokens, OAuth2 (Port: 3001)
- Fleet Service: Vehicle and category management (Port: 3002)
- Reservation Service: Booking and contract management (Port: 3003)
- Assurance Service: Insurance and accident reports (Port: 3004)
- Feedback Service: Customer feedback and complaints (Port: 3005)
- Promotion Service: Coupons and promotions (Port: 3006)
- Maintenance Service: Vehicle maintenance and parts inventory (Port: 3007)
- Discovery Service: Service registry (Port: 3500)
- AI Backend: Python Flask for face authentication (Port: 5000)
- MongoDB: Primary database for all services
- Redis: Rate limiting and caching
- Docker and Docker Compose
- Node.js 18+ (for local development)
- Python 3.9+ (for AI backend)
- MongoDB 6.0+
- Redis 7.0+
git clone https://github.com/kammounmedaziz/e-krini.git
cd e-krini# Copy environment files
cp .env.example .env
# Setup each service
cd backend/auth-user-service && cp .env.example .env
cd ../fleet-service && cp .env.example .env
cd ../reservation-service && cp .env.example .env
# ... repeat for other servicescd backend
docker-compose up -dThis will start all 11 containers:
- MongoDB
- Redis
- Gateway Service
- Discovery Service
- 7 Microservices
- AI Backend
# Check all containers are running
docker-compose ps
# Check service health
./check-services.sh- Frontend: http://localhost:5173
- API Gateway: http://localhost:4000
- Swagger UI: http://localhost:4000/api-docs
See POSTMAN_ENDPOINTS_GUIDE.txt for comprehensive API documentation with 90+ endpoints across 16 service categories.
# Login
POST http://localhost:4000/api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "Admin@123"
}POST http://localhost:4000/api/cars
Authorization: Bearer {{admin_token}}
Content-Type: application/json
{
"nom": "Toyota Corolla 2024",
"category": "{{category_id}}",
"matricule": "TUN-5678",
"marque": "Toyota",
"modele": "Corolla",
"prixParJour": 90,
"disponibilite": true
}POST http://localhost:4000/api/reservations
Authorization: Bearer {{access_token}}
Content-Type: application/json
{
"clientId": "{{client_id}}",
"carId": "{{car_id}}",
"startDate": "2024-12-25T00:00:00.000Z",
"endDate": "2024-12-30T00:00:00.000Z",
"insuranceType": "premium",
"carModel": "Corolla",
"carBrand": "Toyota",
"dailyRate": 90
}- Authentication (8 endpoints): Register, login, 2FA, password reset
- User Profile (4 endpoints): Profile management, password change, profile picture
- Admin (6 endpoints): User management, KYC review
- Agency Profile (4 endpoints): Agency registration and management
- Insurance Profile (3 endpoints): Insurance company management
- Fleet/Cars (10 endpoints): Vehicle CRUD, search, availability
- Categories (5 endpoints): Vehicle category management
- Reservations (14 endpoints): Booking, cancellation, statistics
- Contracts (11 endpoints): Contract generation, signing, PDF download
- Assurance (7 endpoints): Insurance policies
- Constat (6 endpoints): Accident reports
- Feedback (7 endpoints): Customer feedback and complaints
- Promotions (6 endpoints): Marketing promotions
- Coupons (7 endpoints): Discount coupons
- Maintenance (6 endpoints): Vehicle maintenance tracking
- Materiel (7 endpoints): Parts and materials inventory
# Auth Service
cd backend/auth-user-service
npm install
npm run dev
# Fleet Service
cd backend/fleet-service
npm install
npm run dev
# ... similar for other services# Run tests for a service
cd backend/auth-user-service
npm test
# Run with coverage
npm run test:coverage
# Integration tests
cd backend
docker-compose -f docker-compose.test.yml up -d# Lint code
npm run lint
# Format code
npm run formate-krini/
βββ frontend/ # React + Vite application
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ api/ # API client
β β βββ context/ # React context
β βββ package.json
βββ backend/
β βββ gateway-service/ # API Gateway
β βββ discovery-service/ # Service registry
β βββ auth-user-service/ # Authentication
β β βββ src/
β β β βββ controllers/ # Route handlers
β β β βββ models/ # Mongoose schemas
β β β βββ routes/ # Express routes
β β β βββ services/ # Business logic
β β β βββ middlewares/ # Custom middleware
β β β βββ utils/ # Helper functions
β β βββ tests/ # Jest tests
β βββ fleet-service/ # Vehicle management
β βββ reservation-service/ # Booking management
β βββ assurance-service/ # Insurance
β βββ feedback-complaints-service/
β βββ promotion-coupon-service/
β βββ maintenance-service/ # Maintenance & materials
β βββ docker-compose.yml
β βββ POSTMAN_ENDPOINTS_GUIDE.txt
βββ AI-backend/ # Python Flask face auth
βββ face_auth/
βββ face_auth_api.py
- JWT Tokens: Access tokens (15min) + Refresh tokens (7 days)
- Passport.js: OAuth2 integration (Google, Facebook)
- Face Authentication: AI-powered facial recognition
- Rate Limiting: Redis-based API rate limiting
- CORS: Configured for production origins
- Helmet: Security headers
- Input Validation: Express-validator + Yup
Each service maintains its own MongoDB database:
- auth-user-service: Users, KYC documents, sessions
- fleet-service: Cars, categories, maintenance records
- reservation-service: Reservations, contracts
- assurance-service: Insurance policies, accident reports
- feedback-complaints-service: Feedback, complaints
- promotion-coupon-service: Promotions, coupons
- maintenance-service: Maintenance records, materials inventory
The gateway proxies requests to microservices:
/api/auth/* β auth-user-service:3001
/api/users/* β auth-user-service:3001
/api/admin/* β auth-user-service:3001
/api/cars/* β fleet-service:3002
/api/categories/* β fleet-service:3002
/api/reservations/* β reservation-service:3003
/api/contracts/* β reservation-service:3003
/api/assurances/* β assurance-service:3004
/api/constats/* β assurance-service:3004
/api/feedbacks/* β feedback-complaints-service:3005
/api/promotions/* β promotion-coupon-service:3006
/api/coupons/* β promotion-coupon-service:3006
/api/maintenance/* β maintenance-service:3007
/api/materiel/* β maintenance-service:3007
- Winston: Structured logging across all services
- Health Checks:
/healthendpoint on every service - Service Discovery: Automatic service registration
- Error Tracking: Centralized error logging
-
Import the Postman collection from
backend/POSTMAN_ENDPOINTS_GUIDE.txt -
Create environment with variables:
base_url: http://localhost:4000access_token: [Set after login]admin_token: [Set after admin login]
-
Test authentication flow:
Login β Copy accessToken β Set as admin_token β Test protected endpoints
- Authentication: Login, register, refresh, password reset
- Fleet: Car CRUD, categories, availability checking
- Reservations: Create, update, cancel, confirm
- Feedback: Create with Tunisian phone format, status updates
- Coupons: Create with French fields, validation
- Maintenance: Add records with past dates, correct enums
- Materiel: Full updates, stock replenishment
Solution: Ensure MongoDB container is running and check connection strings in .env
Solution: Verify CORS_ORIGIN in gateway service .env includes http://localhost:5173
Solution: Use the refresh token endpoint to get a new access token
Solution: dernierMaintenance is optional. Omit it or provide a valid ISO date
Solution: Use Tunisian format: +216XXXXXXXX (e.g., +21612345678)
Solution: Ensure coupon dates (date_debut, date_fin) include current date
Solution: Include all required fields (nom, quantiteDisponible, prixUnitaire) or use /api/materiel/reapprovisionner/:id for stock-only updates
# Build all services
docker-compose -f docker-compose.prod.yml build
# Start in production mode
docker-compose -f docker-compose.prod.yml up -dNODE_ENV=production
MONGODB_URI=mongodb://production-host:27017
JWT_SECRET=<strong-secret-key>
REDIS_URL=redis://production-redis:6379
CORS_ORIGIN=https://yourdomain.com- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- ES Modules: Use
import/exportsyntax - Error Handling: Consistent JSON format
{success: false, message: "...", error: {...}} - Logging: Use Winston logger from
backend/common/utils/logger.js - Validation: Express-validator for input, Mongoose for schema
- Tests: Jest with minimum 80% coverage
- Linting: ESLint + Prettier configuration
This project is licensed under the MIT License.
- Lead Developer: Aziz Kammoun
- Repository: github.com/kammounmedaziz/e-krini
For issues and questions:
- Create an issue on GitHub
- Check the API Documentation
- Review the API Fixes Summary
Built with β€οΈ for the E-Krini Car Rental Platform