Food Ordering System: A microservices-based backend application for real-time food ordering and tracking. Built with Java, Spring Boot, and Apache Kafka. Implements Domain-Driven Design, Event-Driven Architecture Saga-Pattern, and Clean Architecture principles.
Food Ordering System is a backend application built using a microservices architecture to facilitate seamless and efficient food ordering processes. Customers can place orders from various restaurants, make secure payments, and receive real-time updates, while restaurants can manage orders and menus effectively.
This README will be continuously updated to reflect the latest changes and improvements as the project progresses.
The project follows the Hexagonal Architecture (Ports and Adapters) pattern, emphasizing Domain-Driven Design (DDD) and Clean Architecture principles. This ensures a clear separation of concerns and promotes scalability and maintainability.
The project is modularized, reflecting its microservices architecture:
common
: Shared utilities and code across microservices.infrastructure
: Infrastructure components like Kafka configurations and Outbox pattern implementations.Each microservice comprises:
domain
: Domain models and core business logic.application
: Application services and use cases.dataaccess
: Data repositories and database interactions.messaging
: Kafka producers and consumers.outbox
: Components related to the Outbox pattern for reliable message handling.container
: Spring Boot application entry point.Clone the Repository
git clone https://github.com/sogutemir/FoodOrderingSystem.git
Navigate to the Project Directory
cd FoodOrderingSystem
Build the Project
mvn clean package
Start Docker Containers
Ensure that Docker is running, then start the required services:
docker-compose -f common.yml -f init_kafka.yml up -d
docker-compose -f common.yml -f kafka_cluster.yml up -d
docker-compose -f common.yml -f zookeeper.yml up -d
Run Microservices
Open separate terminals for each microservice and run:
# Order Service
java -jar order-service/order-container/target/order-container-1.0-SNAPSHOT.jar
# Payment Service
java -jar payment-service/payment-container/target/payment-container-1.0-SNAPSHOT.jar
# Restaurant Service
java -jar restaurant-service/restaurant-container/target/restaurant-container-1.0-SNAPSHOT.jar
# Customer Service
java -jar customer-service/customer-container/target/customer-container-1.0-SNAPSHOT.jar
The application exposes RESTful APIs for interaction. Here are some of the key endpoints:
POST /orders
GET /orders/{orderId}
PUT /orders/{orderId}
DELETE /orders/{orderId}
POST /payments
POST /restaurants/{restaurantId}/orders/{orderId}/approve
POST /restaurants/{restaurantId}/orders/{orderId}/reject
POST /customers
GET /customers/{customerId}
Create Order
Endpoint: POST http://localhost:8181/orders
Headers:
Content-Type: application/json
Request Body:
{
"customerId": "d215b5f8-0249-4dc5-89a3-51fd148cfb41",
"restaurantId": "d215b5f8-0249-4dc5-89a3-51fd148cfb45",
"address": {
"street": "Main Street",
"postalCode": "12345",
"city": "Amsterdam"
},
"price": 200.00,
"items": [
{
"productId": "product-1",
"quantity": 1,
"price": 50.00,
"subTotal": 50.00
},
{
"productId": "product-2",
"quantity": 3,
"price": 50.00,
"subTotal": 150.00
}
]
}
Response:
{
"orderId": "order-123",
"status": "PENDING",
"message": "Order created successfully."
}
For detailed API documentation, refer to the API Documentation.
By utilizing the Outbox pattern, we ensure that message delivery between microservices is reliable and consistent, maintaining data integrity across services.
Domain Layer
Application Layer
Data Access Layer
Messaging
API Layer
We welcome contributions! To contribute:
Fork the Project
git clone https://github.com/your-username/FoodOrderingSystem.git
Create a Feature Branch
git checkout -b feature/YourFeatureName
Commit Your Changes
git commit -m "Add YourFeatureName"
Push to the Branch
git push origin feature/YourFeatureName
Open a Pull Request
Submit your pull request, and we will review it as soon as possible.
This project is licensed under the MIT License. See the LICENSE file for details.
Emir SoGood
Project Link: FoodOrderingSystem