# andonny1up/benigan architecture

> Architecture diagram of the GitHub repository andonny1up/benigan, 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/andonny1up/benigan
- Repository: https://github.com/andonny1up/benigan

## Overview

##### Project Type and Purpose
- This is a Django-based full-stack web application (“Software SAS Para la administracion de ganaderia”) packaged with Docker Compose.
- Key features include a web frontend built with Django templates + Tailwind CSS and a PostgreSQL database back end.

##### File Structure
- Top-level files:
- Dockerfile & docker-compose.yml: container definitions
- .env.example: environment variables
- manage.py: Django CLI entry point
- package.json & src/input.css: Node/Tailwind CSS pipeline
- Directories:
- core/: Django project settings (asgi.py, wsgi.py, urls.py, static assets)
- livestockregistry/: Django app containing models.py, views.py, urls.py, templates/, forms.py, tests.py
- Recognize an MVT (Model-View-Template) pattern in Django.

##### README for Architecture Clues
- Services spun up via Docker Compose: web (Django/Python), node (for Tailwind build), db (PostgreSQL)
- Python ≥3.13.5, Node ≥20, Postgres are primary runtimes.

##### Main Components & How They Interact
a. User (Browser)
– Sends HTTP(S) requests, receives HTML/CSS/JS.
b. web Service (Django)
– Core settings & routing (core/urls.py → livestockregistry/urls.py).
– Handles authentication, CRUD of livestock, breeds, parent-child relationships.
– Loads environment variables from .env.
– Renders templates and serves dynamic content.
c. node Service (Tailwind CSS)
– Watches src/input.css, compiles to core/static/css/main.css.
– Rebuilds on file changes.
d. db Service (PostgreSQL)
– Stores all application data via Django ORM migrations.
e. Docker Compose Network
– Connects web, node, and db on an isolated bridge network.

Within the Django web service:
- Requests → URL router → Views
- Views ↔ Models (ORM) ↔ PostgreSQL
- Views → Templates + Static files → Response

##### Architectural Patterns and Design Principles
- MVT (Django’s variant of MVC): clear separation of models, views, templates.
- Containerization: each service in its own Docker container for environment isolation.
- Asset pipeline: Node container dedicated to CSS compilation.
- Single-host orchestration: Docker Compose for development and staging.

