How hnam161098/booking works
Project Type and Purpose
• This is a microservices-based full-stack Golang application.
• It consists of two independent services (customer and booking), each with its own client and server.
• Communication uses gRPC for service calls; Gin is used in the client for routing; MongoDB and Elasticsearch back the data layer.
File-Structure Analysis
• Top-level directories:
• server – two independent services: server/customer and server/booking
• client – corresponding clients: client/customer and client/booking
• database_connection – MongoDB and Elasticsearch connectors
• config – global configuration loader
• helpers – shared utility functions (errors, types, ES helper)
• protoc + pb – .proto definitions and generated Go interfaces
• Naming convention follows “service-centric” grouping (controller, handler, models, testing).
• Each service has its own main.go, tests, mocks, and model definitions.
README Insights
• Confirms microservice design: independent customer and booking services that do not block each other on failure.
• Tech stack: Go, MongoDB, Elasticsearch, gRPC, Gin.
• Code-generation step using protoc for .proto → pb Go files.
Main Components
a. Clients:
• Booking Client (Gin router → gRPC stubs)
• Customer Client (Gin router → gRPC stubs)
b. Servers (microservices):
• Booking Service (gRPC server, handlers, controllers, DB managers)
• Customer Service (gRPC server, handlers, controllers, DB managers)
c. Databases:
• MongoDB instance
• Elasticsearch cluster
d. Shared Libraries/Utilities:
• config service loader
• database_connection layer
• helpers package
e. Code-gen pipeline: protoc → pb interfaces
f. External Tools: grpcui for runtime testing
Interactions & Data Flows
• Client → gRPC stub call → corresponding server endpoint
• Server handler → controller → dbmanager → database_connection (MongoDB or ES) → return to client
• Optional service-to-service calls (e.g., Booking Service querying Customer Service) via gRPC
• Config and Helpers are loaded at startup by both clients and servers
Architectural Patterns & Principles
• Microservices: two separately deployable processes
• Layered architecture within each service: Handler → Controller → Model/DB manager
• API contract via Protocol Buffers (strongly typed, cross-service)
• Dependency injection through config and database_connection modules
• Resilience: isolation ensures one service crash does not affect the other
Detailed Components to Capture
• client/customer/app & client/booking/app: Gin router & route definitions
• pb interfaces: booking.pb.go, customer.pb.go
• server/.../handler: business logic entry points
• server/.../controller: mapping between requests and models
• database_connection: elasticsearch.go, mongodb.go
• helpers: error handling and shared types
• protoc folder: .proto definitions driving contract