Skip to content

About

Handles order creation and communicates with other services.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ… Prerequisites

Before running this project, make sure you have installed:

  • Java 21 or higher
  • Maven 3.9+ (or use the included Maven Wrapper mvnw)
  • Docker Desktop (for PostgreSQL and RabbitMQ)
  • Git
  • An IDE such as IntelliJ IDEA (recommended)

πŸš€ Setup and Installation

1. Clone the Repository

git clone https://github.com/CSCI44092GroupProject/order-service.git
cd order-service

2. Create the .env File

Copy the template and fill in your local values:

cp .env.example .env

Contents of .env:

# Local PostgreSQL (Docker)
DB_HOST=localhost
DB_PORT=5432
DB_NAME=order_db
DB_USERNAME=order_user
DB_PASSWORD=change_me

# RabbitMQ (Docker)
RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USERNAME=rabbitmq_user
RABBITMQ_PASSWORD=rabbitmq_password

3. Start Docker Containers

Start PostgreSQL and RabbitMQ:

docker compose up -d

Verify both containers are running:

docker ps

You should see order-postgres and order-rabbitmq in the output.

πŸƒ Running the Application

Option 1 β€” From IntelliJ

  1. Open the project in IntelliJ IDEA
  2. Right-click OrderServiceApplication.java
  3. Click Run 'OrderServiceApplication'

Option 2 β€” From Terminal

./mvnw spring-boot:run

The application will start on http://localhost:8080.

πŸ“– API Documentation

Once the application is running, access the interactive API documentation:

Example Request

POST /api/orders

{
  "customerId": "CUST-1001",
  "items": [
    {
      "productId": 3,
      "quantity": 2
    }
  ]
}

Example Response (201 Created)

{
  "orderId": "8a4f6e1d-...",
  "customerId": "CUST-1001",
  "items": [
    {
      "productId": 3,
      "productName": "Wireless Mouse",
      "quantity": 2,
      "unitPrice": 120.00,
      "lineTotal": 240.00
    }
  ],
  "totalPrice": 240.00,
  "orderDate": "2026-06-29T14:30:00",
  "status": "CREATED"
}

Available Endpoints

Method Endpoint Description
POST /api/orders Create a new order
GET /api/products List all products (proxied from Product Service)
GET /api/products/{id} Get a product by ID (proxied from Product Service)

πŸ§ͺ Testing

Run All Tests

./mvnw test

Or in IntelliJ:

  • Right-click src/test/java β†’ Run 'All Tests'

Test Coverage

Tests are written for:

  • βœ… Controllers β€” OrderController, ProductController
  • βœ… Service Layer β€” OrderServiceImpl, OrderEventPublisher
  • βœ… Mappers β€” OrderMapper
  • βœ… REST Client β€” ProductCatalogRestClient
  • βœ… Exception Handler β€” GlobalExceptionHandler

View Coverage Report

./mvnw test jacoco:report

Report is generated at target/site/jacoco/index.html.

πŸ”„ CI/CD Pipeline

We use GitHub Actions to automate build and testing on every Pull Request.

Pipeline Steps

  1. Checkout source code
  2. Set up JDK 21
  3. Cache Maven dependencies
  4. Run unit tests (mvn test)
  5. Build the project (mvn clean package)
  6. Run SonarCloud static code analysis
  7. Upload test reports as artifacts

Configuration file: .github/workflows/ci.yml

Code Quality

Static code analysis is performed via SonarCloud on every push and pull request. View the project dashboard on SonarCloud for:

  • Code coverage
  • Bugs and vulnerabilities
  • Code smells
  • Duplications

🐳 Docker

Verify Data in PostgreSQL

docker exec -it order-postgres psql -U order_user -d order_db -c "SELECT * FROM orders;"

RabbitMQ Management UI

You can view exchanges, queues, bindings, and inspect messages here.

Stop Containers

docker compose down

To also delete the database volume:

docker compose down -v

🌐 Related Services

This microservice is part of a larger system. See the other services:

🀝 Contributing

  1. Create a feature branch from main:
git checkout -b feature/your-feature-name
  1. Make your changes and commit with a meaningful message:
git commit -m "feat: describe your change"
  1. Push the branch and open a Pull Request:
git push origin feature/your-feature-name
  1. Wait for the CI pipeline to pass, get code review, then merge.

Commit Message Convention

  • feat: β€” new feature
  • fix: β€” bug fix
  • test: β€” adding or updating tests
  • docs: β€” documentation changes
  • refactor: β€” code refactoring without behavior change
  • ci: β€” CI/CD configuration changes

πŸ‘₯ Team

Name Student ID Role
Amindu Bhashana CS/2020/007 Order Service Developer
Lakith Randula CS/2020/017 Order Service Developer

πŸ“„ License

This project was developed for academic purposes as part of the CSCI 44092 – Software Engineering course.

πŸ“š References

About

Handles order creation and communicates with other services.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages