- Overview
- Features
- Architecture
- Technologies Used
- Project Structure
- Installation and Setup
- Usage
- Data Flow
- Development Guidelines
- Contributing
- License
- Contact
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.
- Order Management: Place, track, and manage food orders.
- Payment Processing: Secure and reliable payment transactions.
- Restaurant Interface: Restaurants can approve or reject orders.
- Customer Profiles: Manage customer information and order history.
- Real-Time Notifications: Updates via Apache Kafka messaging.
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.
- Domain Layer: Contains business logic and domain entities.
- Application Layer: Coordinates application activities and use cases.
- Infrastructure Layer: Deals with external systems like databases and messaging.
- Programming Language: Java 17
- Frameworks and Libraries:
- Spring Boot
- Spring Data JPA
- Messaging and Streaming: Apache Kafka
- Database: PostgreSQL
- Containerization: Docker
- Build Tool: Maven
The project is modularized, reflecting its microservices architecture:
common: Shared utilities and code across microservices.infrastructure: Infrastructure components like Kafka configurations.
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.container: Spring Boot application entry point.
- Java Development Kit (JDK) 17
- Maven
- Docker & Docker Compose
-
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:
- Order Service
- Create Order:
POST /orders - Get Order Details:
GET /orders/{orderId} - Update Order:
PUT /orders/{orderId} - Delete Order:
DELETE /orders/{orderId}
- Create Order:
- Payment Service
- Process Payment:
POST /payments
- Process Payment:
- Restaurant Service
- Approve Order:
POST /restaurants/{restaurantId}/orders/{orderId}/approve - Reject Order:
POST /restaurants/{restaurantId}/orders/{orderId}/reject
- Approve Order:
- Customer Service
- Register Customer:
POST /customers - Get Customer Info:
GET /customers/{customerId}
- Register Customer:
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.
- Order Placement: Customer places an order via the Order Service.
- Payment Initiation: Order Service sends order details to the Payment Service.
- Payment Confirmation: Payment Service processes payment and notifies the Order Service.
- Order Approval: Order is forwarded to the Restaurant Service for approval.
- Notification: Customer receives updates on the order status.
-
Domain Layer
- Define new entities or value objects.
- Implement business logic and rules.
-
Application Layer
- Create or update application services.
- Define use cases.
-
Data Access Layer
- Add or modify repository interfaces.
- Implement data access logic.
-
Messaging
- Update Kafka producers and consumers.
- Define new topics if necessary.
-
API Layer
- Update controllers.
- Define new endpoints.
- Unit Tests: Use JUnit and Mockito.
- Integration Tests: Use Testcontainers for databases and Kafka.
- End-to-End Tests: Validate the complete workflow.
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
- GitHub: @sogutemir
- Email: sogutemir72@gmail.com
Project Link: FoodOrderingSystem