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.
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
Controllers (high level)
-
AuthController (
/api/auth)- POST
/register— Register new CUSTOMER - POST
/login— Login and receive JWT tokens
- POST
-
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)
- GET
-
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
- GET
-
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
- GET
-
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
- POST
-
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
- GET
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
entityanddtopackages - Enum
Roledefines 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:
OmsApplicationTestsunderoms/src/test/java
-
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
Prerequisites:
- Java JDK 11+ (or project-specific Java version)
- Maven or Gradle (check for
pom.xmlorbuild.gradleinoms/) - 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
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.