Skip to content

jbdoster/eventually-consistent-highly-scalable-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Eventually Consistent Highly Scalable System

A production-ready, highly scalable, eventually consistent system demonstrating modern microservices architecture with event-driven design patterns.

πŸš€ Quick Start

# Clone the repository
git clone <repository-url>
cd eventually-consistent-highly-scalable-system

# Start all services
docker compose up -d

# Access the web application
# Option 1: Port-based access
open http://localhost:3001

# Option 2: Domain-based access (add to /etc/hosts)
echo "127.0.0.1 app.eventualconsistent.local" >> /etc/hosts
open http://app.eventualconsistent.local:8080

# Access monitoring tools
open http://localhost:3000  # Grafana
open http://localhost:16686 # Jaeger

πŸ”’ HTTPS Setup

To run the web application using HTTPS with SSL/TLS encryption:

Automated HTTPS Setup

# Run the automated HTTPS setup script
./setup-https.sh

This script will:

  • βœ… Generate SSL certificates for both frontend and backend
  • βœ… Configure HAProxy for HTTPS termination
  • βœ… Update /etc/hosts with the local domain
  • βœ… Build and start all services with HTTPS enabled
  • βœ… Perform health checks to verify HTTPS is working

Manual HTTPS Setup

If you prefer to setup HTTPS manually:

# 1. Generate SSL certificates
chmod +x scripts/generate-ssl-cert.sh scripts/generate-backend-ssl.sh
./scripts/generate-ssl-cert.sh      # Frontend SSL certificates
./scripts/generate-backend-ssl.sh   # Backend SSL certificates

# 2. Create Docker volume for certificates
docker volume create ssl-certs

# 3. Add domain to /etc/hosts (optional for domain-based access)
echo "127.0.0.1 app.eventualconsistent.local" | sudo tee -a /etc/hosts

# 4. Start services
docker compose down
docker compose up -d --build

# 5. Wait for services to start
sleep 30

# 6. Verify HTTPS is working
curl -k https://localhost:8443/health

HTTPS Access Points

Once HTTPS is configured, access your services at:

Service HTTPS URL Purpose
Web Application https://localhost:3001 React frontend
API Gateway https://localhost:8443 HAProxy load balancer
Domain Access https://app.eventualconsistent.local:8443 Domain-based access
Keycloak Admin https://localhost:8443/admin Authentication server

Development Mode with HTTPS

To run the React app in development mode with HTTPS:

cd web_app
npm start  # Will use HTTPS if certificates are configured

Certificate Information

  • Certificate Type: Self-signed certificates for development
  • Certificate Location: Docker volume ssl-certs
  • Security Warning: You'll see browser warnings for self-signed certificates
    • Click "Advanced" β†’ "Proceed to localhost (unsafe)" to continue
  • Production: Replace with CA-signed certificates for production use

Troubleshooting HTTPS

# Check if HTTPS services are running
docker compose ps

# Test HTTPS connectivity
curl -k https://localhost:8443/health

# View HAProxy logs for SSL issues
docker compose logs load-balancer

# Regenerate certificates if needed
./scripts/generate-ssl-cert.sh
./scripts/generate-backend-ssl.sh

πŸ“š Documentation Index

Core Documentation

