How freedium-cfd/web works
Main components
• Frontend – Primarily in “new-web” (with Svelte components) handling client-side rendering and interactions.
• Reverse Proxy – Caddy is configured (under the “caddy” folder) to route HTTP/S traffic.
• Database Layer – There is a PostgreSQL instance (as indicated in the README and configuration files in “docker-compose”), and a Dragonfly-based key value store (mentioned in the stack as “redis_service”). There is also a separate “database-lib” used for database operations.
• Proxy Layer – This includes HAProxy (found in “proxy-balancer”) for load balancing and two WGCF clusters (using “wgcf” and the Dante configuration) to serve as Cloudflare WARP proxies.
• Analytics – Plausible is included as a service along with its own databases (ClickHouse and a PostgreSQL instance for Plausible).
Relationships and interactions
• The Main Application depends on the Reverse Proxy. The Caddy container is used to expose the application externally (with ports such as 6752).
• The backend web service (Freedium’s API) communicates with the Database Layer for content, while also possibly interacting with Redis/Dragonfly for caching.
• There are data flows from the Proxy Layer (HAProxy and WGCF clusters) to the Main Application; these components ensure proper internet routing, load balancing, and secure access.
• The Analytics service (Plausible) is connected with its databases to record user interactions.
• Inter-service Docker networks (like freedium_net, caddy_net, plausible_net) are used to structure communication between containers.
Architectural patterns & design principles
• Dockerized Microservices Architecture: Each service (backend, frontend, database, proxies) runs in its own container and is orchestrated via Docker Compose. This decomposition provides clear separation of responsibilities.
• API Gateway/Reverse Proxy Pattern: Caddy acts as the entry point into the system.
• Modular Separation: You have distinct modules for API, frontend, analytics, and proxy layers.
Relevant technologies, frameworks, and libraries
• Python, FastAPI/Unicorn for the backend.
• Jinja2 templating and Tailwind CSS (and planned Svelte frontend rewrite) for the UI.
• PostgreSQL, Dragonfly (acting as Redis/Memcached compatible database).
• Caddy, HAProxy, WGCF (Cloudflare WARP) for networking and proxy management.
• Analytics with Plausible and ClickHouse.
• Docker and Docker Compose for container orchestration.
• Each major component is clearly labeled (e.g., “Freedium API”, “Frontend UI”, “Caddy Reverse Proxy”, “HAProxy Load Balancer”, “WGCF Cluster 1/2”, “PostgreSQL DB”, “Dragonfly/Redis”, “Plausible Analytics”).
– Main Application → Database Layer
– Caddy ←→ Main Application
– HAProxy ←→ WGCF clusters → Main Application
– Frontend → API endpoints
– Analytics service → Analytics databases
• External access points with port connections (e.g., external port 6752 for Caddy, 7080 for the API service, etc.)
• Labels for Docker networks to show how inter-container communication is structured.
• Within the “Main Application” cluster, include the Freedium API (from “freedium-library” and “web”), indicating internal modules (API endpoints, business logic, etc.).
• Beside it, the “Frontend” cluster could note the “new-web” UI, communicating with the backend.
• Finally, the “Analytics” block should include Plausible and its databases.
• A “Utility” section for any extra service (like autoheal) that maintains service health.