# adeyosemanputra/pygoat architecture

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

- Interactive diagram: https://gitdiagram.com/adeyosemanputra/pygoat
- Repository: https://github.com/adeyosemanputra/pygoat

## Overview

##### Project type & purpose
– PyGoat is a monolithic Django web application that serves intentionally vulnerable OWASP-Top-Ten security training labs.
– It ships with multiple “apps” (Django modules) under a single codebase (e.g. `introduction/`, `challenge/`), plus a set of self-contained “dockerized labs” each in its own container.
– Extras include a Jupyter-based chatbot (`chatbot/pygoatbot.ipynb`) and CLI utilities (`PyGoatBot.py`, installer/uninstaller scripts).

##### File-structure hints at architecture
Top-level:
- `pygoat/` – the Django project (settings, URLs, WSGI/ASGI)
- `introduction/`, `challenge/` – core Django apps following MVC (models, views, templates, migrations)
- `dockerized_labs/…` – a folder of sub-directories, each with its own Dockerfile, small web app (Flask or Django) and docker-compose.yml (broken_auth_lab, insec_des_lab, etc.)
- `manage.py` & `challenge/management/commands` – management-command pattern for DB population
- `Dockerfile`, `docker-compose.yml`, `Procfile` – containerization and deployment scripts
- `Solutions/`, `docs/` – static markdown for solution guides and developer docs

##### README confirms tech stack & deployment modes
- Django (Python)
- Local run via `manage.py runserver` or Gunicorn behind Heroku (`Procfile`)
- Docker container & Docker Compose support
- Database (configurable, e.g. SQLite locally or PostgreSQL in Docker production)
- No external microservice dependencies beyond Docker labs

## Diagram (Mermaid)

```mermaid
flowchart TB
    User["User"]:::external
    User -->|"HTTP/S"| LB["Load Balancer / Reverse-Proxy"]:::proxy
    click LB "https://github.com/adeyosemanputra/pygoat/tree/master/Procfile"

    LB -->|"80/443"| WebServer["WSGI/ASGI Server"]:::web
    click WebServer "https://github.com/adeyosemanputra/pygoat/blob/master/pygoat/wsgi.py"
    click WebServer "https://github.com/adeyosemanputra/pygoat/blob/master/pygoat/asgi.py"

    subgraph "Django Monolith"
        Monolith["Django Project"]:::backend
        click Monolith "https://github.com/adeyosemanputra/pygoat/blob/master/manage.py"
        click Monolith "https://github.com/adeyosemanputra/pygoat/blob/master/pygoat/settings.py"
        click Monolith "https://github.com/adeyosemanputra/pygoat/blob/master/pygoat/urls.py"

        subgraph "Introduction App"
            Intro["Introduction App"]:::app
            click Intro "https://github.com/adeyosemanputra/pygoat/tree/master/introduction/"
        end

        subgraph "Challenge App"
            ChallengeApp["Challenge App"]:::app
            click ChallengeApp "https://github.com/adeyosemanputra/pygoat/tree/master/challenge/"
        end

        subgraph "Management Commands"
            Cmds["DB Population Commands"]:::cli
            click Cmds "https://github.com/adeyosemanputra/pygoat/tree/master/challenge/management/commands/"
        end

        subgraph "Static Assets & Templates"
            Static["Static Assets / Templates"]:::static
            click Static "https://github.com/adeyosemanputra/pygoat/tree/master/introduction/static/"
            click Static "https://github.com/adeyosemanputra/pygoat/tree/master/challenge/templates/"
            click Static "https://github.com/adeyosemanputra/pygoat/tree/master/introduction/templates/"
        end
    end

    WebServer --> Monolith
    Monolith -->|"ORM Read/Write"| DB[(Database)]:::db
    DB --> Monolith

    LB -->|"static/*"| StaticServer["Static Asset Server / CDN"]:::cdn
    StaticServer --> User

    Monolith -->|"Lab Selection"| ProxyLab["Lab Reverse Proxy"]:::proxy

    subgraph "Dockerized Labs"
        Broken["Broken Auth Lab"]:::micro
        click Broken "https://github.com/adeyosemanputra/pygoat/tree/master/dockerized_labs/broken_auth_lab/"
        Insec["Insec Design Lab"]:::micro
        click Insec "https://github.com/adeyosemanputra/pygoat/tree/master/dockerized_labs/insec_des_lab/"
        Sensitive["Data Exposure Lab"]:::micro
        click Sensitive "https://github.com/adeyosemanputra/pygoat/tree/master/dockerized_labs/sensitive_data_exposure/"
    end

    ProxyLab --> Broken
    ProxyLab --> Insec
    ProxyLab --> Sensitive

    Broken -->|HTTP| User
    Insec -->|HTTP| User
    Sensitive -->|HTTP| User

    User -->|"Chat Request"| Chatbot["Chatbot Service"]:::service
    click Chatbot "https://github.com/adeyosemanputra/pygoat/blob/master/chatbot/pygoatbot.ipynb"
    click Chatbot "https://github.com/adeyosemanputra/pygoat/blob/master/PyGoatBot.py"
    Chatbot --> Monolith

    subgraph "CLI Utilities"
        Installer["Installer/Uninstaller"]:::cli
        click Installer "https://github.com/adeyosemanputra/pygoat/blob/master/installer.sh"
        click Installer "https://github.com/adeyosemanputra/pygoat/blob/master/uninstaller.sh"
        click Installer "https://github.com/adeyosemanputra/pygoat/blob/master/uninstaller.py"
    end

    Installer --> Monolith

    subgraph "Deployment Scripts"
        Deploy["Deployment Scripts"]:::deployment
        click Deploy "https://github.com/adeyosemanputra/pygoat/tree/master/Dockerfile"
        click Deploy "https://github.com/adeyosemanputra/pygoat/blob/master/docker-compose.yml"
        click Deploy "https://github.com/adeyosemanputra/pygoat/tree/master/Procfile"
    end

    Deploy --> LB
    Deploy --> ProxyLab
    Deploy --> DB

    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef proxy fill:#ccf,stroke:#333,stroke-width:1px
    classDef web fill:#ccf,stroke:#333,stroke-width:1px
    classDef backend fill:#cfc,stroke:#333,stroke-width:1px
    classDef app fill:#cff,stroke:#333,stroke-width:1px
    classDef cli fill:#ddd,stroke:#333,stroke-width:1px
    classDef static fill:#fcf,stroke:#333,stroke-width:1px
    classDef cdn fill:#fcf,stroke:#333,stroke-width:1px
    classDef db fill:#afa,stroke:#333,stroke-width:1px
    classDef micro fill:#fdd,stroke:#333,stroke-width:1px
    classDef service fill:#ffd,stroke:#333,stroke-width:1px
    classDef deployment fill:#eef,stroke:#333,stroke-width:1px
```
