Skip to content

A modern, reactive microservices-based Point of Sale (POS) system built with **Quarkus**, designed specifically for pharmaceutical retail operations with comprehensive compliance tracking and real-time event processing.

Notifications You must be signed in to change notification settings

hammond01/cleanslice-platform-quarkus

Repository files navigation

CleanSlice Platform - Pharmaceutical POS System

A modern microservices platform built with Quarkus for pharmaceutical and functional food retail, featuring Clean Architecture, reactive programming, and comprehensive audit logging.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Kong API Gateway :8000          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                   β”‚             β”‚              β”‚
β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Product    β”‚ β”‚   Category   β”‚ β”‚    Audit     β”‚ β”‚   Saga    β”‚
β”‚   Service    β”‚ β”‚   Service    β”‚ β”‚   Service    β”‚ β”‚Orchestrateβ”‚
β”‚   :8081      β”‚ β”‚   :8082      β”‚ β”‚   :8083      β”‚ β”‚   :8084   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                β”‚                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
β”‚ Product DB  β”‚  β”‚Category DB  β”‚  β”‚  Audit DB   β”‚
β”‚   :5432     β”‚  β”‚   :5433     β”‚  β”‚   :5434     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  Kafka Message Bus :9092    β”‚
         β”‚  (Audit Events, Saga)       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Key Features

  • Clean Architecture: Hexagonal architecture with clear separation of concerns
  • Reactive Programming: Built on Quarkus Reactive with Mutiny
  • Audit Logging: Comprehensive audit trail for pharmaceutical compliance
  • Event-Driven: Kafka-based async messaging for audit events
  • Saga Orchestration: Distributed transaction management
  • API Gateway: Kong for routing, rate limiting, and security
  • Multi-Database: Separate PostgreSQL instances per service
  • POS Context: Terminal, shift, and pharmacist tracking
  • Compliance-Ready: Prescription tracking, batch/lot traceability

πŸš€ Quick Start

Prerequisites

  • JDK 21+
  • Docker & Docker Compose
  • Gradle 8.x
  • PowerShell (for Windows) or Bash (for Linux/Mac)

1. Clone and Build

# Clone repository
git clone https://github.com/hammond01/cleanslice-platform-quarkus.git
cd HONEY_BEE

# Build all services
./gradlew build

# Or build specific services
./gradlew :services:product-service:build
./gradlew :services:category-service:build
./gradlew :services:audit-service:build

2. Start Infrastructure with Docker Compose

# Start all services (databases, Kafka, Kong)
docker-compose up -d

# View logs
docker-compose logs -f

# Check status
docker-compose ps

# Stop all services
docker-compose down

3. Run Services in Dev Mode

# Terminal 1 - Product Service
./gradlew :services:product-service:quarkusDev

# Terminal 2 - Category Service  
./gradlew :services:category-service:quarkusDev

# Terminal 3 - Audit Service
./gradlew :services:audit-service:quarkusDev

πŸ“‘ API Endpoints

Via Kong API Gateway (Port 8010)

  • Products: http://localhost:8010/products
  • Categories: http://localhost:8010/categories
  • Audit Logs: http://localhost:8010/audit

Direct Service Access (Development)

  • Product Service: http://localhost:8012/api/products
  • Category Service: http://localhost:8013/api/categories
  • Audit Service: http://localhost:8011/api/audit

Health & Metrics

  • Product Health: http://localhost:8012/q/health
  • Category Health: http://localhost:8013/q/health
  • Audit Health: http://localhost:8011/q/health
  • Product Metrics: http://localhost:8012/q/metrics

Documentation & Admin

  • Product Swagger: http://localhost:8012/q/swagger-ui
  • Category Swagger: http://localhost:8013/q/swagger-ui
  • Audit Swagger: http://localhost:8011/q/swagger-ui
  • Kong Admin API: http://localhost:8001
  • Kafka UI: http://localhost:8090

πŸ§ͺ Testing APIs

Create Category