Document Description Key Files
Architecture System design, CQRS patterns, and service communication docker-compose.yml, load_balancer/haproxy.cfg
Deployment Guide Setup, configuration, and getting started scripts/, config/
API Reference Complete API documentation with examples *_service/src/main/java/*/controller/

Operations & Security

Document Description Key Files
Monitoring & Observability Metrics, alerting, and production readiness monitoring/, prometheus.yml
Authentication & Authorization Keycloak integration and security patterns auth/, realm-export.json
Security Guide Security concerns and best practices config/ssl/, load_balancer/haproxy.cfg
Incident Response Security incident response procedures scripts/security-scan.sh, monitoring/alert-rules.yml
Security Implementation Summary Complete security implementation status config/, ssl-cert-generator service

πŸ—οΈ System Overview

This system implements a CQRS (Command Query Responsibility Segregation) pattern with:

  • Event-driven architecture using RabbitMQ (config/rabbitmq/)
  • Keycloak-based authentication with enterprise-grade security (auth/)
  • Comprehensive monitoring with distributed tracing (monitoring/)
  • High availability and horizontal scaling capabilities (load_balancer/)

Key Components

Component Port Purpose Configuration
React Web App 3001 Frontend user interface web_app/
HAProxy 8080/8443 Load balancer and API gateway load_balancer/haproxy.cfg
Write Layer 8081/8083 Event-driven write operations write_layer/
Public API 8082 Read operations with caching public_api/
Coupon Service 8086 Business logic microservice coupon_service/
Keycloak 8090 Authentication server auth/realm-export.json

Infrastructure Services

Service Port Purpose Configuration
RabbitMQ 5672/15672 Message broker config/rabbitmq/rabbitmq.conf
Redis 6379 Cache layer config/redis.conf
DynamoDB 8000 NoSQL database scripts/init-dynamodb.sh
Kafka 9092 Event streaming docker-compose.yml
PostgreSQL 5432 Keycloak database auth/postgres-init.sql

πŸ”„ Architecture Patterns

Write Operations (Event-Driven)

Client β†’ HAProxy (TLS) β†’ Write Layer β†’ RabbitMQ β†’ Services β†’ Database

See: write_layer/src/main/java/com/example/writelayer/controller/WriteController.java

Read Operations (Cache-First)

Client β†’ HAProxy (TLS) β†’ Service β†’ Redis Cache β†’ Database (fallback)

See: public_api/src/main/java/com/example/publicapi/controller/PublicApiController.java

πŸ” Security Features

This system implements enterprise-grade security with comprehensive protection:

πŸ›‘οΈ Infrastructure Security

πŸ”’ Application Security

πŸ—„οΈ Data Security

πŸ“Š Security Monitoring

πŸ”§ Security Tools

# Complete security setup
./scripts/setup-security.sh

# Generate SSL certificates
./scripts/setup-ssl.sh

# Manage secrets securely
./scripts/secrets-manager.sh

# Run security vulnerability scan
./scripts/security-scan.sh

# Automated penetration testing
./scripts/penetration-test.sh

πŸ” Authentication

Default users for testing:

  • Admin: admin / admin
  • User: testuser / testuser

Access points:

Configuration: auth/realm-export.json

πŸ“Š Monitoring

Tool URL Purpose Configuration
Grafana http://localhost:3000 Dashboards monitoring/grafana-dashboards.yml
Jaeger http://localhost:16686 Distributed tracing docker-compose.yml
Prometheus http://localhost:9090 Metrics monitoring/prometheus.yml
RabbitMQ http://localhost:15672 Message queues config/rabbitmq/rabbitmq.conf

πŸ§ͺ Testing

# Health check all services
./scripts/production-health-check.sh

# Test event-driven operations
./scripts/test-idempotency.sh

# Performance testing
./scripts/performance-test.sh

# Security vulnerability scanning
./scripts/security-scan.sh

# Automated penetration testing
./scripts/penetration-test.sh

# Complete security setup and validation
./scripts/setup-security.sh

🐳 Docker Services

# View service status
docker compose ps

# View logs
docker compose logs -f [service-name]

# Scale services
docker compose up -d --scale write-layer=3

πŸ”§ Development

For detailed development instructions, see:

πŸ“ˆ Production Readiness

This system includes:

  • βœ… Health checks and monitoring
  • βœ… Distributed tracing with Jaeger
  • βœ… Enterprise security with comprehensive protection
  • βœ… Backup and recovery procedures
  • βœ… Performance testing capabilities
  • βœ… High availability patterns
  • βœ… Incident response procedures
  • βœ… Penetration testing framework

For production deployment details, see Monitoring & Observability.

πŸ›‘οΈ Security Checklist

All security requirements have been implemented:

Infrastructure Security βœ…

  • Network segmentation implemented
  • TLS encryption for all communications
  • Service mesh with mTLS configured
  • Secure service discovery
  • Regular security updates and patches

Application Security βœ…

  • Input validation and sanitization
  • Output encoding
  • Secure error handling
  • Authentication and authorization
  • Session management

Data Security βœ…

  • Data encryption at rest
  • Data encryption in transit
  • Secure key management
  • Data access controls
  • Data backup security

Monitoring and Incident Response βœ…

  • Security monitoring and alerting
  • Incident response procedures
  • Security audit logging
  • Regular security assessments
  • Penetration testing

Compliance and Governance βœ…

  • Security policies and procedures
  • Regular security training
  • Compliance monitoring
  • Risk assessment and management
  • Third-party security assessments

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Follow the architecture patterns documented in docs/
  4. Add tests and documentation
  5. Submit a pull request

πŸ“„ License

MIT License


For detailed information on any aspect of the system, please refer to the specific documentation files in the docs/ directory.

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published