Skip to content

Infrastructure & Self-Hosting Architecture

Infrastructure & Self-Hosting Architecture

Overview

Learnille utilizes a self-hosted infrastructure architecture engineered for cost efficiency, operational autonomy, and low latency. Media and file assets are stored on Cloudflare R2 (leveraging zero-egress bandwidth fees), while application observability, logging, and APM are centralized in New Relic.


πŸ— Infrastructure Overview

[ Cloudflare CDN / DNS ]
|
HTTPS / WAF Proxy
|
v
+-------------------------------+
| Self-Hosted Ingress Proxy |
| (Nginx / Caddy / Traefik) |
+---------------+---------------+
|
+----------------------+----------------------+
| |
v v
+----------------------------+ +----------------------------+
| NestJS Server Container | | Vite React Portals (SPA) |
| (Node.js / PM2) | | (Student, Admin, Instructor|
+--------------+-------------+ +----------------------------+
|
+-----------------+-----------------+-----------------+-----------------+
| | | | |
v v v v v
+-----------+ +-----------+ +-----------+ +-----------+ +---------------+
|Self-Hosted| |Self-Hosted| | Cloudflare| | Self-Host | | New Relic APM |
| PostgreSQL| | Redis | | R2 S3 | | OpenSearch| | & Log Engine |
| (Data) | | (BullMQ) | | (Storage) | | (Search) | | (Observability|
+-----------+ +-----------+ +-----------+ +-----------+ +---------------+

πŸ›  Self-Hosted Stack Components

1. Compute & Application Hosting

  • Server Deployment: Self-hosted Linux instances (Hetzner / DigitalOcean / Bare Metal) managed via Docker Compose or PM2 process manager.
  • Reverse Proxy / SSL: Nginx / Caddy handling SSL/TLS termination (Let’s Encrypt), rate-limiting, and proxying requests to NestJS server (localhost:3000) and WebSocket services.

2. Primary Database & Storage

  • PostgreSQL: Self-hosted PostgreSQL 15+ instance with automated pg_dump backups to Cloudflare R2.
  • Cloudflare R2 Object Storage: S3 API-compatible storage used for storing course video files, thumbnails, document attachments, and PDF certificates without egress data transfer charges.
  • MinIO: Local development fallback for offline S3 testing.

3. Queue & Real-Time Middleware

  • Redis: Self-hosted Redis instance backing BullMQ worker queues (email delivery, outbox events) and API caching.
  • InstantDB & Soketi: Self-hosted Soketi instance for WebSocket push notifications and InstantDB for real-time room state.

4. Observability & Logging

  • New Relic APM: Application Performance Monitoring agent integrated into the NestJS backend to track API endpoint latencies, transaction traces, and database query profiling.
  • New Relic Log Management: Winston logger sending structured JSON logs directly to New Relic for centralized log searching and alerting.
  • Sentry: Real-time frontend and backend exception tracking.

πŸ”’ Security & Backup Policies

  • Backups: Daily automated database snapshots compressed and stored in Cloudflare R2 bucket with 30-day lifecycle retention.
  • Firewall & Access: Port 22 (SSH) restricted to authorized admin IPs / SSH keys; public ingress restricted to ports 80/443.