Welcome to the Laptop-Lounge-Microservice project! This repository contains a microservices-based e-commerce platform specializing in laptop sales. The project is built using Go (Golang) and leverages gRPC for inter-service communication.
- Introduction
- Architecture Overview
- Directory Structure
- Prerequisites
- Installation
- Running the Services
- API Documentation
- Contributing
- License
Laptop-Lounge-Microservice is an e-commerce platform designed with a microservices architecture to ensure scalability, maintainability, and ease of deployment. Each service is responsible for a specific domain within the application, promoting a separation of concerns.
The application consists of the following microservices:
- API Gateway: Acts as the entry point for all client requests, routing them to the appropriate services.
- Admin Service: Handles administrative tasks such as product management and order oversight.
- Customer Service: Manages user authentication, profiles, and customer-related data.
- Product Service: Oversees the product catalog, inventory management, and product details.
- Cart Service: Manages shopping cart functionalities for users.
- Order Service: Processes orders, payments, and maintains order histories.
These services communicate via gRPC and are built using clean architecture principles. The project also includes Protocol Buffer definitions (.proto
files) for defining service interfaces.
Laptop-Lounge-Microservice/
├── Admin-Service/
├── API-Gateway/
├── Cart-Service/
├── Customer-Service/
├── Order-Service/
└── Product-Service/
Each service directory follows a similar structure:
- cmd/: Entry point of the service (
main.go
). - pkg/: Contains the core packages, including API handlers, configurations, database connections, dependency injection, domain models, and more.
- pb/: Protocol Buffers generated code and
.proto
files. - .env: Environment variables specific to the service.
- go.mod & go.sum: Go module files for dependency management.
Before running the application, ensure you have the following installed:
- Go: Version 1.16 or higher.
- Protocol Buffers Compiler (protoc): For compiling
.proto
files. - Docker: For containerization (optional but recommended).
- Make: For using the provided
Makefile
scripts (if available).
-
Clone the repository:
git clone https://github.com/ShahabazSulthan/Laptop_Lounge_Microservice.git cd Laptop-Lounge-Microservice
-
Set up environment variables:
- Copy the
.env
file in each service directory and configure them as needed. - Ensure database URLs, ports, and other configurations are correctly set.
- Copy the
-
Install dependencies:
Navigate to each service directory and run:
go mod download
If you prefer containerization, you can use Docker Compose to run all services simultaneously.
-
Build and run the containers:
docker-compose up --build
-
Verify that all services are running:
Access the logs to ensure each service has started without errors.
To run the services locally without Docker:
-
Compile Protocol Buffers:
Navigate to the
pb/
directory of each service and run:protoc --go_out=. --go-grpc_out=. *.proto
-
Run each service:
Open separate terminal windows for each service and run:
go run cmd/main.go
Ensure that ports used by each service do not conflict.
API endpoints and their usage are documented using Swagger (or any other API documentation tool you prefer). To access the API documentation:
-
Run the API Gateway:
Ensure the API Gateway service is running.
We welcome contributions! If you'd like to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of your changes.
Please ensure your code adheres to the existing code style and include appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to explore the codebase, open issues, and contribute to making Laptop-Lounge-Microservice a robust e-commerce platform!
For any questions or support, please contact [[email protected]]