How harualex/pharmacymanagementsoa works
This repository is a pharmacy-management SOA: a web frontend sends requests through an API gateway to authentication, catalog, inventory, purchasing, sales, and reporting services. The gateway adds Consul-based discovery and load balancing, resilience controls, idempotency, and operational metrics. The README documents the service capabilities and SQL Server/Consul integrations; sampled gateway sources confirm several internal calls, while domain-service request flows and most service implementations were not sampled, so those links follow documented architecture rather than inspected call sites.
Main entry points: GatewayController.java API gateway · ResilientServiceCaller.java Resilient HTTP caller · MetricsCollector.java Metrics collector · ServiceDiscoveryClient.java Service discovery
Components 26
Client
- Web frontend
frontend/server.js
Gateway
- API gateway
api-gateway/app/controllers/GatewayController.java - Idempotency filter and cache
shared/filters/IdempotencyFilter.java - In-memory idempotency cache
shared/services/InMemoryIdempotencyCache.java - Metrics and health endpoints
api-gateway/app/controllers/MetricsController.java - Metrics collector
api-gateway/app/services/MetricsCollector.java - Metrics snapshot
api-gateway/app/models/MetricsSnapshot.java
Pharmacy Services
- Authentication and users
auth-service/app - Medicine catalog and branches
catalog-service/app - Stock and transfers
inventory-service/app - Inventory repository
inventory-service/app/db/InventoryRepository.java - Purchasing and supplier debt
purchase-service/app - Sales and returns
sales-service/app - Reports and dashboard
report-service/app
Discovery and Operations
- Service registration
auth-service/app/modules/ConsulModule.java - Service discovery
api-gateway/app/services/ServiceDiscoveryClient.java - Round-robin balancing
api-gateway/app/services/RoundRobinLoadBalancer.java
Gateway Resilience
- Resilient HTTP caller
api-gateway/app/services/ResilientServiceCaller.java - Retry policy
api-gateway/app/services/ExponentialBackoffRetryPolicy.java - Circuit breaker registry
api-gateway/app/services/CircuitBreakerRegistry.java - Circuit breaker
api-gateway/app/services/SimpleCircuitBreaker.java - Bulkhead registry
api-gateway/app/services/BulkheadRegistry.java - Bulkhead executor
api-gateway/app/services/BulkheadExecutor.java
Other components
- Pharmacy user
- Microsoft SQL Server
- Consul registry
Connections 25
- Pharmacy user → Web frontend: uses
README.md - Web frontend → API gateway: sends requests
README.md - API gateway → Authentication and users: routes requests
README.md - API gateway → Medicine catalog and branches: routes requests
README.md - API gateway → Stock and transfers: routes requests
README.md - API gateway → Purchasing and supplier debt: routes requests
README.md - API gateway → Sales and returns: routes requests
README.md - API gateway → Reports and dashboard: routes requests
README.md - Service registration → Consul registry: registers instances
README.md - Service discovery → Consul registry: queries health
api-gateway/app/services/ServiceDiscoveryClient.java - Service discovery → Round-robin balancing: selects instance
api-gateway/app/services/ServiceDiscoveryClient.java - Resilient HTTP caller → Service discovery: finds instances
api-gateway/app/services/ResilientServiceCaller.java - Resilient HTTP caller → Retry policy: checks retries
api-gateway/app/services/ResilientServiceCaller.java - Resilient HTTP caller → Circuit breaker registry: gets breaker
api-gateway/app/services/ResilientServiceCaller.java - Resilient HTTP caller → Bulkhead registry: gets executor
api-gateway/app/services/ResilientServiceCaller.java - Circuit breaker registry → Circuit breaker: creates breaker
api-gateway/app/services/CircuitBreakerRegistry.java - Bulkhead registry → Bulkhead executor: creates executor
api-gateway/app/services/BulkheadRegistry.java - Stock and transfers → Inventory repository: uses repository
- Reports and dashboard → Microsoft SQL Server: reads data
README.md - Idempotency filter and cache → In-memory idempotency cache: reads and writes
shared/filters/IdempotencyFilter.java - Metrics and health endpoints → Metrics collector: captures metrics
api-gateway/app/controllers/MetricsController.java - Metrics collector → Circuit breaker registry: collects state
api-gateway/app/services/MetricsCollector.java - Metrics collector → Bulkhead registry: collects stats
api-gateway/app/services/MetricsCollector.java - Metrics collector → Metrics snapshot: builds snapshot
api-gateway/app/services/MetricsCollector.java - Metrics and health endpoints → Metrics snapshot: formats health
api-gateway/app/controllers/MetricsController.java