# faus14/proyectofinal_curso_python architecture

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

- Interactive diagram: https://gitdiagram.com/faus14/proyectofinal_curso_python
- Repository: https://github.com/faus14/proyectofinal_curso_python

## Overview

##### Project type and purpose
- This is a full‑stack, server‑rendered web application built with the Django framework.
- Purpose: allow users to register, create and view “posts” about sports activities, and follow/unfollow other users (akin to a mini‑Twitter).

##### File structure
- Top‑level “post_coder” folder contains:
- social_django/       ← Django project settings (ASGI/WSGI, URLs, settings.py)
- social/              ← the core Django “social” app (models, views, templates, static, forms, migrations)
- db.sqlite3           ← embedded database
- media/               ← uploaded user media (profile pictures, etc.)
- requirements.txt, manage.py
- Static assets under social/static and templates under social/templates/social.
- Signals (post_coder/social/signals.py) hint at event‑driven updates (e.g., auto‑create Profiles).
- Dependencies managed in requirements.txt; virtualenv under venv/.

##### Key README insights
- Models: Profile, Post, Relationship (follow/unfollow).
- SQLite used for persistence.
- No external APIs or microservices—pure Django MTV (Model‑Template‑View) pattern.

##### Main components
A. User’s Web Browser (Client)
B. Django Web Server
1) URL Dispatcher (social_django/urls.py + social/urls.py)
2) Views (social/views.py)
3) Templates (social/templates/social/*.html) & Static (CSS under social/static)
4) Forms (social/forms.py)
5) Signals (social/signals.py)
6) ORM Models (social/models.py)
C. Database (SQLite db.sqlite3)
D. Media Storage (filesystem under media/)
E. (Optional) Future External Services (e.g., S3 for media, Redis for caching)

##### Relationships & interactions
- Browser → HTTP Request → URL Dispatcher → View
- View ↔ ORM Models → Database
- View → Template Renderer → HTML Response → Browser
- Static files (CSS) served either by Django during dev or via a CDN/in web server in prod
- Form submissions (login, register, post creation) flow through Django Forms → Views → Models
- Signals listen to Model events (e.g., creating Profile when User is created)

##### Architectural patterns & design principles
- MTV (Model‑Template‑View) pattern: clear separation of concerns.
- Layered architecture:
- Presentation layer (templates/static)
- Application layer (views/forms/signals)
- Domain layer (models + ORM)
- Infrastructure layer (DB, media filesystem)
- Single‑app monolith: easy to extend, one Django project with one or more apps.

##### Details to capture
- The inter‑app interaction (settings.py imports social.urls).
- The path of a user’s “Create Post” flow: Browser → social/post view → form validation → model.save() → DB → redirect to feed.
- Follow/unfollow flow: Browser → relationship view → model update → DB → feed view refresh.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Browser["User's Web Browser"]:::client

    %% Django Server
    subgraph "Django Web Server"
        direction TB
        ManagePy["manage.py"]:::infra
        Settings["settings.py"]:::infra
        ASGI["asgi.py"]:::infra
        WSGI["wsgi.py"]:::infra

        subgraph "URL Dispatcher"
            direction TB
            GlobalURLs["social_django/urls.py"]:::backend
            AppURLs["social/urls.py"]:::backend
        end

        Views["views.py"]:::backend
        Forms["forms.py"]:::backend
        Signals["signals.py"]:::backend
        Models["models.py"]:::backend

        subgraph "Templates & Static"
            direction TB
            Templates["Templates (HTML)"]:::presentation
            Static["Static (CSS)"]:::presentation
        end
    end

    %% Infrastructure
    DB["SQLite (db.sqlite3)"]:::database
    Media["Media Storage"]:::media
    Requirements["requirements.txt"]:::infra

    %% Connections
    Browser -->|"HTTP GET/POST"| GlobalURLs
    Browser -->|"HTTP GET/POST"| AppURLs
    GlobalURLs -->|"route to view"| Views
    AppURLs -->|"route to view"| Views
    Views -->|"validate"| Forms
    Forms -->|"cleaned data"| Views
    Views -->|"query/update"| Models
    Models -->|"ORM queries"| DB
    DB -->|"results"| Models
    Models -->|"model signals"| Signals
    Signals -->|"trigger business logic"| Models
    Views -->|"render"| Templates
    Browser -->|"fetch CSS"| Static
    Views -->|"serve static"| Static
    Views -->|"serve media"| Media
    Browser -->|"fetch media"| Media
    ManagePy -->|"bootstrap"| Settings
    Settings -->|"configure"| GlobalURLs
    Settings -->|"configure"| AppURLs
    Settings -->|"configure"| ASGI
    Settings -->|"configure"| WSGI
    Requirements -->|"install deps"| Settings

    %% Click Events
    click GlobalURLs "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social_django/urls.py"
    click AppURLs "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social/urls.py"
    click Views "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social/views.py"
    click Forms "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social/forms.py"
    click Signals "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social/signals.py"
    click Models "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social/models.py"
    click Templates "https://github.com/faus14/proyectofinal_curso_python/tree/main/post_coder/social/templates/social"
    click Static "https://github.com/faus14/proyectofinal_curso_python/tree/main/post_coder/social/static"
    click Settings "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social_django/settings.py"
    click ASGI "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social_django/asgi.py"
    click WSGI "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/social_django/wsgi.py"
    click ManagePy "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/manage.py"
    click DB "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/db.sqlite3"
    click Media "https://github.com/faus14/proyectofinal_curso_python/tree/main/post_coder/media/"
    click Requirements "https://github.com/faus14/proyectofinal_curso_python/blob/main/post_coder/requirements.txt"

    %% Styles
    classDef client fill:#D6E9FE,stroke:#3178C6,color:#000
    classDef backend fill:#FFFFFF,stroke:#555,stroke-width:1px
    classDef presentation fill:#FFF8DC,stroke:#DAA520
    classDef database fill:#FFE5B4,stroke:#FF8C00
    classDef media fill:#E0F8E0,stroke:#228B22
    classDef infra fill:#F0F0F0,stroke:#888;color:#333
```
