# caio-machado-dev/growup_portodigital_bonsae architecture

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

- Interactive diagram: https://gitdiagram.com/caio-machado-dev/growup_portodigital_bonsae
- Repository: https://github.com/caio-machado-dev/growup_portodigital_bonsae

## Overview

##### Project type and purpose
- This is a Django-based full-stack web application named “GrowUP Porto Digital – Bonsae.”
- It provides a form interface (in `preCorrecao/templates`) backed by a SQLite database (`db.sqlite3`), with client–side scripts under `preCorrecao/static/javascript`.

##### File structure
- Top-level “setup” folder: the Django project container (`settings.py`, `urls.py`, `wsgi.py`, `asgi.py`).
- Top-level “preCorrecao” folder: the primary Django app, with `models.py`, `views.py`, `admin.py`, migrations, static assets, and templates.
- Procfile at root: indicates deployment on a platform like Heroku using a WSGI server.
- `requirements.txt`: enumerates Python dependencies.
- `manage.py`: Django CLI entrypoint.

##### README for technical stack
- Python + Django framework.
- SQLite3 as the development database.
- Heroku (Procfile) for deployment.
- Frontend uses HTML templates, JavaScript modules (`adicionarFundamentacao.js`,  `dadosCampos.js`, `limparCampos.js`, `sweetAlert.js`), and static JSON data (`estados-cidades.json`).

##### Main components
a. Client Side
- Web Browser
- Static assets: HTML templates, CSS (if any), JavaScript modules, JSON files
b. Application Server
- Heroku Dyno (or local `runserver`) hosting a WSGI/ASGI server
- Django core:
- Views (`preCorrecao/views.py`)
- Models (`preCorrecao/models.py`)
- Admin interface (`preCorrecao/admin.py`)
c. Database
- SQLite (`db.sqlite3`)
d. Deployment & Tooling
- Git (version control)
- Python Virtual Environment `.venv`
- Procfile → Gunicorn server configuration

##### Relationships and data flows
- Browser → HTTP Request → WSGI/ASGI Server → Django URL router → View function
- View ↔ Database ORM (CRUD operations on models)
- View → Template renderer → HTML + JavaScript → HTTP Response → Browser
- Browser loads static files (JS, JSON) via static URL endpoints served by Django’s `collectstatic` or a CDN in production.

##### Architectural patterns & design principles
- MVC (Model–View–Template variant in Django)
- Separation of concerns:
- Models handle data
- Views process requests and orchestrate data flow
- Templates define presentation
- Static modules handle client-side logic
- One-app structure keeps related code (models, views, templates, static) together.

##### Elements
- From Browser to Heroku/Gunicorn (HTTP request)
- From Gunicorn to Django URL router (WSGI socket)
- From URL router to View (function call)
- From View to Database (ORM query) and back
- From View to Template renderer (data → HTML) and back
- From Browser to Static asset server (JS/JSON fetch)
- Optional: annotate environment setup (virtualenv, migrations via `manage.py migrate`).

##### Final advice
- Real-world deployment: include Heroku dyno, or local dev server if relevant.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Browser["Web Browser"]:::client
        Templates["HTML Templates"]:::client
        JSModules["JavaScript Modules"]:::client
        JSONData["Static JSON Data"]:::client
    end

    %% Web Server Layer
    subgraph "Web Server" 
        direction TB
        WSGI["WSGI Entry Point\n(setup/wsgi.py)"]:::server
        ASGI["ASGI Entry Point\n(setup/asgi.py)"]:::server
        URLDispatcher["URL Dispatcher\n(setup/urls.py)"]:::server
    end

    %% Django Core Layer
    subgraph "Django Core" 
        direction TB
        Views["Views\n(preCorrecao/views.py)"]:::core
        Models["Models\n(preCorrecao/models.py)"]:::core
        Admin["Admin Interface\n(preCorrecao/admin.py)"]:::core
        TemplateRenderer["Template Renderer"]:::core
        ORM["ORM (CRUD)"]:::core
    end

    %% Database Layer
    subgraph "Database" 
        direction TB
        SQLite["SQLite Database\n(db.sqlite3)"]:::db
    end

    %% Deployment & Tooling
    subgraph "Deployment & Tooling"
        direction TB
        ProcfileNode["Procfile"]:::tooling
        Requirements["requirements.txt"]:::tooling
        Manage["manage.py"]:::tooling
        VirtualEnv["Python Virtual Env\n(.venv)"]:::tooling
        Git["Git Version Control"]:::tooling
    end

    %% Connections
    Browser -->|"HTTP GET/POST"| WSGI
    Browser -->|"Static file request"| URLDispatcher
    URLDispatcher -->|"route request"| Views
    Views -->|"render form"| TemplateRenderer
    TemplateRenderer -->|"HTML + JS"| Browser
    Views -->|"ORM query"| ORM
    ORM -->|"SQL queries"| SQLite
    Views -->|"admin actions"| Admin
    Browser -->|"loads JS modules"| JSModules
    Browser -->|"fetches JSON"| JSONData

    %% Click Events
    click Templates "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/templates/preCorrecao/formulario.html"
    click JSModules "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/static/javascript/adicionarFundamentacao.js"
    click JSModules "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/static/javascript/dadosCampos.js"
    click JSModules "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/static/javascript/limparCampos.js"
    click JSModules "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/static/javascript/sweetAlert.js"
    click JSONData "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/static/json/estados-cidades.json"
    click WSGI "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/setup/wsgi.py"
    click ASGI "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/setup/asgi.py"
    click URLDispatcher "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/setup/urls.py"
    click Views "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/views.py"
    click Models "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/models.py"
    click Admin "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/preCorrecao/admin.py"
    click SQLite "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/db.sqlite3"
    click ProcfileNode "https://github.com/caio-machado-dev/growup_portodigital_bonsae/tree/main/Procfile"
    click Requirements "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/requirements.txt"
    click Manage "https://github.com/caio-machado-dev/growup_portodigital_bonsae/blob/main/manage.py"

    %% Styles
    classDef client fill:#D6E9FF,stroke:#2B6CB0,color:#2B6CB0;
    classDef server fill:#DFFFE0,stroke:#27632A,color:#27632A;
    classDef core fill:#FFF4D6,stroke:#A66E00,color:#A66E00;
    classDef db fill:#FFE4E1,stroke:#A12E2E,color:#A12E2E;
    classDef tooling fill:#E2E8F0,stroke:#4A5568,color:#4A5568;
```
