Request flows
1. User Registration Flow
Objective: A new user registers on the platform.
- User Action:
- The user submits a registration form with email, password, and other details.
- API Gateway:
- Routes the request to the Authentication Service.
- Authentication Service:
- Validates the input (e.g., checks email format, password strength).
- Hashes the password (e.g., using bcrypt).
- Stores user details in the User Database.
- Generates a confirmation token for email verification.
- Notification Service:
- Sends a verification email with the confirmation token.
- Response:
- Returns a success response, prompting the user to verify their email.
2. User Login Flow
Objective: A user logs in to access the system.
- User Action:
- The user submits login credentials.
- API Gateway:
- Routes the request to the Authentication Service.
- Authentication Service:
- Verifies the credentials against the User Database.
- Generates a JWT or session token upon successful validation.
- Response:
- Returns the token to the client for subsequent authenticated requests.
3. Restaurant Search and Browsing Flow
Objective: A user searches for restaurants or browses menus.
- User Action:
- The user enters search terms or selects filters (e.g., cuisine, location).
- API Gateway:
- Routes the request to the Search and Recommendation Service.
- Search and Recommendation Service:
- Queries the Restaurant Database or Search Index (e.g., Elasticsearch).
- Applies filters and ranking algorithms (e.g., ratings, proximity).
- Response:
- Returns a list of matching restaurants to the client.
4. Placing an Order
Objective: A user places a new order.
- User Action:
- The user selects menu items, customizes them, and proceeds to checkout.
- API Gateway:
- Routes the request to the Order Management Service.
- Order Management Service:
- Validates the order details (e.g., item availability, restaurant status).
- Calculates the total cost, including taxes and delivery fees.
- Stores the order details in the Order Database with an initial status of "Pending."
- Payment Service:
- Processes the payment using a payment gateway.
- Updates the order status to "Confirmed" upon successful payment.
- Notification Service:
- Sends order confirmation to the user and the restaurant.
- Response:
- Returns the order confirmation details to the client.
5. Real-Time Order Tracking
Objective: A user tracks their order status.
- User Action:
- The user opens the order tracking screen.
- API Gateway:
- Routes the request to the Order Management Service.
- Order Management Service:
- Fetches the current status of the order from the Order Database.
- Fetches real-time driver location from the Real-Time Tracking Service (if the order is out for delivery).
- Real-Time Tracking Service:
- Queries the location of the assigned driver from a NoSQL Database (e.g., Redis).
- Response:
- Returns the order status and live driver location to the client.
6. Driver Order Acceptance
Objective: A driver accepts a delivery order.
- System Action:
- The system assigns an order to a nearby driver using the Delivery Service.
- Driver Action:
- The driver receives a notification for a new order.
- The driver accepts the order in their app.
- API Gateway:
- Routes the acceptance request to the Delivery Service.
- Delivery Service:
- Updates the order status to "Accepted by Driver" in the Order Database.
- Notification Service:
- Notifies the user that a driver has been assigned.
7. Payment Processing
Objective: Process payment for an order.
- User Action:
- The user provides payment details during checkout.
- API Gateway:
- Routes the request to the Payment Service.
- Payment Service:
- Validates payment details.
- Initiates the transaction with a payment gateway (e.g., Stripe, PayPal).
- Updates the Payment Database with the transaction details.
- Order Management Service:
- Updates the order status to "Paid" upon successful payment.
- Response:
- Returns the payment confirmation to the client.
8. Ratings and Reviews Submission
Objective: A user submits a review for a restaurant or driver.
- User Action:
- The user rates the restaurant/driver and writes a review.
- API Gateway:
- Routes the request to the Review Service.
- Review Service:
- Validates the input and stores the review in the Restaurant Database or Driver Database.
- Response:
- Returns a confirmation message to the client.
9. Real-Time Notifications
Objective: Notify users of order updates.
- System Action:
- An order status update occurs (e.g., "Out for Delivery").
- Notification Service:
- Triggers a real-time notification to the user.
- Uses WebSocket or push notifications (e.g., Firebase Cloud Messaging).
- Response:
- The user receives the notification instantly on their device.
10. Admin Panel Actions
Objective: An administrator performs actions (e.g., managing users or restaurants).
- Admin Action:
- The admin logs into the panel and performs actions like suspending a user or updating restaurant details.
- API Gateway:
- Routes requests to the appropriate service (e.g., User Management Service, Restaurant Management Service).
- Relevant Service:
- Validates the admin’s permissions.
- Executes the requested action and updates the respective database.
- Response:
- Returns success/failure messages and updated records to the admin panel.