# l4rm4nd/securethejuice architecture

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

- Interactive diagram: https://gitdiagram.com/l4rm4nd/securethejuice
- Repository: https://github.com/l4rm4nd/securethejuice

## Overview

- External Clients: Represent users (and potential attackers) connecting via a browser or SSH.
- Traefik Reverse Proxy: Acts as the entry point, terminating SSL, managing HTTP challenges, and routing requests based on domain names (e.g., juice.fictive.local, auth.fictive.local, traefik.fictive.local).
- Authelia: The authentication/authorization service that handles SSO – it uses its configuration files under authelia/config.
- OWASP Juice Shop: The main web application that requires pre-authentication via Authelia.
- Cowrie SSH Honeypot: A deceptive service set to capture SSH intruder activity, with configuration files found in the cowrie directory.

##### Relationships and Interactions Between Components
- Traefik routes web traffic based on the requested subdomain:
- Requests for juice.fictive.local are directed to the Juice Shop container.
- Requests for auth.fictive.local go to the Authelia container.
- Requests for traefik.fictive.local are routed to Traefik’s dashboard (with access restrictions).
- Authelia sits in front of Juice Shop so that once a user is authenticated via Authelia, they can access the application.

##### Architectural Patterns and Design Principles
- Reverse Proxy/Security Gateway: Traefik is central to traffic management, using SSL/TLS termination and routing logic based on host headers.
- Single-Sign-On (SSO) Mechanism: The authentication flow through Authelia should be clearly indicated.
- Honeypot Strategy: Cowrie is specifically set up to act as a decoy, capturing unauthorized SSH attempts.
- Use of Configuration Files: Emphasize that customization is done via config files (e.g., authelia/config/configuration.yml, cowrie/config.cfg, traefik/fileConfig.yml).

##### Relevant Technologies and Frameworks
- Docker and Docker Compose (see docker-compose.yml) to describe container orchestration.
- Traefik (for SSL reverse proxy).
- Authelia (for SSO and access control).
- OWASP Juice Shop (the target web app).
- Cowrie (for SSH honeypot deployment).

##### Elements
- All the key components (Traefik, Authelia, Juice Shop, Cowrie, and the Docker infrastructure) should be clearly labeled.
- Traffic incoming from the internet to Traefik.
- Authenticated web traffic routed from Traefik to Authelia and then to Juice Shop.
- A separate path mapping SSH connections directly to Cowrie on port 2222.
- Configuration dependencies in your annotations (e.g., adjustments in traefik/fileConfig.yml, authelia/configuration.yml, and cowrie config files).

This systematic approach to diagramming will ensure that you capture all the essential architectural elements of “SecureTheJuice” accurately.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    Clients["External Clients"]:::external

    %% Docker Compose node indicating container orchestration
    DC_DOCKER["Docker Compose"]:::docker

    %% Container Infrastructure Subgraph
    subgraph "Container Infrastructure"
        direction TB
        T_TRAEFIK["Traefik Reverse Proxy"]:::internal
        A_AUTHELIA["Authelia (SSO)"]:::internal
        JS_JUICE["OWASP Juice Shop"]:::internal
        C_COWRIE["Cowrie SSH Honeypot"]:::internal
    end

    %% External Web Traffic Flow
    Clients -->|"TCP/80_TCP/443"| T_TRAEFIK
    T_TRAEFIK -->|"juice.fictive.local"| JS_JUICE
    T_TRAEFIK -->|"auth.fictive.local"| A_AUTHELIA
    A_AUTHELIA -->|"authenticated"| JS_JUICE

    %% External SSH Traffic Flow
    Clients -->|"SSH_TCP/2222"| C_COWRIE

    %% Docker Compose orchestrates all container services
    DC_DOCKER --- T_TRAEFIK
    DC_DOCKER --- A_AUTHELIA
    DC_DOCKER --- JS_JUICE
    DC_DOCKER --- C_COWRIE

    %% Click Events for configuration files
    click T_TRAEFIK "https://github.com/l4rm4nd/securethejuice/blob/main/traefik/fileConfig.yml"
    click A_AUTHELIA "https://github.com/l4rm4nd/securethejuice/blob/main/authelia/config/configuration.yml"
    click A_AUTHELIA "https://github.com/l4rm4nd/securethejuice/blob/main/authelia/config/users_database.yml"
    click C_COWRIE "https://github.com/l4rm4nd/securethejuice/blob/main/cowrie/config.cfg"
    click C_COWRIE "https://github.com/l4rm4nd/securethejuice/blob/main/cowrie/users.txt"
    click DC_DOCKER "https://github.com/l4rm4nd/securethejuice/blob/main/docker-compose.yml"

    %% Styles
    classDef external fill:#FFCC00,stroke:#000,stroke-width:2px;
    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef docker fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
