Skip to content

AnthonyQ98/pcbook_grpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PCBook - gRPC Laptop Store Service

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.

Features

  • 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

Prerequisites

  • Go 1.23.4 or later
  • Protocol Buffer Compiler (protoc)
  • Make (for running commands)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd pcbook
  2. Generate protocol buffer code:

    make gen
  3. Generate TLS certificates (optional, for secure communication):

    make cert

Usage

Starting the Server

Start the gRPC server:

make server

Start the REST server:

make rest

For TLS-enabled servers:

make server1-tls

Running the Client

Connect to the server:

make client

For TLS-enabled connection:

make client-tls

Development

Available Make Commands

  • make gen: Generate protocol buffer code
  • make clean: Clean generated protobuf files
  • make server: Start the gRPC server
  • make rest: Start the REST server
  • make client: Run the client
  • make test: Run tests
  • make cert: Generate TLS certificates

Project Structure

  • /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

Security

The service implements several security features:

  • JWT-based authentication
  • Role-based access control
  • TLS encryption (optional)
  • Client-server certificate verification

Testing

Run the test suite:

make test

Dependencies

  • 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

License

[Add your license information here]

About

A modern gRPC-based laptop store service with REST API gateway, JWT authentication, and TLS support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors