- Overview
- Architecture
- Microservices
- Technology Stack
- Prerequisites
- Getting Started
- API Documentation
- Security
- Business Rules
- Service Communication
- Contributing
ChainFlow is a comprehensive supply chain management system built with a microservices architecture. The platform provides end-to-end supply chain management from raw material procurement to finished product delivery, featuring seamless integration between procurement, production, and customer delivery modules.
- Procurement Management: Supplier management, raw materials tracking, and supply order processing
- Production Management: Product manufacturing, bill of materials (BOM), and production order scheduling
- Customer & Delivery Management: Customer orders, delivery tracking, and logistics coordination
- Centralized Authentication: Secure role-based access control across all services
- Service Discovery: Dynamic service registration and discovery with Eureka
- API Gateway: Single entry point for all client requests with routing and load balancing
The system follows a microservices architecture with synchronous communication using Feign Client, service discovery via Eureka, and a centralized API Gateway.
- Eureka Server (Port: 8761) - Service registry and discovery
- API Gateway (Port: 8888) - Single entry point for client requests
- Auth Service (Port: 8081) - Authentication and authorization
- Supply Service (Port: 8082) - Procurement management
- Production Service (Port: 8083) - Manufacturing operations
- Customer Service (Port: 8084) - Customer orders and delivery
Service registry that enables service discovery and registration for all microservices.
Responsibilities:
- Service registration and health monitoring
- Dynamic service discovery
- Load balancing support
Single entry point for all client requests with intelligent routing.
Responsibilities:
- Request routing to appropriate microservices
- Load balancing
- Cross-cutting concerns (logging, monitoring)
- Rate limiting and throttling
Centralized authentication and authorization service.
Responsibilities:
- User account management
- Role-based access control (RBAC)
- Authentication via email/password in HTTP headers
- User role assignment and modification
Supported Roles:
ADMIN- Full system access- Procurement Module:
GESTIONNAIRE_APPROVISIONNEMENTRESPONSABLE_ACHATSSUPERVISEUR_LOGISTIQUE
- Production Module:
CHEF_PRODUCTIONPLANIFICATEURSUPERVISEUR_PRODUCTION
- Delivery Module:
GESTIONNAIRE_COMMERCIALRESPONSABLE_LOGISTIQUESUPERVISEUR_LIVRAISONS
Manages procurement operations including suppliers, raw materials, and supply orders.
Core Entities:
- Supplier: Vendor management with ratings and lead times
- RawMaterial: Inventory tracking with critical stock alerts
- SupplyOrder: Purchase order management with status tracking
Key Features:
- Supplier CRUD operations with active order validation
- Raw material inventory management
- Critical stock level monitoring
- Supply order lifecycle management (EN_ATTENTE, EN_COURS, RECUE)
- Supplier search by name or code
- Pagination support for all listing endpoints
Handles manufacturing operations, product management, and production planning.
Core Entities:
- Product: Finished goods with production time and cost tracking
- BillOfMaterial (BOM): Material requirements for each product
- ProductionOrder: Manufacturing order management
Key Features:
- Product lifecycle management
- BOM definition and material consumption tracking
- Production order scheduling and prioritization
- Material availability verification before production
- Production time estimation
- Order status tracking (EN_ATTENTE, EN_PRODUCTION, TERMINE, BLOQUE)
- Priority order handling
Manages customer relationships, orders, and delivery logistics.
Core Entities:
- Customer: Client information and order history
- Order: Customer purchase orders
- Delivery: Shipment tracking and logistics
Key Features:
- Customer account management
- Customer order processing
- Delivery scheduling and tracking
- Vehicle and driver assignment
- Delivery cost calculation
- Order status management (EN_PREPARATION, EN_ROUTE, LIVREE)
- Customer search capabilities
- Spring Boot 3.x - Application framework
- Spring Cloud - Microservices infrastructure
- Spring Cloud Netflix Eureka - Service discovery
- Spring Cloud Gateway - API gateway
- Spring Cloud OpenFeign - Synchronous service communication
- Spring Data JPA - Data persistence
- Spring Security - Authentication and authorization
- Hibernate - ORM framework
- MySQL / PostgreSQL - Relational database (each service has its own database)
- REST API - RESTful web services
- Swagger - API documentation and testing interface
- MapStruct - DTO mapping
- Spring Security - Authentication and authorization
- Bean Validation - Input validation
- Jenkins - Continuous integration and deployment
- SonarQube - Code quality and security analysis
- JaCoCo - Code coverage reporting
- Docker - Containerization and deployment
- JUnit 5 - Unit testing framework
- Mockito - Mocking framework for unit tests
- AssertJ - Fluent assertion library
- Spring Boot Test - Integration testing support
- MockMvc - REST API testing
- @WebMvcTest - Controller layer testing
- @DataJpaTest - Repository layer testing
- @SpringBootTest - Full integration testing
- Java 17+
- Maven 3.8+
- PostgreSQL 15+
- Docker
git clone https://github.com/your-org/ChainFlow-pro.git
cd ChainFlow-proUpdate application.yml in each service with your database credentials.
Visit Eureka Dashboard: http://localhost:8761 All services should be registered and showing as UP.
All API requests should go through: http://localhost:8888
Once services are running, access Swagger UI documentation:
- Auth Service: http://localhost:8081/swagger-ui.html
- Supply Service: http://localhost:8082/swagger-ui.html
- Production Service: http://localhost:8083/swagger-ui.html
- Customer Service: http://localhost:8084/swagger-ui.html
Via API Gateway: http://localhost:8888/{service-name}/swagger-ui.html
Swagger provides interactive API documentation where you can:
- Explore all available endpoints
- View request/response schemas
- Test APIs directly from the browser
- Understand authentication requirements
The system uses Spring Security for comprehensive security implementation:
- JWT-based authentication
- Role-based access control (RBAC) across all services
- Secure password encryption
- Protected REST endpoints with method-level security
API requests include authentication credentials:
GET /api/suppliers
Headers:
Authorization: Bearer <token>Each endpoint is protected based on user roles. Access is validated by the Auth Service and enforced across all microservices using Spring Security filters and interceptors.
- A raw material can have multiple suppliers
- A supply order is associated with a single supplier
- Suppliers cannot be deleted if they have active orders
- Critical stock levels trigger alerts (optional: email notifications via SMTP scheduler)
- Each production order consumes materials according to the BOM
- Products can only be manufactured if all required materials are available
- Products cannot be deleted if they have associated production orders
- Priority orders are processed before standard orders
- Customers can have multiple orders
- Each customer order is linked to a single delivery
- Deliveries are only possible if the product is available in stock
- Customers cannot be deleted if they have active orders
Services communicate synchronously using Spring Cloud OpenFeign:
Example: Production Service calling Supply Service
@FeignClient(name = "supply-service")
public interface SupplyServiceClient {
@GetMapping("/api/materials/{id}")
MaterialAvailabilityDTO checkAvailability(@PathVariable Long id);
}Common Integration Patterns:
- Production β Supply: Check material availability before creating production orders
- Customer β Production: Verify product stock before accepting customer orders
- All Services β Auth: Validate user permissions and roles
Services register with Eureka on startup and discover other services dynamically. Feign clients use service names (not hard-coded URLs) for inter-service communication.
mvn testmvn verifyGenerate code coverage reports:
mvn clean test jacoco:reportView coverage report at: target/site/jacoco/index.html
# Run SonarQube analysis
mvn clean verify sonar:sonar \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=your-tokenThe project includes a comprehensive CI/CD pipeline:
Pipeline Stages:
- Checkout - Pull latest code from repository
- Build - Compile all microservices
- Unit Tests - Execute JUnit tests
- Code Quality - SonarQube analysis
- Docker Build - Build Docker images for each service
- Docker Push - Push images to Docker registry
- Minimum Code Coverage: 80%
- SonarQube Quality Gate: Must pass
- Zero Critical/Blocker Issues
- All Tests Pass
docker-compose up -daliyara29/eureka-server:latestaliyara29/api-gateway:latestaliyara29/auth-service:latestaliyara29/supply-service:latestaliyara29/production-service:latestaliyara29/customer-service:latest
- 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
This project is licensed under the MIT License.
For questions or support, please contact: support@ChainFlow-pro.com
ChainFlow - Powering Modern Supply Chain Management π