This repository contains a production-grade microservices architecture for the LifePill Pharmacy Management System. Built with Spring Cloud ecosystem, it follows industry best practices including Service Discovery, Centralized Configuration, API Gateway pattern, Circuit Breaker, Distributed Tracing, and comprehensive monitoring.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ LIFEPILL MICROSERVICES ARCHITECTURE │
│ Production Environment │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
EXTERNAL CLIENTS
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Mobile App │ │ Web App │ │ POS System │ │ Admin Panel │
│ (Flutter) │ │ (React) │ │ (Desktop) │ │ (React) │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │ │
└──────────────────────┴──────────────────────┴──────────────────────┘
│
│ HTTPS (Port 9191)
▼
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 🚪 API GATEWAY (Spring Cloud Gateway) │
│ Port: 9191 │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
│ │ Rate Limiting │ │ Circuit Breaker│ │ Load Balancer │ │ CORS Handler │ │ Request Router │ │
│ │ (Redis) │ │ (Resilience4j)│ │ (Ribbon) │ │ │ │ │ │
│ └────────────────┘ └────────────────┘ └────────────────┘ └────────────────┘ └────────────────┘ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
│
┌──────────────────────────┼──────────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────────────────┐ ┌─────────────────────────────┐ ┌─────────────────────────────┐
│ 🔐 SERVICE REGISTRY │ │ ⚙️ CONFIG SERVER │ │ 🔍 DISTRIBUTED TRACING │
│ (Netflix Eureka) │ │ (Spring Cloud Config) │ │ (Zipkin) │
│ Port: 8761 │ │ Port: 8888 │ │ Port: 9411 │
│ │ │ │ │ │
│ • Service Registration │ │ • Centralized Config │ │ • Request Tracing │
│ • Health Monitoring │ │ • Environment Profiles │ │ • Latency Analysis │
│ • Load Balancing Info │ │ • Runtime Refresh │ │ • Dependency Mapping │
└─────────────────────────────┘ └─────────────────────────────┘ └─────────────────────────────┘
▲ ▲ ▲
│ Register & Heartbeat │ Pull Configuration │ Send Traces
│ │ │
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 🏢 BUSINESS MICROSERVICES LAYER │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ 👤 USER AUTH │ │ 🏥 PATIENT CUSTOMER │ │ 🏪 BRANCH SERVICE │ │ 📦 INVENTORY │ │
│ │ SERVICE │ │ SERVICE │ │ │ │ SERVICE │ │
│ │ Port: 8080 │ │ Port: 8070 │ │ Port: 8081 │ │ Port: 8082 │ │
│ │ │ │ │ │ │ │ │ │
│ │ • Mobile Auth │ │ • Patient Records │ │ • Branch Management │ │ • Stock Management │ │
│ │ • JWT Tokens │ │ • Prescriptions │ │ • Location Data │ │ • Product Catalog │ │
│ │ • Email OTP │ │ • Stripe Payments │ │ • Operating Hours │ │ • Alerts & Reports │ │
│ │ • Password Reset │ │ • Customer Profile │ │ │ │ │ │
│ └──────────┬──────────┘ └──────────┬──────────┘ └──────────┬──────────┘ └──────────┬──────────┘ │
│ │ │ │ │ │
│ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ 🪪 IDENTITY │ │ 🛒 ORDER SERVICE │ │ │ │
│ │ SERVICE │ │ (POS System) │ │ Future Services │ │
│ │ Port: 8085 │ │ Port: 8086 │ │ │ │
│ │ │ │ │ │ • Notification │ │
│ │ • Employee Auth │ │ • Order Processing │ │ • Analytics │ │
│ │ • PIN Authentication│ │ • Transactions │ │ • Reporting │ │
│ │ • Session Caching │ │ • Receipt Gen │ │ │ │
│ └──────────┬──────────┘ └──────────┬──────────┘ └─────────────────────┘ │
│ │ │ │
└─────────────┼────────────────────────┼────────────────────────────────────────────────────────────────────────────┘
│ │
▼ ▼
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 💾 DATA LAYER │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ 🐘 PostgreSQL │ │ 🍃 MongoDB │ │ 🔴 Redis │ │
│ │ Port: 5432 │ │ Port: 27017 │ │ Port: 6379 │ │
│ │ │ │ │ │ │ │
│ │ DATABASES: │ │ COLLECTIONS: │ │ USAGE: │ │
│ │ • mobile_user_auth │ │ • lifepill_customer │ │ • Session Cache │ │
│ │ • identity_service │ │ • prescriptions │ │ • Rate Limiting │ │
│ │ • branch_service │ │ • medical_records │ │ • Token Blacklist │ │
│ │ • inventory_service │ │ │ │ │ │
│ │ • order_service │ │ │ │ │ │
│ │ • customer_service │ │ │ │ │ │
│ └─────────────────────┘ └─────────────────────┘ └─────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 📊 OBSERVABILITY STACK │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ 📈 Prometheus │ │ 📊 Grafana │ │ 🔍 Zipkin │ │ 📤 Exporters │ │
│ │ Port: 9090 │ │ Port: 3001 │ │ Port: 9411 │ │ │ │
│ │ │ │ │ │ │ │ • PostgreSQL :9187 │ │
│ │ • Metrics Scraping │ │ • Dashboards │ │ • Trace Collection │ │ • Redis :9121 │ │
│ │ • Alert Rules │ │ • Visualization │ │ • Service Map │ │ • MongoDB :9216 │ │
│ │ • Time Series DB │ │ • Alerting │ │ • Latency Analysis │ │ │ │
│ └─────────────────────┘ └─────────────────────┘ └─────────────────────┘ └─────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ REQUEST FLOW: Client → Service → Response │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
CLIENT API GATEWAY SERVICE REGISTRY TARGET SERVICE
│ │ │ │
│ 1. HTTP Request │ │ │
│ GET /api/user-auth/... │ │ │
│─────────────────────────▶│ │ │
│ │ │ │
│ │ 2. Rate Limit Check │ │
│ │ (Redis) │ │
│ │─────────┐ │ │
│ │ │ Check │ │
│ │◀────────┘ Quota │ │
│ │ │ │
│ │ 3. Lookup Service │ │
│ │ Location │ │
│ │───────────────────────────▶│ │
│ │ │ │
│ │ 4. Return Healthy │ │
│ │ Instance List │ │
│ │◀───────────────────────────│ │
│ │ │ │
│ │ 5. Load Balance & │ │
│ │ Forward Request │ │
│ │───────────────────────────────────────────────────────▶│
│ │ │ │
│ │ │ 6. Process Request │
│ │ │ - Validate JWT │
│ │ │ - Business Logic │
│ │ │ - Database Query │
│ │ │ │
│ │ 7. Service Response │ │
│ │◀───────────────────────────────────────────────────────│
│ │ │ │
│ │ 8. Circuit Breaker │ │
│ │ Health Update │ │
│ │─────────┐ │ │
│ │ │ Record │ │
│ │◀────────┘ Metrics │ │
│ │ │ │
│ 9. HTTP Response │ │ │
│◀─────────────────────────│ │ │
│ │ │ │
PARALLEL: Zipkin Trace Propagation ─────────────────────────────────────────────────────▶ Zipkin Server
| Step | Component | Action | Details |
|---|---|---|---|
| 1 | Client | Send Request | HTTP/HTTPS request to http://34.59.6.212:9191/api/{service}/{endpoint} |
| 2 | API Gateway | Rate Limiting | Check Redis for request quota (prevents DDoS) |
| 3 | API Gateway | Service Discovery | Query Eureka for available service instances |
| 4 | Eureka | Return Instances | Provide list of healthy service instances |
| 5 | API Gateway | Load Balancing | Select instance using Round Robin / Weighted algorithm |
| 6 | Target Service | Process Request | JWT validation → Business logic → Database query |
| 7 | Target Service | Return Response | Send response back through gateway |
| 8 | API Gateway | Circuit Breaker | Update health metrics, trip breaker if errors exceed threshold |
| 9 | Client | Receive Response | Final HTTP response with data |
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ API GATEWAY ROUTE CONFIGURATION │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ INCOMING REQUEST ROUTED TO SERVICE │
│ ───────────────── ───────── ─────── │
│ │
│ /api/user-auth/** ───────────────▶ lb://USER-AUTH ───────▶ User Auth (8080) │
│ /api/identity/** ───────────────▶ lb://IDENTITY-SERVICE ───────▶ Identity (8085) │
│ /api/customer/** ───────────────▶ lb://PATIENT-CUSTOMER ───────▶ Patient Customer (8070) │
│ /api/branch/** ───────────────▶ lb://BRANCH-SERVICE ───────▶ Branch (8081) │
│ /api/inventory/** ───────────────▶ lb://INVENTORY-SERVICE ───────▶ Inventory (8082) │
│ /api/order/** ───────────────▶ lb://ORDER-SERVICE ───────▶ Order (8086) │
│ │
│ Note: "lb://" = Load Balanced (Service Discovery enabled) │
│ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ EXAMPLE 1: Mobile App Login (User Auth Service) │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ Mobile App │
│ │ │
│ │ POST http://34.59.6.212:9191/api/user-auth/v1/auth/login │
│ │ Body: { "email": "user@test.com", "password": "..." } │
│ │ │
│ ▼ │
│ API Gateway (9191) │
│ │ │
│ │ Route: /api/user-auth/** → lb://USER-AUTH │
│ │ Strip Prefix: /api/user-auth │
│ │ │
│ ▼ │
│ User Auth Service (8080) │
│ │ │
│ │ Internal: POST /v1/auth/login │
│ │ • Validate credentials against PostgreSQL │
│ │ • Generate JWT access + refresh tokens │
│ │ • Return tokens to client │
│ │ │
│ ▼ │
│ Response: { "accessToken": "eyJ...", "refreshToken": "eyJ...", "user": {...} } │
│ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ EXAMPLE 2: POS System Employee Login (Identity Service + Redis) │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ POS Desktop App │
│ │ │
│ │ POST http://34.59.6.212:9191/api/identity/lifepill/v1/auth/authenticate │
│ │ Body: { "employerEmail": "emp@lifepill.com", "employerPassword": "..." } │
│ │ │
│ ▼ │
│ API Gateway (9191) │
│ │ │
│ │ Route: /api/identity/** → lb://IDENTITY-SERVICE │
│ │ │
│ ▼ │
│ Identity Service (8085) │
│ │ │
│ ├──▶ PostgreSQL: Verify employee credentials │
│ │ │
│ ├──▶ Redis: Cache session { token, user, pin, expiry } │
│ │ │
│ ▼ │
│ Response: { "token": "eyJ...", "employer": {...}, "sessionId": "..." } │
│ │
│ ───────────────────────────────────────────────────────────────────────────────────────────────────────│
│ │
│ QUICK RE-LOGIN (PIN from Redis Cache): │
│ │
│ POST /api/identity/lifepill/v1/session/authenticate/cached │
│ Body: { "username": "emp@lifepill.com", "pin": 1234 } │
│ │ │
│ ▼ │
│ Identity Service → Redis (Check cached PIN) → Return cached session │
│ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ EXAMPLE 3: Customer Payment (Patient Customer Service + Stripe) │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ Web App │
│ │ │
│ │ POST http://34.59.6.212:9191/api/customer/payments/create │
│ │ Headers: { Authorization: "Bearer eyJ..." } │
│ │ Body: { "amount": 150.00, "customerId": "cust_123" } │
│ │ │
│ ▼ │
│ API Gateway (9191) │
│ │ │
│ │ • Relay Authorization header │
│ │ • Route: /api/customer/** → lb://PATIENT-CUSTOMER │
│ │ │
│ ▼ │
│ Patient Customer Service (8070) │
│ │ │
│ ├──▶ MongoDB: Fetch customer profile │
│ │ │
│ ├──▶ Stripe API: Create PaymentIntent │
│ │ │
│ ├──▶ PostgreSQL: Record transaction │
│ │ │
│ ▼ │
│ Response: { "paymentIntentId": "pi_...", "clientSecret": "pi_..._secret_..." } │
│ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ PULL-BASED SERVICE DISCOVERY │
│ (Netflix Eureka Pattern) │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────┐
│ EUREKA SERVER │
│ (Port 8761) │
│ │
│ Service Registry: │
│ ┌───────────────────┐ │
│ │ USER-AUTH │ │
│ │ └─ 8080 (healthy)│ │
│ │ IDENTITY-SERVICE │ │
│ │ └─ 8085 (healthy)│ │
│ │ PATIENT-CUSTOMER │ │
│ │ └─ 8070 (healthy)│ │
│ │ BRANCH-SERVICE │ │
│ │ └─ 8081 (healthy)│ │
│ │ INVENTORY-SERVICE │ │
│ │ └─ 8082 (healthy)│ │
│ │ ORDER-SERVICE │ │
│ │ └─ 8086 (healthy)│ │
│ └───────────────────┘ │
└───────────┬─────────────┘
│
┌───────────────────────────┼───────────────────────────┐
│ │ │
1. REGISTER 2. PULL REGISTRY 3. HEARTBEAT
(On Startup) (Every 30 sec) (Every 30 sec)
│ │ │
▼ ▼ │
┌───────────────────────┐ ┌───────────────────────┐ │
│ MICROSERVICE │ │ API GATEWAY │ │
│ (Any Service) │ │ (Port 9191) │ │
│ │ │ │ │
│ On startup: │ │ Cached Registry: │ │
│ • Register with │ │ ┌───────────────────┐ │ │
│ Eureka │ │ │ USER-AUTH: 8080 │ │ │
│ • Send metadata │ │ │ IDENTITY: 8085 │ │ │
│ (host, port, health)│ │ │ PATIENT: 8070 │ │ │
│ │ │ │ ... │ │ │
│ Every 30 seconds: │ │ └───────────────────┘ │ │
│ • Send heartbeat ─────┼─────┼─────────────────────────────────────────┘
│ │ │ │
└───────────────────────┘ │ Uses cache to route │
│ requests instantly │
└───────────────────────┘
FLOW EXPLANATION:
━━━━━━━━━━━━━━━━━
1. SERVICE REGISTRATION: When a microservice starts, it registers itself with Eureka
including its service name, host, port, and health check URL.
2. REGISTRY PULL: API Gateway pulls the full service registry every 30 seconds
and caches it locally for fast routing decisions.
3. HEARTBEAT: Each service sends a heartbeat to Eureka every 30 seconds.
If missed 3 times (90 sec), the service is marked as DOWN and removed.
4. SELF-PRESERVATION: If >85% of instances miss heartbeats (network partition),
Eureka enters self-preservation mode and keeps registrations.
This is a monorepo that links to the following microservices as Git submodules:
| Submodule | Repository | Description | Port |
|---|---|---|---|
api-gateway |
Life-Pill/api-gateway | Spring Cloud Gateway with Circuit Breaker | 9191 |
service-registry |
Life-Pill/service-registry | Netflix Eureka Server | 8761 |
config-server |
Life-Pill/configuration-server | Spring Cloud Config Server | 8888 |
user-auth |
Life-Pill/mobile-auth-user-service | JWT Authentication Service (Mobile) | 8080 |
patient-customer-service |
Life-Pill/patient-web-customer-service | Patient & Customer Management | 8070 |
| Service | Location | Description | Port |
|---|---|---|---|
employee-identity-service |
./employee-identity-service |
Employee Auth with Redis Session | 8085 |
branch-service |
./branch-service |
Branch Management | 8081 |
inventory-service |
./inventory-service |
Inventory Management | 8082 |
order-service |
./pharmacy-pos-main-backend/order-system |
Order Processing & POS | 8086 |
# Clone with all submodules
git clone --recurse-submodules https://github.com/Life-Pill/mobile-ms.git
# Or if already cloned, initialize submodules
git submodule init
git submodule update
# Update all submodules to latest
git submodule update --remote --merge| Service | Port | Description | Database |
|---|---|---|---|
| User Auth Service | 8080 | JWT-based authentication for mobile apps | PostgreSQL |
| Identity Service | 8085 | Employee auth with PIN & Redis session caching | PostgreSQL + Redis |
| Patient Customer Service | 8070 | Patient records, prescriptions, Stripe payments | PostgreSQL + MongoDB |
| Branch Service | 8081 | Branch management, locations, operating hours | PostgreSQL |
| Inventory Service | 8082 | Stock management, product catalog, alerts | PostgreSQL |
| Order Service | 8086 | Order processing, transactions, receipts | PostgreSQL |
| Service | Port | Description |
|---|---|---|
| Service Registry | 8761 | Netflix Eureka Server for service discovery |
| Config Server | 8888 | Centralized configuration management |
| API Gateway | 9191 | Single entry point with routing, load balancing, circuit breaker |
| Service | Port | Description |
|---|---|---|
| PostgreSQL | 5432 | Primary relational database |
| MongoDB | 27017 | Document database for patient records |
| Redis | 6379 | Session caching and rate limiting |
| Service | Port | Description |
|---|---|---|
| Prometheus | 9090 | Metrics collection and alerting |
| Grafana | 3001 | Metrics visualization dashboards |
| Zipkin | 9411 | Distributed tracing |
| PostgreSQL Exporter | 9187 | PostgreSQL metrics for Prometheus |
| Redis Exporter | 9121 | Redis metrics for Prometheus |
| MongoDB Exporter | 9216 | MongoDB metrics for Prometheus |
The system uses Pull-based Service Discovery via Netflix Eureka:
┌─────────────────────────────────────────────────────────────────────────────┐
│ PULL ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ 1. Register ┌─────────────────┐ │
│ │ Service │ ─────────────────────────────────▶│ Eureka Server │ │
│ │ (on start) │ │ (8761) │ │
│ └─────────────┘ └────────┬────────┘ │
│ │ │
│ │ │
│ ┌─────────────┐ 2. Pull Registry ┌───────┴───────┐ │
│ │ API Gateway │ ◀────────────────────────────────│ Service List │ │
│ │ (9191) │ (Every 30 sec) └───────────────┘ │
│ └──────┬──────┘ │
│ │ │
│ │ 3. Route Request (with cached registry) │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────┐ │
│ │ MICROSERVICES │ │
│ │ │ │
│ │ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ │ │
│ │ │ Identity │ │ User │ │ Patient │ │ Order │ │ │
│ │ │ Service │ │ Auth │ │ Service │ │ Service │ │ │
│ │ │ (8085) │ │ (8080) │ │ (8070) │ │ (8086) │ │ │
│ │ └───────────┘ └───────────┘ └───────────┘ └───────────┘ │ │
│ │ │ │
│ │ ┌───────────┐ ┌───────────┐ │ │
│ │ │ Branch │ │ Inventory │ │ │
│ │ │ Service │ │ Service │ │ │
│ │ │ (8081) │ │ (8082) │ │ │
│ │ └───────────┘ └───────────┘ │ │
│ └──────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
PULL FLOW:
1. Services REGISTER themselves with Eureka on startup
2. API Gateway PULLS the service registry every 30 seconds
3. Gateway uses CACHED registry to route requests to services
4. If a service goes down, it's removed from registry after heartbeat timeout
┌─────────────────────────────────────────────────────────────────────────────┐
│ SESSION MANAGEMENT FLOW │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ 1. Login (password) ┌──────────────┐ │
│ │ Client │ ──────────────────────────▶│ Identity │ │
│ │ (POS) │ │ Service │ │
│ └──────────┘ └──────┬───────┘ │
│ │ │ │
│ │ │ 2. Authenticate │
│ │ │ & Generate JWT │
│ │ ▼ │
│ │ ┌──────────────┐ │
│ │ │ PostgreSQL │ │
│ │ │ (5432) │ │
│ │ └──────────────┘ │
│ │ │ │
│ │ │ 3. Cache Session │
│ │ ▼ │
│ │ ┌──────────────┐ │
│ │ │ Redis │ │
│ │ ◀──────────────────────────── │ (6379) │ │
│ │ 4. Return JWT + Session │ │ │
│ │ │ ┌────────┐ │ │
│ │ │ │Session │ │ │
│ │ │ │ Data: │ │ │
│ │ │ │ -token │ │ │
│ │ │ │ -user │ │ │
│ │ │ │ -expiry│ │ │
│ │ │ │-revoked│ │ │
│ │ │ └────────┘ │ │
│ │ └──────────────┘ │
│ │ │
│ │ 5. Re-login with PIN (from cache) │
│ │ ─────────────────────────────────────────▶ │
│ │ │
│ │ ◀───────────────────────────────────── │
│ │ 6. Return cached session │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
SESSION OPERATIONS:
┌─────────────────────────────────────────────────────────────────┐
│ Temporary Logout │ Keep cache data, set DB inactive │
│ │ User can re-login with PIN │
├───────────────────┼────────────────────────────────────────────┤
│ Permanent Logout │ Delete cache data, set DB inactive │
│ │ User must login with password │
├───────────────────┼────────────────────────────────────────────┤
│ Session Valid │ revoked == false AND expiresAt > now() │
└───────────────────┴────────────────────────────────────────────┘
| Method | Endpoint | Request Body | Description |
|---|---|---|---|
| POST | /lifepill/v1/auth/authenticate |
{"employerEmail": "...", "employerPassword": "..."} |
Login with password (caches session) |
| POST | /lifepill/v1/auth/authenticate-pin |
{"employerEmail": "...", "pin": 1234} |
Login with PIN (caches session) |
| POST | /lifepill/v1/session/authenticate/cached |
{"username": "...", "pin": 1234} |
Re-login from cache with PIN |
| POST | /lifepill/v1/session/logout/temporary |
{"username": "..."} |
Temporary logout (keeps cache) |
| POST | /lifepill/v1/session/logout/permanent |
{"username": "..."} |
Permanent logout (removes cache) |
| GET | /lifepill/v1/session/get-cached-employer/email/{email} |
- | Get cached session by email |
| GET | /lifepill/v1/session/get-all-cached-employers |
- | Get all cached sessions |
| GET | /lifepill/v1/session/check/{email} |
- | Check if session is valid |
Important: Services must be started in the following order:
1. PostgreSQL, MongoDB, Redis - Infrastructure
2. Service Registry (Eureka Server) - Port 8761
3. Config Server - Port 8888
4. Zipkin - Port 9411
5. API Gateway - Port 9191
6. Identity Service - Port 8085
7. User Auth Service - Port 8080
8. Patient Customer Service - Port 8070
9. Other Services...
10. Prometheus, Grafana - Monitoring
Each service requires specific environment variables. Copy the .env.example files to .env and configure:
EUREKA_PORT=8761
EUREKA_USERNAME=admin
EUREKA_PASSWORD=your-secure-passwordCONFIG_SERVER_PORT=8888
CONFIG_SERVER_USERNAME=configuser
CONFIG_SERVER_PASSWORD=your-secure-password
EUREKA_URI=http://localhost:8761/eureka/API_GATEWAY_PORT=9191
EUREKA_URI=http://localhost:8761/eureka/
CORS_ORIGINS=http://localhost:3000,http://localhost:8081DB_URL=jdbc:postgresql://localhost:5432/mobile_user_auth_db
DB_USERNAME=postgres
DB_PASSWORD=your-db-password
JWT_SECRET=your-jwt-secret-key
EUREKA_URI=http://localhost:8761/eureka/DB_URL=jdbc:postgresql://localhost:5432/identity_service_db
REDIS_HOST=localhost
REDIS_PORT=6379
JWT_SECRET=your-jwt-secret-key
EUREKA_URI=http://localhost:8761/eureka/# Copy environment file and configure
cp .env.example .env
# Build and start all services
docker compose --env-file .env up -d
# View logs
docker compose logs -f
# Stop all services
docker compose down# 1. Clone repository
git clone --recurse-submodules https://github.com/Life-Pill/mobile-ms.git
cd mobile-ms
# 2. Setup environment
cp .env.example .env
# Edit .env with your configuration
# 3. Start all services
docker compose --env-file .env up -d
# 4. Verify services
docker compose psAfter starting with Docker Compose:
| Service | URL |
|---|---|
| Eureka Dashboard | http://localhost:8761 |
| API Gateway | http://localhost:9191 |
| Identity Service Swagger | http://localhost:8085/swagger-ui/index.html |
| User Auth Swagger | http://localhost:8080/api/swagger-ui.html |
| Patient Customer Swagger | http://localhost:8070/swagger-ui.html |
| Branch Service Swagger | http://localhost:8081/swagger-ui.html |
| Inventory Service Swagger | http://localhost:8082/swagger-ui.html |
| Order Service Swagger | http://localhost:8086/swagger-ui.html |
| Prometheus | http://localhost:9090 |
| Grafana | http://localhost:3001 |
| Zipkin | http://localhost:9411 |
| Service | URL |
|---|---|
| Eureka Dashboard | http://34.59.6.212:8761 |
| API Gateway | http://34.59.6.212:9191 |
| User Auth Swagger | http://34.59.6.212:8080/api/swagger-ui.html |
| Patient Customer Swagger | http://34.59.6.212:8070/swagger-ui.html |
| Branch Service Swagger | http://34.59.6.212:8081/swagger-ui.html |
| Inventory Service Swagger | http://34.59.6.212:8082/swagger-ui.html |
| Identity Service Swagger | http://34.59.6.212:8085/swagger-ui.html |
| Order Service Swagger | http://34.59.6.212:8086/swagger-ui.html |
| Prometheus | http://34.59.6.212:9090 |
| Grafana | http://34.59.6.212:3001 |
| Zipkin | http://34.59.6.212:9411 |
All services expose actuator endpoints for monitoring:
| Endpoint | Description |
|---|---|
/actuator/health |
Health status |
/actuator/info |
Application info |
/actuator/metrics |
Metrics data |
/actuator/prometheus |
Prometheus format metrics |
Access Eureka Dashboard: http://localhost:8761
- Username:
admin(default) - Password:
admin(default)
- Circuit Breaker pattern (Resilience4j)
- Request rate limiting
- CORS configuration
- Request/Response logging
- Authentication header relay
- JWT-based authentication
- BCrypt password encoding
- PIN-based quick authentication
- Redis session caching with TTL
- Session revocation support
- Basic authentication for dashboard
- Secured actuator endpoints
The API Gateway implements circuit breaker pattern:
resilience4j:
circuitbreaker:
instances:
userAuthCircuitBreaker:
sliding-window-size: 5
failure-rate-threshold: 40
wait-duration-in-open-state: 15s- Java 17
- Spring Boot 3.3.0
- Spring Cloud 2023.0.1
- Spring Cloud Gateway (Reactive)
- Netflix Eureka (Service Discovery)
- Spring Cloud Config (Configuration Management)
- Resilience4j (Circuit Breaker)
- Spring Data Redis (Session Caching)
- Micrometer + Prometheus (Metrics)
- PostgreSQL (Database)
- MongoDB (Document Database)
- Redis (Session Cache)
- Flyway (Database Migration)
- JWT (Authentication)
For support, email support@lifepill.com or raise an issue in the repository.
This project is licensed under the MIT License.