This project involves the development of an online SUSTech Merch Store, where exactly 3 products are available for sale. The store is accessible via a RESTful API Service, which interacts with gRPC microservices for database operations and logging. The system is designed to handle user registration, product browsing, and order placement, with all data stored in a PostgreSQL database. The project also includes a centralized logging service using Kafka for monitoring purposes.
The system architecture consists of the following components:
- RESTful API Service: Handles external customer requests, including product browsing, user management, and order placement.
- gRPC DB Service: Manages database operations, including CRUD operations for products, users, and orders. It maintains a connection pool to optimize database access.
- gRPC Logging Service: Collects logs from the API and DB services and publishes them to a Kafka topic for monitoring.
- PostgreSQL Database: Stores product, user, and order information.
- Kafka: Used for centralized logging and monitoring.
All components are deployed using Docker Compose.
- Implement the following APIs:
- Greeting API: Returns a welcome message.
- Product APIs:
list-products
,get-product
. - User APIs:
register
,deactivate-user
,get-user
,update-user
,login
. - Order APIs:
place-order
,cancel-order
,get-order
.
- Define the APIs in an OpenAPI specification YAML file.
- Implement JWT-based authentication for user-specific APIs.
- Implement CRUD operations for products, users, and orders.
- Define the RPCs in a Proto file.
- Implement a client-side streaming RPC to collect log messages.
- Define the RPCs in a Proto file.
- Update the provided Docker Compose file to include all services and ensure they can communicate with each other.
- API/RPC Definitions: Ensure reasonable API/RPC definitions (e.g.,
get-user
should not return sensitive information like passwords). - Authentication: Implement JWT-based authentication for user-specific APIs.
- Data Types: Ensure consistent field data types across the OpenAPI specification, Proto files, and database schema.
- Error Handling: Implement gRPC error handling with appropriate status codes and detail messages.
- Code Style: Adhere to standard style guidelines and include comments where necessary.
The report should answer the following questions:
- Implementation Procedures: Explain the setup, code generation, and business logic implementation for each component.
- Authentication: Identify which APIs require authentication and describe the authentication logic.
- Data Types: Explain how you selected field data types for different definitions.
- Protobuf Encoding: Analyze how a Proto message is encoded into binary format and verify the result programmatically.
- Logging Service: Explain how the server-side streaming RPC works.
- Docker Configuration: Describe how Docker and Docker Compose are configured to enable communication between services.
- Testing: Explain how you tested the API Service (e.g., using cURL, Postman, Swagger UI) and monitored log messages from the Kafka topic.