curl -X POST http://localhost:8010/categories `
  -H "Content-Type: application/json" `
  -d '{
    "name": "Pharmaceuticals",
    "description": "Prescription and OTC medications",
    "slug": "pharmaceuticals"
  }'

Create Product

curl -X POST http://localhost:8010/products `
  -H "Content-Type: application/json" `
  -H "X-Terminal-Id: POS-001" `
  -H "X-Store-Id: STORE-HCM-01" `
  -d '{
    "name": "Paracetamol 500mg",
    "description": "Pain reliever and fever reducer",
    "price": 25000,
    "stock": 1000,
    "categoryNumber": "CAT-001",
    "requiresPrescription": false,
    "batchNumber": "BATCH-2024-001",
    "expiryDate": "2025-12-31"
  }'

Get All Products

curl http://localhost:8010/products

Get Product by Number

curl http://localhost:8010/products/PROD-001

Update Product

curl -X PUT http://localhost:8010/products/PROD-001 `
  -H "Content-Type: application/json" `
  -d '{
    "name": "Paracetamol 500mg",
    "price": 27000,
    "stock": 950
  }'

Delete Product (Soft Delete)

curl -X DELETE http://localhost:8010/products/PROD-001

πŸ—‚οΈ Project Structure

HONEY_BEE/
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ product-service/           # Product management service
β”‚   β”‚   β”œβ”€β”€ src/main/java/
β”‚   β”‚   β”‚   β”œβ”€β”€ application/       # Application layer
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ dto/           # Data transfer objects
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ mapper/        # Entity-DTO mappers
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ port/          # Hexagonal ports
β”‚   β”‚   β”‚   β”‚   └── service/       # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ domain/            # Domain layer
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ entity/        # Domain entities
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ enums/         # Domain enums
β”‚   β”‚   β”‚   β”‚   └── exception/     # Domain exceptions
β”‚   β”‚   β”‚   β”œβ”€β”€ infrastructure/    # Infrastructure layer
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ messaging/     # Kafka adapters
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ persistence/   # Database adapters
β”‚   β”‚   β”‚   β”‚   └── web/           # REST controllers
β”‚   β”‚   β”‚   └── presentation/      # Presentation layer
β”‚   β”‚   └── build.gradle.kts
β”‚   β”‚
β”‚   β”œβ”€β”€ category-service/          # Category management service
β”‚   β”‚   └── [Same structure as product-service]
β”‚   β”‚
β”‚   β”œβ”€β”€ audit-service/             # Audit logging service
β”‚   β”‚   β”œβ”€β”€ src/main/java/
β”‚   β”‚   β”‚   β”œβ”€β”€ application/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ usecase/       # Process audit events
β”‚   β”‚   β”‚   β”‚   └── mapper/
β”‚   β”‚   β”‚   β”œβ”€β”€ domain/
β”‚   β”‚   β”‚   β”‚   └── entity/        # AuditLog entity
β”‚   β”‚   β”‚   └── infrastructure/
β”‚   β”‚   β”‚       β”œβ”€β”€ messaging/     # Kafka consumer
β”‚   β”‚   β”‚       └── persistence/   # AuditLog repository
β”‚   β”‚   └── build.gradle.kts
β”‚   β”‚
β”‚   └── saga-orchestration/        # Saga pattern orchestrator
β”‚       └── build.gradle
β”‚
β”œβ”€β”€ share/                          # Shared libraries
β”‚   β”œβ”€β”€ src/main/java/share/
β”‚   β”‚   β”œβ”€β”€ context/               # PosContext, UserContext
β”‚   β”‚   β”œβ”€β”€ enums/                 # Shared enums
β”‚   β”‚   └── util/                  # Utility classes
β”‚   └── build.gradle.kts
β”‚
β”œβ”€β”€ core/                           # Core utilities
β”‚   └── build.gradle.kts
β”‚
β”œβ”€β”€ gateway/                        # Kong API Gateway config
β”‚   β”œβ”€β”€ kong.yml                   # Kong declarative config
β”‚   β”œβ”€β”€ docker-compose.yml         # Gateway setup
β”‚   └── configure-kong.ps1         # Setup script
β”‚
β”œβ”€β”€ docs/                           # Documentation
β”‚   β”œβ”€β”€ AUDIT_LOGGING_GUIDE.md     # Audit system guide
β”‚   β”œβ”€β”€ CLEAN_ARCHITECTURE.md      # Architecture docs
β”‚   └── REACTIVE_MIGRATION_REPORT.md
β”‚
β”œβ”€β”€ docker-compose.yml              # Main compose file
β”œβ”€β”€ build.gradle.kts                # Root build config
β”œβ”€β”€ settings.gradle.kts             # Module settings
└── README.md                       # This file

πŸ”§ Configuration

Service Ports

Service Port Database
Audit Service 8011 audit_db (PostgreSQL :5432)
Product Service 8012 product_db (PostgreSQL :5432)
Category Service 8013 category_db (PostgreSQL :5432)
Saga Orchestrator 8084 -
Kong Gateway 8010 kong (PostgreSQL :5432)
Kong Admin 8001 -
Kafka 9092 -
Kafka UI 8090 -
Zookeeper 2181 -
PostgreSQL 5432 All databases

Environment Variables

Create .env file for local development:

# Database
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

# Kafka
KAFKA_BOOTSTRAP_SERVERS=localhost:9092

# POS Context
STORE_ID=STORE-HCM-01
STORE_NAME=Main Store

πŸ› οΈ Tech Stack

Backend

  • Framework: Quarkus 3.6+ (Reactive)
  • Language: Java 21
  • Reactive: Mutiny, Vert.x
  • Database: PostgreSQL 16 (Reactive Client)
  • ORM: Hibernate Reactive Panache
  • Messaging: Apache Kafka
  • API Gateway: Kong
  • Build Tool: Gradle 8.x

Architecture Patterns

  • Clean Architecture (Hexagonal)
  • CQRS (Command Query Responsibility Segregation)
  • Event Sourcing (Audit events)
  • Saga Pattern (Distributed transactions)

DevOps & Tools

  • Containerization: Docker & Docker Compose
  • API Documentation: OpenAPI/Swagger
  • Logging: Quarkus Logging + Structured logs
  • Health Checks: MicroProfile Health
  • Metrics: MicroProfile Metrics

πŸ“š Key Features for Pharmaceutical POS

1. Audit Logging System

  • Complete audit trail for compliance
  • Tracks all CRUD operations
  • Records prescription validations
  • Monitors price changes
  • Batch/lot traceability
  • See AUDIT_LOGGING_GUIDE.md

2. POS Context Management

@Inject PosContext posContext;

// Set at login/shift start
posContext.setTerminalId("POS-001");
posContext.setStoreId("STORE-HCM-01");
posContext.setShiftId("SHIFT-MORNING");
posContext.setPharmacistId("PHARM-001");

3. Soft Delete Pattern

  • Products and categories use soft delete
  • Maintains referential integrity
  • Supports audit trail
  • isDeleted flag with deletedAt timestamp

4. Event-Driven Architecture

  • Kafka-based async messaging
  • Audit events published to Kafka
  • Consumer pattern in audit-service
  • Scalable and decoupled

5. Reactive Programming

  • Non-blocking I/O
  • High performance under load
  • Backpressure handling
  • Resource efficient

πŸ§ͺ Development

Running Tests

# Run all tests
./gradlew test

# Run specific service tests
./gradlew :services:product-service:test

# Run integration tests
./gradlew integrationTest

Code Quality

# Check code style
./gradlew checkstyleMain

# Run static analysis
./gradlew check

Database Migrations

# Using Flyway (if configured)
./gradlew flywayMigrate

# Or manual SQL scripts in src/main/resources/db/migration/

πŸ“ˆ Roadmap

Current Features βœ…

  • Clean Architecture implementation
  • Reactive programming with Mutiny
  • Product & Category management
  • Comprehensive audit logging
  • Kafka event streaming
  • Kong API Gateway
  • Multi-database setup
  • POS context management
  • Soft delete pattern

In Progress 🚧

  • Saga orchestration implementation
  • User authentication & authorization (JWT)
  • Role-based access control (RBAC)
  • Prescription management module

Planned πŸ“‹

  • Inventory management service
  • Sales transaction service
  • Customer management service
  • Reporting & analytics service
  • Redis caching layer
  • Elasticsearch for audit search
  • Service discovery (Consul)
  • Circuit breaker (Resilience4j)
  • Rate limiting & throttling
  • API versioning
  • GraphQL support
  • Monitoring (Prometheus + Grafana)
  • Distributed tracing (Jaeger)
  • CI/CD pipeline (GitHub Actions)
  • Kubernetes deployment configs

πŸ”’ Security Considerations

For Production

  1. Authentication: Implement JWT-based auth
  2. Authorization: RBAC with pharmacist roles
  3. Encryption: TLS for all communications
  4. Secrets: Use secret management (Vault)
  5. Audit: Enable comprehensive audit logging
  6. Database: Encrypt data at rest
  7. API Gateway: Rate limiting, IP whitelisting
  8. Compliance: HIPAA/GDPR considerations

πŸ“– Documentation

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Coding Standards

  • Follow Clean Architecture principles
  • Write reactive code (use Uni/Multi)
  • Add comprehensive audit logging
  • Include unit and integration tests
  • Document public APIs
  • Use meaningful variable names
  • Keep methods small and focused

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Team

  • Architecture: Clean Architecture + Hexagonal
  • Development: Quarkus Reactive Stack
  • Database: PostgreSQL with Reactive Client
  • Messaging: Apache Kafka
  • Gateway: Kong API Gateway

πŸ†˜ Troubleshooting

Common Issues

Port already in use

# Check which process uses port
netstat -ano | findstr :8081

# Kill the process
taskkill /PID <PID> /F

Database connection failed

# Check if PostgreSQL is running
docker ps | findstr postgres

# Restart database
docker-compose restart product-db

Kafka connection failed

# Check Kafka logs
docker-compose logs kafka

# Restart Kafka
docker-compose restart kafka zookeeper

Build failed

# Clean and rebuild
./gradlew clean build

# Skip tests if needed
./gradlew build -x test

πŸ“ž Support

For issues and questions:

  • Create an issue in GitHub
  • Check documentation in /docs
  • Review audit logging guide for compliance questions

Built with ❀️ for Pharmaceutical Retail Industry

Running the Application in Dev Mode

You can run your application in dev mode that enables live coding using:

# Audit Service (Port 8011)
./gradlew :services:audit-service:quarkusDev

# Product Service (Port 8012)
./gradlew :services:product-service:quarkusDev

# Category Service (Port 8013)
./gradlew :services:category-service:quarkusDev

NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at:

Packaging and Running the Application

The application can be packaged using:

./gradlew build

It produces the quarkus-run.jar file in the build/quarkus-app/ directory. Be aware that it's not an ΓΌber-jar as the dependencies are copied into the build/quarkus-app/lib/ directory.

The application is now runnable using java -jar build/quarkus-app/quarkus-run.jar.

If you want to build an ΓΌber-jar, execute the following command:

./gradlew build -Dquarkus.package.jar.type=uber-jar

The application, packaged as an ΓΌber-jar, is now runnable using java -jar build/*-runner.jar.

Creating a Native Executable

You can create a native executable using:

./gradlew build -Dquarkus.native.enabled=true

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:

./gradlew build -Dquarkus.native.enabled=true -Dquarkus.native.container-build=true

You can then execute your native executable with: ./build/code-with-quarkus-1.0.0-SNAPSHOT-runner

If you want to learn more about building native executables, please consult https://quarkus.io/guides/gradle-tooling.

Related Quarkus Guides

  • REST (guide): A Jakarta REST implementation utilizing build time processing and Vert.x
  • REST JSON-B (guide): JSON-B serialization support for Quarkus REST
  • Reactive PostgreSQL client (guide): Connect to PostgreSQL using reactive patterns
  • Hibernate Reactive Panache (guide): Reactive ORM with Panache
  • SmallRye Reactive Messaging (guide): Kafka integration for event streaming
  • OpenAPI (guide): API documentation with Swagger UI
  • Health Checks (guide): MicroProfile Health for readiness/liveness probes

Provided Code

Reactive REST Resources

All REST endpoints are built using reactive patterns with Quarkus REST and return Uni<T> or Multi<T> types for non-blocking operations.

Example:

@GET
@Path("/{number}")
public Uni<GetProduct> getProduct(@PathParam("number") String number) {
    return productService.getProductById(number);
}

Related guide section...

About

A modern, reactive microservices-based Point of Sale (POS) system built with **Quarkus**, designed specifically for pharmaceutical retail operations with comprehensive compliance tracking and real-time event processing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published