# microsoftdocs/pipelines-python-django architecture

> Architecture diagram of the GitHub repository microsoftdocs/pipelines-python-django, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoftdocs/pipelines-python-django
- Repository: https://github.com/microsoftdocs/pipelines-python-django

## Overview

##### Project type and purpose
- This is a simple, monolithic Django web-application written in Python.
- Its primary purpose is to serve as a sample app for demonstrating Azure Pipelines: building, testing, containerizing (via Docker), and pushing to Docker Hub or Azure Container Registry.

##### File structure
- Top-level files:
- Dockerfile – container image definition
- azure-pipelines.yml / azure-pipelines.docker.yml / azure-pipelines.acr.yml – CI/CD pipeline definitions
- manage.py – Django management CLI
- test_site.py – test harness for the application
- Folder “helloworld”: contains a minimal Django MVC app
- settings.py – configuration
- urls.py – URL routing
- wsgi.py – WSGI entrypoint
- __init__.py – package marker

##### Key insights from README
- Demonstrates three Azure Pipelines scenarios:
- Plain build/test (Python)
- Build and push Docker image to Docker Hub
- Build and push Docker image to Azure Container Registry
- No external database is explicitly defined here (the sample likely uses Django’s default SQLite or an in-memory DB for demo purposes).

##### Main components
a. Developer & Git repository
b. Azure DevOps – Pipelines (YAML):
- Build & test stage (runs manage.py tests or test_site.py)
- Docker build stage (uses Dockerfile)
- Push stage (to Docker Hub or ACR)
c. Container registry(s): Docker Hub / Azure Container Registry
d. Runtime environment: Azure Web App / Azure Kubernetes Service (AKS) or any Docker-compatible host
e. Application internals:
- Django MVC layers (URLs → Views → Templates / Models)
- WSGI server process

##### Relationships and interactions
- Developer commits code → triggers Azure Pipelines
- Pipeline fetches repo → runs tests via test_site.py / manage.py
- On success → Dockerfile builds container image
- Image is tagged & pushed to chosen registry (Docker Hub or ACR)
- Deployment step (not in sample but implied) pulls image from registry → runs on Azure host

##### Architectural patterns and design principles
- Monolithic MVC web application (Django)
- CI/CD pipeline as code (YAML)
- Containerization for environment consistency
- “Pipeline → Registry → Host” deployment flow

##### Technologies, frameworks, libraries
- Python 3.x, Django framework
- Docker (containerization)
- Azure DevOps Pipelines (YAML)
- Azure Container Registry / Docker Hub
- WSGI server (built into Django wsgi.py)

##### Detail level
- Inside the “Django App” container, list key sub-components: settings, URL router, WSGI entrypoint

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Code Layer
    subgraph "Source Code" 
        SRC_GIT["Developer & Git Repository"]:::code
        Gitignore[".gitignore"]:::code
        Readme["README.md"]:::code
        License["LICENSE"]:::code
        LicenseCode["LICENSE-CODE"]:::code
    end

    %% CI/CD Pipeline
    subgraph "Azure DevOps Pipelines (YAML)" 
        Pipelines["Azure Pipelines"]:::cicd
        AZYML["azure-pipelines.yml"]:::cicd
        AZDOCKER["azure-pipelines.docker.yml"]:::cicd
        AZACR["azure-pipelines.acr.yml"]:::cicd
    end

    %% Build & Test Stage
    subgraph "Build & Test Stage" 
        Manage["manage.py"]:::code
        TestSite["test_site.py"]:::code
        BuildTest["Build & Test"]:::cicd
    end

    %% Docker Build Stage
    subgraph "Docker Build Stage" 
        Dockerfile["Dockerfile"]:::cicd
        Dockerignore[".dockerignore"]:::cicd
        DockerBuild["Docker Build"]:::cicd
    end

    %% Push Stage
    subgraph "Push to Registry" 
        PushStage["Push Image"]:::cicd
        DockerHub["Docker Hub"]:::registry
        ACR["Azure Container Registry"]:::registry
    end

    %% Runtime Environment
    subgraph "Runtime Environment" 
        Host["Azure Web App / AKS"]:::host
        AppContainer["Django App Container"]:::app
        subgraph "Django MVC App"
            Init["__init__.py"]:::app
            Settings["settings.py"]:::app
            Urls["urls.py"]:::app
            WSGI["wsgi.py"]:::app
        end
    end

    %% Relationships
    SRC_GIT -->|commits code| Pipelines
    Pipelines -->|includes definitions| AZYML
    Pipelines --> AZDOCKER
    Pipelines --> AZACR

    Pipelines --> BuildTest
    BuildTest --> Manage
    BuildTest --> TestSite

    BuildTest --> DockerBuild
    DockerBuild --> Dockerfile
    DockerBuild --> Dockerignore

    DockerBuild --> PushStage
    PushStage --> DockerHub
    PushStage --> ACR

    ACR --> Host
    DockerHub --> Host
    Host --> AppContainer
    AppContainer --> Init
    AppContainer --> Settings
    AppContainer --> Urls
    AppContainer --> WSGI

    %% Click Events
    click Gitignore "https://github.com/microsoftdocs/pipelines-python-django/blob/master/.gitignore"
    click Readme "https://github.com/microsoftdocs/pipelines-python-django/blob/master/README.md"
    click AZYML "https://github.com/microsoftdocs/pipelines-python-django/blob/master/azure-pipelines.yml"
    click AZDOCKER "https://github.com/microsoftdocs/pipelines-python-django/blob/master/azure-pipelines.docker.yml"
    click AZACR "https://github.com/microsoftdocs/pipelines-python-django/blob/master/azure-pipelines.acr.yml"
    click Manage "https://github.com/microsoftdocs/pipelines-python-django/blob/master/manage.py"
    click TestSite "https://github.com/microsoftdocs/pipelines-python-django/blob/master/test_site.py"
    click Dockerfile "https://github.com/microsoftdocs/pipelines-python-django/tree/master/Dockerfile"
    click Dockerignore "https://github.com/microsoftdocs/pipelines-python-django/blob/master/.dockerignore"
    click Init "https://github.com/microsoftdocs/pipelines-python-django/blob/master/helloworld/__init__.py"
    click Settings "https://github.com/microsoftdocs/pipelines-python-django/blob/master/helloworld/settings.py"
    click Urls "https://github.com/microsoftdocs/pipelines-python-django/blob/master/helloworld/urls.py"
    click WSGI "https://github.com/microsoftdocs/pipelines-python-django/blob/master/helloworld/wsgi.py"
    click License "https://github.com/microsoftdocs/pipelines-python-django/tree/master/LICENSE"
    click LicenseCode "https://github.com/microsoftdocs/pipelines-python-django/tree/master/LICENSE-CODE"

    %% Styles
    classDef code fill:#cce5ff,stroke:#004085,color:#004085
    classDef cicd fill:#d4edda,stroke:#155724,color:#155724
    classDef registry fill:#fff3cd,stroke:#856404,color:#856404
    classDef host fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef app fill:#f8d7da,stroke:#721c24,color:#721c24
```
