A modern gRPC-based laptop store service that demonstrates the implementation of various features including authentication, REST API gateway, TLS security, and more. The service allows users to manage laptop inventory, upload images, and rate laptops.
- gRPC and REST Support: Dual protocol support with automatic REST API gateway
- Authentication: JWT-based authentication with role-based access control
- TLS Security: Optional TLS encryption for secure communication
- Image Upload: Support for laptop image uploads
- Rating System: User-based laptop rating functionality
- In-Memory Storage: Efficient in-memory storage implementation
- Protobuf: Modern protocol buffer definitions for service interfaces
- Go 1.23.4 or later
- Protocol Buffer Compiler (protoc)
- Make (for running commands)
-
Clone the repository:
git clone <repository-url> cd pcbook
-
Generate protocol buffer code:
make gen
-
Generate TLS certificates (optional, for secure communication):
make cert
Start the gRPC server:
make serverStart the REST server:
make restFor TLS-enabled servers:
make server1-tlsConnect to the server:
make clientFor TLS-enabled connection:
make client-tlsmake gen: Generate protocol buffer codemake clean: Clean generated protobuf filesmake server: Start the gRPC servermake rest: Start the REST servermake client: Run the clientmake test: Run testsmake cert: Generate TLS certificates
/proto: Protocol buffer definitions/pb: Generated protocol buffer code/service: Core service implementations/cmd: Command-line applications/client: Client implementation/img: Image storage directory/openapiv2: OpenAPI v2 specifications
The service implements several security features:
- JWT-based authentication
- Role-based access control
- TLS encryption (optional)
- Client-server certificate verification
Run the test suite:
make test- github.com/grpc-ecosystem/grpc-gateway/v2
- google.golang.org/grpc
- github.com/dgrijalva/jwt-go
- github.com/google/uuid
- github.com/jinzhu/copier
- github.com/stretchr/testify
[Add your license information here]