# joacocavest/tp_apis architecture

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

- Interactive diagram: https://gitdiagram.com/joacocavest/tp_apis
- Repository: https://github.com/joacocavest/tp_apis

## Overview

##### Project type and purpose
- This is a Django-based REST API project for an auction system (“subastas_clase”).
- It follows Django’s Model-View-Template (MVT) architecture extended with Django REST Framework (DRF).
- Two core domains (apps): “anuncio” (auction listings) and “usuario” (user management).

##### File structure
- Top-level Django project folder: subastas_clase/ (contains settings.py, urls.py, asgi.py, wsgi.py, router.py).
- Apps subdirectory: apps/anuncio/ and apps/usuario/. Each app has models.py, views.py or api.py, serializers.py (in anuncio), filters.py (in TP4), urls.py or router.py, migrations, tests.py.
- manage.py at project root and a local SQLite database (db.sqlite3).
- Evolution: TP1 was minimal; by TP4 filters, routers, serializers and API endpoints are in place.

##### README insights
- The Google Doc describes mobile-first requirements, listing endpoints for auctions and users.
- It outlines features: create/list/update auctions, user registration/authentication.

##### Components
a. External Clients
- Mobile app / Web front-end
- Postman or any REST client
b. API Gateway / HTTP Interface
- Django’s URL dispatcher (urls.py and router.py)
- asgi.py / wsgi.py
c. Django Application Layers
- Views / API views (apps/anuncio/views.py or api.py, apps/usuario/views.py or api.py)
- Serializers (apps/anuncio/serializers.py)
- Filters (apps/anuncio/filters.py)
- Business Logic (in views or service modules if any)
- Models (apps/*/models.py)
d. Persistence
- Django ORM
- SQLite database (db.sqlite3)
e. Admin Interface (optional)
- Django Admin (apps/*/admin.py)
f. External Services (if any in future)
- Email service for user notifications
- Third-party authentication

##### Relationships and interactions
- Client issues HTTP requests to the API endpoint (e.g., POST /api/anuncios/).
- Django URL router directs requests to the appropriate viewset or view function.
- View invokes serializer to validate and transform data.
- Serializer interacts with models (via ORM) to perform create, read, update, delete operations on the database.
- Database returns results back up the chain; view serializes response JSON; HTTP response goes back to client.

##### Architectural patterns and design principles
- MVT (Django’s variant of MVC): Models, Views (controllers), Templates (not used here), extended by DRF Views/Serializers.
- RESTful API principles: resource-based endpoints, HTTP verbs.
- Modular app structure: each domain in its own app folder.
- Use of routers for automatic URL generation (router.py in project and apps).

##### Elements
- Labels: “Mobile Client”, “Django API Gateway”, “Anuncio App”, “Usuario App”, “SQLite DB”.
- Client → API Gateway (HTTP request)
- API Gateway → Views/Router → Serializers → ORM → Database
- Database → ORM → Serializers → API Gateway → Client
- Rectangles for services (API Gateway, Apps)

##### Detailed capture of essential elements
- Break out the URL router as a distinct node.
- Both asgi.py (async entry) and wsgi.py (sync entry) if needed.
- Core settings.py module as the place configuring installed apps, middleware, REST framework settings.
- Optionally, include the admin interface and migrations folder to show schema evolution process.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "External Clients"
        Mobile["Mobile/Web Client"]:::external
        RESTClient["HTTP Client (Postman)"]:::external
    end

    subgraph "API Gateway"
        ASGI["asgi.py"]:::code
        WSGI["wsgi.py"]:::code
        URLs["urls.py"]:::code
        Router["router.py"]:::code
    end

    subgraph "Core Configuration"
        Settings["settings.py"]:::config
        Manage["manage.py"]:::config
    end

    subgraph "Backend Applications"
        subgraph "Anuncio App"
            A_Admin["admin.py"]:::app
            A_API["api.py"]:::app
            A_Serializers["serializers.py"]:::app
            A_Filters["filters.py"]:::app
            A_Models["models.py"]:::app
            A_Views["views.py"]:::app
            A_Router["router.py"]:::app
            A_URLs["urls.py"]:::app
            A_Migrations["migrations/"]:::app
        end
        subgraph "Usuario App"
            U_Admin["admin.py"]:::app
            U_API["api.py"]:::app
            U_Models["models.py"]:::app
            U_Views["views.py"]:::app
            U_Tests["tests.py"]:::app
            U_Migrations["migrations/"]:::app
        end
    end

    ORM["Django ORM"]:::orm
    DB["SQLite DB"]:::db

    Mobile -->|"HTTP Request"| ASGI
    RESTClient -->|"HTTP Request"| ASGI
    ASGI --> URLs
    WSGI --> URLs
    URLs --> Router
    Router --> A_Views
    Router --> U_Views
    A_Views --> A_Serializers
    A_Serializers --> A_Models
    U_Views --> U_API
    U_API --> U_Models
    A_Models --> ORM
    U_Models --> ORM
    ORM --> DB
    DB --> ORM
    ORM --> A_Serializers
    A_Serializers --> A_Views
    A_Views --> Router
    Router --> URLs
    URLs --> ASGI
    ASGI --> Mobile

    classDef external fill:#ffcc00,stroke:#333,stroke-width:1px;
    classDef gateway fill:#66ccff,stroke:#333,stroke-width:1px;
    classDef config fill:#ccff99,stroke:#333,stroke-width:1px;
    classDef app fill:#ff99cc,stroke:#333,stroke-width:1px;
    classDef orm fill:#ccccff,stroke:#333,stroke-width:1px;
    classDef db fill:#ff9999,stroke:#333,stroke-width:1px;
    classDef code fill:#dddddd,stroke:#333,stroke-width:1px;

    click ASGI "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/subastas_clase/asgi.py"
    click WSGI "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/subastas_clase/wsgi.py"
    click URLs "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/subastas_clase/urls.py"
    click Router "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/subastas_clase/router.py"
    click Settings "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/subastas_clase/settings.py"
    click Manage "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/manage.py"
    click DB "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/db.sqlite3"
    click A_Admin "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/anuncio/admin.py"
    click A_API "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/anuncio/api.py"
    click A_Models "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/anuncio/models.py"
    click A_Serializers "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/anuncio/serializers.py"
    click A_Filters "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/anuncio/filters.py"
    click A_Router "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/anuncio/router.py"
    click A_URLs "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/anuncio/urls.py"
    click A_Views "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/anuncio/views.py"
    click A_Migrations "https://github.com/joacocavest/tp_apis/tree/main/TP4/subastas_clase/apps/anuncio/migrations/"
    click U_Admin "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/usuario/admin.py"
    click U_API "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/usuario/api.py"
    click U_Models "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/usuario/models.py"
    click U_Views "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/usuario/views.py"
    click U_Tests "https://github.com/joacocavest/tp_apis/blob/main/TP4/subastas_clase/apps/usuario/tests.py"
    click U_Migrations "https://github.com/joacocavest/tp_apis/tree/main/TP4/subastas_clase/apps/usuario/migrations/"
```
