https://github.com/datarohit/order-management-system
https://github.com/datarohit/order-management-system
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/datarohit/order-management-system
- Owner: DataRohit
- License: mit
- Created: 2025-02-02T05:31:02.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-02T09:25:56.000Z (over 1 year ago)
- Last Synced: 2025-02-02T10:25:07.602Z (over 1 year ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Order Management System ππ
## Project Overview π
This Order Management System is a microservices-based application βοΈ designed to streamline e-commerce operations. It focuses on efficiently managing products π¦, inventory Stockπ, orders ποΈ, and payments π³. The system is built with user authentication π, supporting both vendor π§βπΌ and customer π§βπ§βπ€βπ§ roles. It leverages asynchronous task processing β±οΈ for improved performance and scalability βοΈ. Designed to be cloud-native π, it utilizes Docker π³ for containerization and Consul π§ for service discovery.
## Services π§©
The system is composed of distinct microservices, each handling a specific domain:
* **Gateway Service πͺ**:
* Serves as the single entry point for all external API requests π¦.
* Manages HTTP routing using Gin π€οΈ.
* Enforces authentication and authorization via middleware π‘οΈ.
* Implements rate limiting using Redis to ensure API stability β³.
* Provides comprehensive API documentation with Swagger π.
* Communicates with backend services using gRPC π£οΈ.
* **Auth Service π‘οΈ**:
* Handles all aspects of user authentication and authorization π.
* Manages user registration π, login β
, logout πͺ, and secure password management (resetting and forgotten passwords π).
* Generates and rigorously verifies JWT tokens for both access and refresh tokens ποΈ.
* Manages distinct user roles: customer and vendor π§βπΌπ§βπ§βπ€βπ§.
* Persistently stores user data in MongoDB πΎ.
* Publishes critical user-related events to RabbitMQ for asynchronous processing (e.g., user registration, account activation, password resets βοΈ).
* **Product Service π¦**:
* Manages the entire product catalog and detailed product information βΉοΈ.
* Empowers vendors to create β, update βοΈ, delete ποΈ, and list products π.
* Stores all product-related information in MongoDB πΎ.
* Dispatches product-related events via RabbitMQ (e.g., product creation, updates, deletions π’).
* **Inventory Service Stockπ**:
* Precisely manages product inventory levels π.
* Enables vendors to efficiently create β, update βοΈ, delete ποΈ, and retrieve inventory details for their products π¦.
* Stores inventory data securely in MongoDB πΎ.
* **Order Service ποΈ**:
* Oversees the complete order lifecycle: creation β, retrieval π, and cancellation β.
* Calculates order totals accurately and manages order statuses effectively π.
* Stores comprehensive order information in MongoDB πΎ.
* Broadcasts order-related events using RabbitMQ (e.g., order creation, cancellation, successful payments π’).
* **Payment Service π³**:
* Facilitates secure payment processing using Stripe π°.
* Generates unique payment links for each order π.
* Processes real-time webhook events from Stripe for immediate payment confirmations and notifications of failures π.
* Interacts with Auth, Product, and Order services via high-performance gRPC π£οΈ.
* Subscribes to relevant order and product events from RabbitMQ to orchestrate payment workflows and maintain data synchronization with Stripe π.
* Sends timely email notifications for order confirmations and cancellations through the Mailer service βοΈ.
* **Mailer Service βοΈ**:
* Dedicated to sending emails for crucial events: user registration, account activation, password resets, and order confirmations π§.
* Utilizes Mailpit for efficient local email testing and SMTP for reliable real email delivery π§ͺβ‘οΈπ€.
* Subscribes to user-related events from RabbitMQ to trigger automated email sending processes π¬.
## Functionalities β¨
The Order Management System is packed with features, including:
* **User Authentication and Authorization π**:
* Streamlined user registration and secure account activation via email verification π§β
.
* Secure user login and logout with JWT-based authentication ππͺ.
* Role-Based Access Control (RBAC) to manage permissions for customers and vendors π§βπΌπ§βπ§βπ€βπ§.
* Password recovery and reset functionalities for account security π.
* Refresh token mechanism for seamless access token renewal and persistent sessions π.
* **Product Management π¦**:
* Vendors can easily add new products with comprehensive details: name, description, category, and price β.
* Vendors have full control to update and remove their listed products βοΈποΈ.
* Vendors can efficiently list and manage their product offerings with pagination support πβ‘οΈ.
* **Inventory Management Stockπ**:
* Vendors can precisely control inventory levels, setting available and threshold quantities for each product π.
* Real-time inventory updates triggered by order placements and cancellations ensure accuracy π.
* **Order Management ποΈ**:
* Customers can create orders with multiple items, potentially from various vendors, in a single transaction π.
* Orders are initiated in a "pending" status and transition to "paid" upon successful payment processing β³β‘οΈβ
.
* Customers can conveniently view their order details and cancel orders that are still pending πβ.
* Unique payment links are dynamically generated for each order using Stripe for secure checkout ππ³.
* Real-time webhook handling for Stripe payment events ensures immediate order status updates and accurate records ππ.
* **Payment Processing π³**:
* Seamless integration with Stripe for secure and reliable payment processing π€π°.
* Automated generation of Stripe Payment Links simplifies the checkout process for customers π.
* Robust handling of Stripe webhook events keeps order statuses synchronized with payment events ππ.
* Supports order cancellations and efficient payment refunds when necessary ββ©οΈ.
* **Email Services βοΈ**:
* Automated email notifications for user registration and account activation guide new users π§β
.
* Password reset email functionality ensures users can recover access to their accounts securely π§π.
* Order confirmation and cancellation emails keep customers informed about their transactions π§ποΈβ.
* **Monitoring and Tracing π**:
* Distributed tracing with Jaeger provides deep insights into request flows across all services, aiding in monitoring and debugging π.
* Centralized logging across all services using Logrus for efficient issue tracking and system analysis πͺ΅.
* Health check endpoints for every service enable proactive monitoring and ensure system health π©Ί.
* **Service Discovery and Configuration π§**:
* Consul facilitates dynamic service registration and discovery, enabling services to locate and communicate with each other automatically ππ£οΈ.
* Environment variable-based configuration ensures flexibility and easy deployment across different environments βοΈ.
* **API Security and Rate Limiting π‘οΈβ³**:
* JWT-based authentication secures all API endpoints, protecting against unauthorized access π.
* Rate limiting middleware in the Gateway service safeguards against abuse and ensures fair usage π¦.
* **API Documentation π**:
* Swagger documentation for the Gateway API provides interactive, up-to-date API exploration and integration resources for developers π.
## Docker Setup π³
To run the Order Management System using Docker Compose, ensure you have Docker and Docker Compose installed on your machine.
1. **Clone the repository:**
```bash
git clone
cd
```
2. **Environment Variables:**
* Ensure you have configured all necessary environment variables. Example `.env` files are provided in each service directory (e.g., `.envs/auth/.env.example`).
* Copy `.env.example` files to `.env` and modify the values as needed for your setup.
* Pay special attention to database connection strings, RabbitMQ and Redis URIs, Stripe secrets, and JWT secrets.
3. **Start the services with Docker Compose:**
```bash
docker-compose up --build -d
```
This command builds all the Docker images and starts all services in detached mode.
4. **Access the applications:**
* **Gateway Service & Swagger UI**: `http://localhost:8080/api/v1/swagger/index.html`
* **Mailpit UI**: `http://localhost:8025`
* **RabbitMQ Management UI**: `http://localhost:15672` (default credentials are `guest:guest`)
* **Jaeger UI**: `http://localhost:16686`
* **Consul UI**: `http://localhost:8500`
* **mongo-express UI**: `http://localhost:8081`
5. **Stop the services:**
```bash
docker-compose down
```
## Tech Stack π οΈ
* **Backend Services**: Go
* **API Gateway Framework**: Gin
* **Inter-service Communication**: gRPC
* **Message Broker**: RabbitMQ
* **In-memory Data Store**: Redis
* **Database**: MongoDB
* **Payment Processing**: Stripe
* **Service Discovery**: Consul
* **Distributed Tracing**: Jaeger
* **Email Testing**: Mailpit
* **Containerization**: Docker
## License & Contributing ππ§βπ€βπ§
### License π
This project is licensed under the MIT License - see the [LICENSE](license) file for details.
### Contributing π§βπ€βπ§
Contributions are welcome! Please feel free to submit pull requests, report issues, or suggest new features to improve Gopher Social Backend.