Skip to content

Latest commit

 

History

History
92 lines (69 loc) · 4.18 KB

File metadata and controls

92 lines (69 loc) · 4.18 KB

Functionalities of the Distributed Bookstore Application

1. User Service

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.

2. Book Inventory Service

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.

3. Order Service

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.

Inter-Service Communication

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:

  1. User Registration: A user registers through the User Service.
  2. Book Browsing: The user browses available books using the Book Inventory Service.
  3. 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.
  4. Order Status: The user can check the status of their order through the Order Service.

Implementation Steps

  1. 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.
  2. 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.
  3. Set Up Communication:

    • Ensure that services can communicate with each other using gRPC.
    • Implement gRPC clients within each service to interact with other services.
  4. Containerization:

    • Create Dockerfiles for each service.
    • Build Docker images and run the services in separate containers.
  5. Client Application:

    • Develop a client application to interact with the services, enabling users to register, browse books, and place orders.
  6. Testing:

    • Test each service independently.
    • Perform integration testing to ensure that all services work together seamlessly.