Responsibilities: Manage user accounts and authentication.
Functionalities:
- User Registration: Allow new users to create accounts. Collect and store user information such as name, email, and password.
- User Authentication: Verify user credentials during login. This involves checking the username and password against stored records.
- User Management: Enable users to update their details, reset passwords, and delete their accounts.
Endpoints:
CreateUser(UserRequest): Registers a new user.GetUser(UserIDRequest): Retrieves user details based on user ID.UpdateUser(UserUpdateRequest): Updates user information.AuthenticateUser(UserAuthRequest): Authenticates a user based on credentials.
Responsibilities: Manage the book catalog and availability.
Functionalities:
- Add/Update Book: Add new books to the inventory or update details of existing books (title, author, price, stock).
- Check Book Availability: Check if a book is in stock and available for purchase.
- Get Book Details: Retrieve information about a specific book.
Endpoints:
AddBook(BookRequest): Adds a new book to the inventory.UpdateBook(BookUpdateRequest): Updates details of an existing book.CheckAvailability(BookIDRequest): Checks the availability of a book.GetBookDetails(BookIDRequest): Retrieves detailed information about a book.
Responsibilities: Handle book orders and transactions.
Functionalities:
- Place Order: Create an order for books, including user details and book information.
- Update Order Status: Update the status of an order (e.g., pending, shipped, completed).
- Process Payment: Simulate or integrate with a payment gateway to handle transactions.
- Order History: Retrieve a user’s order history.
Endpoints:
PlaceOrder(OrderRequest): Places a new order.UpdateOrderStatus(OrderStatusUpdateRequest): Updates the status of an existing order.GetOrderStatus(OrderIDRequest): Retrieves the current status of an order.GetOrderHistory(UserIDRequest): Retrieves a user's order history.
Service Dependencies:
- Order Service: Communicates with Book Inventory Service to check book availability and update stock when an order is placed.
- User Service: Optionally communicates with Order Service to authenticate users before processing orders.
Example Flow:
- User Registration: A user registers through the User Service.
- Book Browsing: The user browses available books using the Book Inventory Service.
- Order Placement: The user places an order through the Order Service.
- Order Service checks book availability with the Book Inventory Service.
- If the book is available, Order Service processes the order and updates the book stock.
- Order Status: The user can check the status of their order through the Order Service.
-
Define Protobuf Files:
- Create Protobuf messages for user data, book details, and orders.
- Define the gRPC services for user management, book inventory, and order processing.
-
Implement Services:
- User Service: Implement user registration, authentication, and management.
- Book Inventory Service: Implement book addition, updating, and availability checks.
- Order Service: Implement order placement, status updates, and history retrieval.
-
Set Up Communication:
- Ensure that services can communicate with each other using gRPC.
- Implement gRPC clients within each service to interact with other services.
-
Containerization:
- Create Dockerfiles for each service.
- Build Docker images and run the services in separate containers.
-
Client Application:
- Develop a client application to interact with the services, enabling users to register, browse books, and place orders.
-
Testing:
- Test each service independently.
- Perform integration testing to ensure that all services work together seamlessly.