# freedomofpress/securedrop architecture

> Architecture diagram of the GitHub repository freedomofpress/securedrop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/freedomofpress/securedrop
- Repository: https://github.com/freedomofpress/securedrop

## Overview

##### Main Components

a. User-Facing Interfaces:
- Source Interface (port 8080) - For whistleblowers
- Journalist Interface (port 8081) - For media organization staff
- Admin Interface - For system administration

b. Server Components:
- Application Server
- Apache Web Server
- Python Flask Applications
- Redis Queue Worker
- Database (SQLite/Alembic for migrations)
- Monitor Server
- OSSEC (Security monitoring)
- Postfix (Email alerts)

c. Security Components:
- Tor Hidden Services
- GPG Encryption System
- Two-Factor Authentication
- AppArmor Profiles

##### Key Relationships

a. Data Flow:
- Source → Tor Network → Source Interface → Encrypted Storage
- Journalist → Tor Network → Journalist Interface → Encrypted Storage
- Monitor Server → Admin Email Alerts
- Worker Processes → Database/File Operations

b. Security Boundaries:
- Network Isolation
- Encryption Boundaries
- Access Control Points

##### Specific Implementation Details

**[Public Internet Zone]**
- ↓ (Tor Network)
**[Network Boundary]**
- ↓
**[Application Zone]**
- Source Interface (Flask App)
- Journalist Interface (Flask App)
- Admin Interface
- ↓
**[Storage Zone]**
- Encrypted Submissions
- Database
- GPG Keys
**[Monitoring Zone]**
- OSSEC
- Postfix

##### Critical Subsystems to Highlight

- Authentication System
- Two-factor authentication
- Session management
- Encryption Pipeline
- GPG encryption for submissions
- Storage encryption
- Queue Management
- Redis for background jobs
- Worker processes
- Monitoring System
- OSSEC integration
- Alert generation

##### Implementation Notes

Technical details such as:
- Python/Flask backend
- SQLite database
- Redis queue
- Apache web server
- Tor hidden services
- System dependencies

- Layered visualization
- Security notation
- Clear connection routing
- Export in high resolution
- Collaborative editing

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef public fill:#AEC6CF,stroke:#333
    classDef app fill:#98FB98,stroke:#333
    classDef security fill:#FFB6C1,stroke:#333
    classDef monitor fill:#FFE4B5,stroke:#333
    classDef database fill:#DEB887,stroke:#333
    classDef server fill:#E6E6FA,stroke:#333

    %% Public Internet Zone
    subgraph Internet
        S[Source]
        J[Journalist]
        A[Admin]
    end

    %% Network Boundary / Tor
    TOR["Tor Hidden Services"]:::security
    click TOR "https://github.com/freedomofpress/securedrop/tree/develop/install_files/ansible-base/roles/tor-hidden-services/"

    %% Application Zone
    subgraph AppZone
        SI["Source Interface\n(Flask App)"]:::app
        JI["Journalist Interface\n(Flask App)"]:::app
        AI["Admin Interface"]:::app
        APA["Apache Web Server"]:::server
        TFA["2FA System"]:::security
    end
    click SI "https://github.com/freedomofpress/securedrop/tree/develop/securedrop/source_app/"
    click JI "https://github.com/freedomofpress/securedrop/tree/develop/securedrop/journalist_app/"
    click AI "https://github.com/freedomofpress/securedrop/tree/develop/admin/"
    click APA "https://github.com/freedomofpress/securedrop/blob/develop/install_files/ansible-base/roles/app/files/apache2.conf"
    click TFA "https://github.com/freedomofpress/securedrop/blob/develop/securedrop/two_factor.py"

    %% Storage & Processing Zone
    subgraph Storage
        DB[(Database)]:::database
        DBM["DB Migrations"]:::database
        ES["Encrypted Storage"]:::security
        GPG["GPG Encryption"]:::security
        RQ["Redis Queue"]:::app
        QW["Queue Worker"]:::app
        AP["AppArmor Profiles"]:::security
    end
    click DB "https://github.com/freedomofpress/securedrop/blob/develop/securedrop/db.py"
    click DBM "https://github.com/freedomofpress/securedrop/tree/develop/securedrop/alembic/"
    click GPG "https://github.com/freedomofpress/securedrop/blob/develop/securedrop/encryption.py"
    click QW "https://github.com/freedomofpress/securedrop/blob/develop/securedrop/worker.py"
    click RQ "https://github.com/freedomofpress/securedrop/blob/develop/securedrop/worker.py"
    click AP "https://github.com/freedomofpress/securedrop/tree/develop/securedrop/debian/app-code/etc/apparmor.d/"

    %% Monitoring Zone
    subgraph Monitoring
        OSSEC["OSSEC Security\nMonitoring"]:::monitor
        PF["Postfix Email\nAlerts"]:::monitor
        SM["System Monitor"]:::monitor
    end
    click OSSEC "https://github.com/freedomofpress/securedrop/tree/develop/install_files/ansible-base/roles/ossec/"
    click PF "https://github.com/freedomofpress/securedrop/tree/develop/install_files/ansible-base/roles/postfix/"
    click SM "https://github.com/freedomofpress/securedrop/tree/develop/install_files/ansible-base/roles/monitor/"

    %% Connections
    S --> TOR
    J --> TOR
    A --> TOR
    TOR --> SI
    TOR --> JI
    TOR --> AI
    SI --> APA
    JI --> APA
    AI --> APA
    APA --> TFA
    TFA --> DB
    TFA --> ES
    ES --> GPG
    DB --> DBM
    APA --> RQ
    RQ --> QW
    QW --> DB
    QW --> ES
    AP -.-> |Protects| AppZone
    AP -.-> |Protects| Storage
    OSSEC -.-> |Monitors| AppZone
    OSSEC -.-> |Monitors| Storage
    OSSEC --> PF
    SM -.-> |Monitors| OSSEC

    %% Legend
    subgraph Legend
        L1[User Interface]:::public
        L2[Application Component]:::app
        L3[Security Component]:::security
        L4[Monitoring Component]:::monitor
        L5[(Database Component)]:::database
        L6[Server Component]:::server
    end
```
