Skip to content

[Glense][Infra] YARP Gateway integration#25

Merged
Brankonymous merged 1 commit intomainfrom
branko-grbic/yarp-gateway-integration
Mar 29, 2026
Merged

[Glense][Infra] YARP Gateway integration#25
Brankonymous merged 1 commit intomainfrom
branko-grbic/yarp-gateway-integration

Conversation

@Brankonymous
Copy link
Copy Markdown
Owner

🚀 Summary

  • Infrastructure Rewrite: Replaced 8 manual proxy controllers (~2,500 LOC) with a YARP (Yet Another Reverse Proxy) config-driven implementation (~40 LOC + JSON config).
  • Containerization: Fully containerized the Gateway with a Dockerfile and integrated it into docker-compose.
  • Feature Parity & Beyond: Added active health checks, request timeouts, and native WebSocket/SignalR support.
  • Video Enhancements: Fixed 500MB upload limits, implemented streaming (range requests), and added thumbnail support.
  • Developer Experience: Introduced dev.sh for one-command environment setup (supporting Docker & Podman).

🛠️ What Changed

Gateway (Glense.Server)

  • YARP Integration: Replaced all manual proxy logic with appsettings.json route configurations.
    • 13 routes across 4 clusters (Account, Video, Donation, Chat + SignalR).
  • Resilience: * Active health checks polling /health every 10s per cluster.
    • 30s default request timeout (extended to 5min for video uploads).
  • Security & Ops: * Runs as non-root user in Docker.
    • Environment-specific config via appsettings.Docker.json.
  • Optimizations: .dockerignore added to exclude DonationService from build context.

Video Service Fixes

  • Streaming: Fixed video range requests using PhysicalFile with enableRangeProcessing.
  • Thumbnails: Added multipart form support for thumbnail uploads and a new /api/videos/{id}/thumbnail endpoint.
  • Capacity: Raised Kestrel max request body limit to 500MB.

Frontend Fixes

  • Upload Form: Requires thumbnail (16:9 validated), uses MUI buttons with preview.
  • Video Components: VideoCard and VideoStream updated to resolve media through the gateway.

Dev Experience

  • dev.sh: New script for start/stop/restart/logs/seed/prune with auto-detection for Docker/Podman.
  • Cleanup: Script kills stale dotnet run processes blocking container ports.
  • seed.sh: Routes through gateway, auto-detects DB containers.

📊 Architecture Comparison

Before vs. After

┌─────────────────────────┐         ┌─────────────────────────┐
│ 8 proxy controllers     │         │ Program.cs (~40 LOC)    │
│ ~2,500 lines of C#      │         │                         │
│ Manual route mapping    │   ──→   │ appsettings.json        │
│ Manual header forwarding│         │ (13 routes, 4 clusters) │
│ No WebSocket support    │         │ WebSocket: built-in     │
│ No health checks        │         │ Health checks: built-in │
│ No Docker support       │         │ Docker: containerized   │
└─────────────────────────┘         └─────────────────────────┘

   
          ┌─────────────────────────────────────────────────────────────┐
          │                 Frontend (React/Vite)                       │
          │                 http://localhost:3000                       │
          └──────────────────────────┬──────────────────────────────────┘
                                     │
                        All requests to http://localhost:5050
                                     │
                                     ▼
          ┌──────────────────────────────────────────────────────────────┐
          │                API Gateway (YARP) :5050                      │
          │                                                              │
          │  Route matching (appsettings.json):                          │
          │                                                              │
          │  /api/auth/** ──→  account-cluster  (:5001)          │
          │  /api/videos/** ──→  video-cluster    (:5002)          │
          │  /api/donation/** ──→  donation-cluster (:5100)          │
          │  /api/chats/** ──→  chat-cluster     (:5004)          │
          │  /hubs/chat           ──→  chat-cluster     (:5004) [WS]     │
          │                                                              │
          │  ┌────────────┐ ┌──────────┐ ┌───────────┐ ┌────────────┐    │
          │  │ Health     │ │  CORS    │ │ Timeouts  │ │  500MB     │    │
          │  │ checks/10s │ │ config   │ │ 30s/5min  │ │ upload     │    │
          │  └────────────┘ └──────────┘ └───────────┘ └────────────┘    │
          └──────┬──────────────┬──────────────┬──────────────┬──────────┘
                 │              │              │              │
                 ▼              ▼              ▼              ▼
          ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
          │  Account   │ │   Video    │ │  Donation  │ │    Chat    │
          │   :5001    │ │   :5002    │ │   :5100    │ │   :5004    │
          └────────────┘ └────────────┘ └────────────┘ └────────────┘

@Brankonymous Brankonymous self-assigned this Mar 29, 2026
@Brankonymous Brankonymous added this to the sprint-3 milestone Mar 29, 2026
@Brankonymous Brankonymous moved this to Code Review in Glense Mar 29, 2026
@Brankonymous Brankonymous merged commit 4f66ef7 into main Mar 29, 2026
2 checks passed
@github-project-automation github-project-automation bot moved this from Code Review to Done in Glense Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants