> ## Documentation Index
> Fetch the complete documentation index at: https://ihub.learnille.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Infrastructure & Self-Hosting Architecture

> Migrated from the previous Learnille internal documentation hub

## Overview

Learnille uses a hybrid production architecture. The backend application runs through Dokploy, PostgreSQL is hosted on Neon, Redis is hosted on Redis Cloud, OpenSearch is hosted on Aiven, InstantDB is self-hosted, and media and file assets are stored on Cloudflare R2. 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 / Dokploy)   |                 | (Student, Admin, Instructor|
       +--------------+-------------+                 +----------------------------+
                      |
    +-----------------+-----------------+-----------------+-----------------+
    |                 |                 |                 |                 |
    v                 v                 v                 v                 v
+-----------+   +-----------+   +-----------+   +-----------+   +---------------+
|   Neon    |   |Redis Cloud|   | Cloudflare|   | Self-Host |   | New Relic APM |
| PostgreSQL|   |   Redis   |   |   R2 S3   |   | InstantDB |   | & Log Engine  |
|  (Data)   |   | (BullMQ)  |   | (Storage) |   | (Realtime)|   | (Observability|
+-----------+   +-----------+   +-----------+   +-----------+   +---------------+
```

***

## 🛠 Self-Hosted Stack Components

### 1. Compute & Application Hosting

* **Server Deployment**: The independent `server` package is deployed as a Docker application through Dokploy.
* **Reverse Proxy / SSL**: Dokploy and its ingress layer handle service routing and TLS termination for the production API.

### 2. Primary Database & Storage

* **PostgreSQL**: Neon for production; Aiven for development and non-production environments.
* **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**: Redis Cloud backing BullMQ worker queues (email delivery, outbox events), throttling, sessions, and API caching.
* **OpenSearch**: Aiven OpenSearch for search and indexing.
* **InstantDB & Soketi**: Self-hosted InstantDB for real-time room state and Soketi for WebSocket push notifications.

### 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.