##### Putting It All Together
- Small text notes for key technologies: Django, Python, PostgreSQL, Tailwind CSS, Docker.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    Browser["User Browser"]:::external

    %% Environment Variables
    Env[".env (.env.example)"]:::external
    click Env "https://github.com/andonny1up/benigan/blob/main/.env.example"

    %% Docker Compose Boundary
    subgraph "Docker Compose Network"
        direction TB

        %% Web Service
        subgraph "web (Django/Python)" 
            direction TB
            WebDockerfile["Dockerfile"]:::webComp
            click WebDockerfile "https://github.com/andonny1up/benigan/tree/main/Dockerfile"
            Manage["manage.py"]:::webComp
            click Manage "https://github.com/andonny1up/benigan/blob/main/manage.py"
            Env --> WebDockerfile

            subgraph "core/ (Project Settings & Routing)"
                direction TB
                CoreSettings["settings.py"]:::webComp
                click CoreSettings "https://github.com/andonny1up/benigan/blob/main/core/settings.py"
                CoreASGI["asgi.py"]:::webComp
                click CoreASGI "https://github.com/andonny1up/benigan/blob/main/core/asgi.py"
                CoreWSGI["wsgi.py"]:::webComp
                click CoreWSGI "https://github.com/andonny1up/benigan/blob/main/core/wsgi.py"
                CoreURLs["urls.py"]:::webComp
                click CoreURLs "https://github.com/andonny1up/benigan/blob/main/core/urls.py"
            end

            subgraph "livestockregistry/ (App)"
                direction TB
                LRModels["models.py"]:::webComp
                click LRModels "https://github.com/andonny1up/benigan/blob/main/livestockregistry/models.py"
                LRViews["views.py"]:::webComp
                click LRViews "https://github.com/andonny1up/benigan/blob/main/livestockregistry/views.py"
                LRUrls["urls.py"]:::webComp
                click LRUrls "https://github.com/andonny1up/benigan/blob/main/livestockregistry/urls.py"
                LRForms["forms.py"]:::webComp
                click LRForms "https://github.com/andonny1up/benigan/blob/main/livestockregistry/forms.py"
                LRAdmin["admin.py"]:::webComp
                click LRAdmin "https://github.com/andonny1up/benigan/blob/main/livestockregistry/admin.py"
                LRTests["tests.py"]:::webComp
                click LRTests "https://github.com/andonny1up/benigan/blob/main/livestockregistry/tests.py"
            end

            subgraph "Templates"
                direction TB
                TBase["base.html"]:::webComp
                click TBase "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/base.html"
                TLogin["authentication/login.html"]:::webComp
                click TLogin "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/authentication/login.html"
                TBreedForm["breed/breed_form.html"]:::webComp
                click TBreedForm "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/breed/breed_form.html"
                TBreedList["breed/breed_list.html"]:::webComp
                click TBreedList "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/breed/breed_list.html"
                TBreedDelete["breed/breed_confirm_delete.html"]:::webComp
                click TBreedDelete "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/breed/breed_confirm_delete.html"
                TLivestockList["livestock/livestock_list.html"]:::webComp
                click TLivestockList "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/livestock/livestock_list.html"
                TLivestockDetail["livestock/livestock_detail.html"]:::webComp
                click TLivestockDetail "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/livestock/livestock_detail.html"
                TLivestockForm["livestock/livestock_form.html"]:::webComp
                click TLivestockForm "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/livestock/livestock_form.html"
                TParentList["parentchild/parentchild_list.html"]:::webComp
                click TParentList "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/parentchild/parentchild_list.html"
                TParentForm["parentchild/parentchild_form.html"]:::webComp
                click TParentForm "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/parentchild/parentchild_form.html"
                TDashboard["dashboard.html"]:::webComp
                click TDashboard "https://github.com/andonny1up/benigan/blob/main/livestockregistry/templates/dashboard.html"
            end

            subgraph "Static Assets"
                direction TB
                CoreStatic["core/static/core/"]:::webComp
                click CoreStatic "https://github.com/andonny1up/benigan/tree/main/core/static/core/"
            end
        end

        %% Node Service
        subgraph "node (Tailwind CSS builder)"
            direction TB
            PackageJSON["package.json"]:::nodeComp
            click PackageJSON "https://github.com/andonny1up/benigan/blob/main/package.json"
            PackageLock["package-lock.json"]:::nodeComp
            click PackageLock "https://github.com/andonny1up/benigan/blob/main/package-lock.json"
            InputCSS["src/input.css"]:::nodeComp
            click InputCSS "https://github.com/andonny1up/benigan/blob/main/src/input.css"
            InputCSS --> CoreStatic
        end

        %% Database Service
        subgraph "db (PostgreSQL)"
            direction TB
            DBM1["0001_initial.py"]:::dbComp
            click DBM1 "https://github.com/andonny1up/benigan/blob/main/livestockregistry/migrations/0001_initial.py"
            DBM2["0002_profile_livestock_image_property_latitude_and_more.py"]:::dbComp
            click DBM2 "https://github.com/andonny1up/benigan/blob/main/livestockregistry/migrations/0002_profile_livestock_image_property_latitude_and_more.py"
            DBM3["0003_rename_direccion_profile_address_and_more.py"]:::dbComp
            click DBM3 "https://github.com/andonny1up/benigan/blob/main/livestockregistry/migrations/0003_rename_direccion_profile_address_and_more.py"
            DBM4["0004_parentchild_insemination_type_and_more.py"]:::dbComp
            click DBM4 "https://github.com/andonny1up/benigan/blob/main/livestockregistry/migrations/0004_parentchild_insemination_type_and_more.py"
        end
    end

    %% Connections
    Browser -->|"HTTP/S Request"| WebDockerfile
    WebDockerfile -->|"Reads env vars"| Manage
    Manage -->|"Routes request"| CoreURLs
    CoreURLs -->|"Includes"| LRUrls
    CoreASGI -->|"ASGI Server"| WebDockerfile
    CoreWSGI -->|"WSGI Server"| WebDockerfile
    Manage -->|"Interacts via ORM"| DBM1
    nodeComp --> CoreStatic
    WebDockerfile -->|"SQL over TCP (5432)"| DBM1

    %% Styling
    classDef webComp fill:#D0E8FF,stroke:#93C2E0;
    classDef nodeComp fill:#FFF5B1,stroke:#F2DA6D;
    classDef dbComp fill:#BFFFB1,stroke:#8FDB82;
    classDef external fill:#E0E0E0,stroke:#CCCCCC;
```
