System Overview: This document describes how Yarpie (reverse proxy) and Aspire orchestration work together in the AdminWeb ecosystem, managing traffic routing and local development environments.
Architecture Overview
The AdminWeb product uses a distributed microservices architecture with two key infrastructure components:- Aspire (
Main.AppHost): Local development orchestration and service discovery - Yarpie: Production reverse proxy with blue/green deployment capabilities
Aspire - Local Development Orchestration
Purpose
Main.AppHost is the .NET Aspire host project that orchestrates all services locally during development. It provides:
- Service Discovery: Automatic registration and discovery of all microservices
- Networking: Internal communication between services using service names
- Configuration Management: Centralized environment variable management
- Dependency Management: Orchestrates startup order and health checks
How Aspire Works
Key Features
Service Endpoints: Services reference each other using their project names as hostnames:Main.AppHost/Program.cs:
/.github/container-scripts/environment_variables.py and applied during deployment.
Yarpie - Production Reverse Proxy
Purpose
Yarpie is a reverse proxy built on YARP (Yet Another Reverse Proxy) that handles production traffic routing and enables blue/green deployments.Key Responsibilities
- Unified Entry Point: Single public endpoint for all web traffic
- Routing: Routes requests to appropriate Blazor frontends (Web projects)
- Blue/Green Deployments: Switches traffic between deployment versions with zero downtime
- Load Balancing: Distributes traffic across multiple instances
- SSL/TLS Termination: Handles HTTPS at the edge
- API Gateway Patterns: Can implement rate limiting, authentication, logging
Yarpie Architecture
Yarpie Configuration
Routes are configured in Yarpie’s configuration files to:- Map public URLs to backend Blazor applications
- Handle SSL certificates (from AWS Secrets Manager or CloudFlare)
- Define health check endpoints
- Configure timeout and retry policies
How They Work Together
Local Development (with Aspire)
Development Benefits:- No manual URL configuration
- Services automatically discover each other
- Local database (LocalDB or Docker)
- Integrated logging and debugging
- Matches production architecture
Production (with Yarpie)
Blue/Green Deployment Flow
Deployment Process:- Deploy new version to Green environment
- Run health checks and smoke tests
- Yarpie switches traffic from Blue to Green (instantaneous)
- Blue becomes the idle/standby environment
- Rollback: Switch back to Blue if issues detected
Communication Patterns
Within Aspire (Development)
Services communicate using:- gRPC: Service-to-service direct calls (Protobuffers for serialization)
- RabbitMQ: Asynchronous message passing between services
- Entity Framework: Database access via
Sa.DataAccess - Dapper: Complex query execution (when EF is insufficient)
Within Yarpie (Production)
Key Configuration Files
Aspire Configuration
Main.AppHost/Program.cs: Orchestration and environment setupMain.AppHost/appsettings.json: Local secrets and configurations/.github/container-scripts/environment_variables.py: Test/Production environment overrides
Yarpie Configuration
Yarpie/config.jsonorProgram.cs: Route definitions- AWS Secrets Manager / CloudFlare: Production SSL certificates and routing rules
/.github/workflows/: CI/CD pipeline integration for deployments
Service Project Structure Reference
Web Projects (*.Web)
- Blazor applications (server or client)
- Connected to Yarpie in production
- Connected to Aspire in development
- Call GRPC ServiceApis
Service APIs (*.ServiceApis)
- GRPC endpoints
- Business logic and validation
- Called by Web and Worker projects
- Access data via CoreLibs
Workers (*.Workers)
- Background services
- RabbitMQ consumers
- Execute scheduled tasks
- Run EF migrations (from CoreLibs)
Core Libraries (*.CoreLibs)
- Data models (Entity Framework DbContext)
- Repository patterns
- Database migrations (executed by Workers)
- Shared business logic
Development Workflow
- Start Aspire:
dotnet run --project Main.AppHost - Access Dashboard: https://localhost:port (shows all running services)
- Services Auto-Discover: No URL configuration needed
- Debug: Set breakpoints in any service
- Test Changes: Modify code and services reload
Production Workflow
- Build & Package: Docker images created for each service
- Deploy to Green: New version deployed alongside Blue
- Health Checks: Verify Green environment is healthy
- Traffic Switch: Yarpie routes 100% traffic to Green
- Monitor: Watch metrics, logs, error rates
- Rollback Option: Switch back to Blue if needed
