Skip to content

This microservices-based Order Management System streamlines e-commerce by managing products, inventory, orders, and payments. It supports vendor and customer authentication, asynchronous task processing for scalability, and cloud-native deployment using Docker and Consul for service discovery.

License

Notifications You must be signed in to change notification settings

DataRohit/Order-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ae26247 Β· Feb 25, 2025

History

75 Commits
Feb 25, 2025
Feb 25, 2025
Feb 25, 2025
Feb 24, 2025
Feb 25, 2025
Feb 23, 2025
Feb 23, 2025
Feb 25, 2025
Feb 25, 2025
Feb 24, 2025
Feb 12, 2025
Feb 24, 2025
Feb 12, 2025
Feb 24, 2025
Feb 25, 2025

Repository files navigation

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:

    git clone <repository_url>
    cd <repository_directory>
  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:

    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:

    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 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.

About

This microservices-based Order Management System streamlines e-commerce by managing products, inventory, orders, and payments. It supports vendor and customer authentication, asynchronous task processing for scalability, and cloud-native deployment using Docker and Consul for service discovery.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published