# ecotrust/wcoa architecture

> Architecture diagram of the GitHub repository ecotrust/wcoa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ecotrust/wcoa
- Repository: https://github.com/ecotrust/wcoa

## Overview

##### Main Components

a) Frontend Layer:
- Wagtail CMS interface
- Public-facing web portal
- Static assets (CSS, JS, images)
- Template system (Django templates)

b) Backend Layer:
- Django application (wcoa)
- Wagtail CMS core
- Database models and migrations
- Authentication system

c) Infrastructure Layer:
- Nginx web server
- uWSGI application server
- PostgreSQL database with PostGIS extension
- Redis cache
- Static/Media file storage
- SSL/TLS (Certbot)

**[Client Layer]**
- ↓ HTTPS
**[Load Balancer/Reverse Proxy]**
- ↓
**[Application Layer]**
- ↓
**[Data Layer]**

##### Component Relationships

- Client browsers → Nginx (HTTPS/443)
- Nginx → uWSGI (Unix socket)
- uWSGI → Django application
- Django → PostgreSQL/PostGIS
- Django → Redis cache
- Django → File system (media/static)

##### Specific Implementation Details

Key architectural elements:
**[Browser] → HTTPS → [Nginx + SSL]**
- ↓
**[Static Files] ← [Django + Wagtail CMS] → [uWSGI]**
- ↓
- [PostgreSQL + PostGIS]
- ↓
- [Redis Cache]

##### Additional Notes

- Separation between development and production environments
- Backup systems and monitoring (Munin)
- Unattended upgrade paths
- Content management workflow through Wagtail

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser[Web Browser]
    end

    subgraph "Web Server Layer"
        Nginx["Nginx Web Server"]:::webserver
        SSL["SSL/TLS (Certbot)"]:::security
    end

    subgraph "Application Layer"
        uWSGI["uWSGI Server"]:::appserver
        Django["Django + Wagtail CMS"]:::appserver
        Auth["Authentication System"]:::auth
        Static["Static Assets"]:::storage
        Templates["Template System"]:::templates
    end

    subgraph "Data Layer"
        Postgres[("PostgreSQL + PostGIS")]:::database
        Redis[("Redis Cache")]:::cache
        Media["Media Storage"]:::storage
        Backup["Backup System"]:::maintenance
    end

    Browser --> |HTTPS/443| Nginx
    Nginx --> |Unix Socket| uWSGI
    uWSGI --> Django
    Django --> Postgres
    Django --> Redis
    Django --> Static
    Django --> Templates
    Django --> Auth
    Django --> Media
    Backup --> Postgres
    Nginx --> Static
    Nginx --> Media
    SSL --> Nginx

    %% Click Events
    click Django "https://github.com/Ecotrust/wcoa/tree/main/wcoa/"
    click Auth "https://github.com/Ecotrust/wcoa/tree/main/wcoa/templates/wcoa/accounts/"
    click Static "https://github.com/Ecotrust/wcoa/tree/main/wcoa/static/wcoa/"
    click Templates "https://github.com/Ecotrust/wcoa/tree/main/wcoa/templates/"
    click Media "https://github.com/Ecotrust/wcoa/tree/main/media/"
    click Backup "https://github.com/Ecotrust/wcoa/blob/main/deploy/backup.sh"
    click Nginx "https://github.com/Ecotrust/wcoa/tree/main/deploy/nginx_config"
    click uWSGI "https://github.com/Ecotrust/wcoa/blob/main/deploy/wcoa.ini"

    %% Styles
    classDef webserver fill:#3498db
    classDef security fill:#e74c3c
    classDef appserver fill:#2ecc71
    classDef database fill:#f1c40f
    classDef cache fill:#e67e22
    classDef storage fill:#9b59b6
    classDef auth fill:#34495e
    classDef templates fill:#1abc9c
    classDef maintenance fill:#95a5a6

    %% Legend
    subgraph Legend
        L1["Web Server"]:::webserver
        L2["Security"]:::security
        L3["App Server"]:::appserver
        L4["Database"]:::database
        L5["Cache"]:::cache
        L6["Storage"]:::storage
        L7["Auth"]:::auth
        L8["Templates"]:::templates
        L9["Maintenance"]:::maintenance
    end
```
