Skip to content

Navi2510/Order-Management-System-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

OMS (Order Management System) — Backend module

This README documents the features implemented in the oms module of the repository Navi2510/Order-Management-System-Backend. It summarizes controllers, endpoints, services, and other core functionality found in oms/src/main/java/com/navneet/oms. Payment-related features are intentionally omitted.

Overview

The oms module is a Spring Boot-based Java backend that implements an order management system with:

  • Authentication (JWT)
  • Role-based authorization (ADMIN, CUSTOMER)
  • User management
  • Product management (catalog)
  • Inventory management (admin operations)
  • Order management (place orders, view orders, admin order queries)
  • Reporting (sales, top products, order summaries, user activity)
  • Typical layered architecture: controllers, services, repositories, entities, DTOs

Main components & features

Controllers (high level)

  • AuthController (/api/auth)

    • POST /register — Register new CUSTOMER
    • POST /login — Login and receive JWT tokens
  • UserController (/api/users)

    • GET /profile — Get logged-in user's profile
    • PUT /profile — Update logged-in user's profile (name)
    • GET / — Get all users (ADMIN)
    • PUT /{id}/activate — Activate / deactivate a user (ADMIN)
  • ProductController (/api/products)

    • GET / — Get all active products
    • GET /{id} — Get an active product by id
    • GET /search — Search & filter products (via ProductSearchRequest)
    • DELETE /{id} — Soft-delete a product (ADMIN)
    • Endpoints support both Admin and Customer usage depending on the action
  • InventoryController (/api/inventory) — ADMIN only

    • GET / — Get inventory for all products
    • GET /{productId} — Get inventory by product id
    • PUT /{productId}/add?quantity= — Add stock for a product
  • OrderController (/api/orders)

    • POST / — Place order from cart (requires role CUSTOMER)
    • GET /{orderId} — Get order details by order id (CUSTOMER)
    • GET /admin/status/{status} — Get orders by status (ADMIN)
    • Uses OrderService for core order lifecycle and mapping to OrderResponse
  • ReportController (/api/reports) — ADMIN only

    • GET /sales?from=<>&to=<> — Total sales between date range
    • GET /top-products — Best selling / top products
    • GET /orders-summary — Order count grouped by status
    • GET /users — User activity / user report

Services

  • AuthService — register and login logic, JWT issuance
  • OrderService — handles order placement, lifecycle, transaction management, and mapping to DTOs (OrderResponse, OrderItemResponse)
  • ProductService — product retrieval, search, create/update/delete
  • InventoryService — inventory queries and stock adjustments
  • Additional services for user management, reporting, etc.

Persistence & Data

  • Repositories (Spring Data JPA interfaces) exist for Users, Orders, OrderItems, Products, Inventory
  • Entities / DTOs present under entity and dto packages
  • Enum Role defines roles: ADMIN, CUSTOMER

Security

  • Role-based access control using Spring Security annotations (@PreAuthorize)
  • Role enum supports ADMIN and CUSTOMER
  • Controllers indicate role restrictions on admin-only routes

Utilities

  • OrderNumberGenerator — utility used to create order numbers
  • DTO mapper logic in services (e.g., converting Order -> OrderResponse with item subtotals)

Testing

  • Basic Spring Boot context test exists: OmsApplicationTests under oms/src/test/java

Endpoints summary (quick reference)

  • Auth

    • POST /api/auth/register
    • POST /api/auth/login
  • Users

    • GET /api/users/profile
    • PUT /api/users/profile
    • GET /api/users (ADMIN)
    • PUT /api/users/{id}/activate (ADMIN)
  • Products

    • GET /api/products
    • GET /api/products/{id}
    • GET /api/products/search
    • DELETE /api/products/{id} (ADMIN)
  • Inventory (ADMIN)

    • GET /api/inventory
    • GET /api/inventory/{productId}
    • PUT /api/inventory/{productId}/add?quantity={n}
  • Orders

    • POST /api/orders (place order — requires CUSTOMER role)
    • GET /api/orders/{orderId} (CUSTOMER)
    • GET /api/orders/admin/status/{status} (ADMIN)
  • Reports (ADMIN)

    • GET /api/reports/sales?from={datetime}&to={datetime}
    • GET /api/reports/top-products
    • GET /api/reports/orders-summary
    • GET /api/reports/users

Build & run (module-specific)

Prerequisites:

  • Java JDK 11+ (or project-specific Java version)
  • Maven or Gradle (check for pom.xml or build.gradle in oms/)
  • Database (Postgres, MySQL, or H2 in-memory for dev)
  • Optional: Docker for local DB

Typical commands (from repository root or oms/ directory):

  • Maven
    • mvn clean package
    • mvn spring-boot:run
    • java -jar oms/target/-.jar
  • Gradle
    • ./gradlew :oms:build
    • ./gradlew :oms:bootRun
    • java -jar oms/build/libs/-.jar

Configuration

Application properties likely found in:

  • oms/src/main/resources/application.properties
  • or oms/src/main/resources/application.yml

Common properties to set:

  • spring.datasource.url / DB_URL
  • spring.datasource.username / DB_USERNAME
  • spring.datasource.password / DB_PASSWORD
  • server.port / PORT
  • spring.profiles.active (dev/test/prod)

Secrets should be supplied via environment variables or a secrets manager, not committed to the repo.

About

Order Management system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages