# dsilvas2001/django_prueba architecture

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

- Interactive diagram: https://gitdiagram.com/dsilvas2001/django_prueba
- Repository: https://github.com/dsilvas2001/django_prueba

## Overview

##### Project Type and Purpose
- It is primarily a backend API system built with Django.
- Provides both a web administration interface (using Django’s built-in admin panel) and a REST API for CRUD operations on images.
- It includes a separate AWS Lambda function for analyzing images to detect and classify them as documents, photos, invoices, or others.
- The project is ready for deployment on AWS Lightsail.

##### Main Components
a. Django Backend:
- “catalogo” project which includes the overall Django configuration (settings, URLs, and WSGI/ASGI).
- “imagenes” application that handles image models, views, serializers (suggesting use of Django REST Framework), migrations, and tests.
b. Database:
- Use of SQLite (db.sqlite3) for development, with potential to scale to a production-grade database.
c. Media/File Storage:
- “media” folder where uploaded image files are stored (i.e., media/imagenes).
d. Image Classification Service (AWS Lambda):
- This external component that processes and classifies image data.
- Triggers for Lambda either via S3 (for uploaded files) or through direct base64 image payloads.
e. Deployment Environment:
- AWS Lightsail as the deployment target for the Django application.
- AWS S3 for storage and as a trigger for the Lambda function.

##### Relationships and Interactions
- Interactions between the views and serializers (for API data handling) and the underlying models (database persistence).
- Link the media storage component with the Django backend, indicating that uploaded images are saved to disk.
- AWS S3 with the Lambda function, indicating that file uploads (or events) trigger the classification function.

##### Architectural Patterns and Technologies
- Model-View-Controller (or Model-View-Template) pattern inherent in Django.
- Use of Django REST Framework components (views, serializers) for the API layer.
- That there is a clear separation between the web backend and the Lambda-based classification functionality.
- Integration with AWS services (Lightsail for deployment, S3 triggers for Lambda) as key points of interest.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Client["Client (Web/Upload Client)"]:::client

    %% Deployment Environment
    subgraph "Deployment Environment (AWS Lightsail)"
        Django["Django Project (catalogo)"]:::django
        Imagenes["Imagenes App"]:::app
    end

    DB["Database (SQLite)"]:::database
    Media["Media Storage"]:::storage
    AWS_S3["AWS S3"]:::aws
    AWS_Lambda["AWS Lambda – Image Classifier"]:::aws

    %% Data Flow
    Client -->|"HTTP/API_request"| Django
    Django -->|"URL_Routing"| Imagenes
    Imagenes -->|"CRUD_operations"| DB
    Imagenes -->|"Store_Images"| Media
    Client -->|"Direct_Upload/S3_Trigger"| AWS_S3
    AWS_S3 -->|"Triggers"| AWS_Lambda
    AWS_Lambda -->|"Returns_classification"| Django

    %% Click Events
    click Django "https://github.com/dsilvas2001/django_prueba/tree/main/catalogo/"
    click Imagenes "https://github.com/dsilvas2001/django_prueba/tree/main/imagenes/"
    click DB "https://github.com/dsilvas2001/django_prueba/blob/main/db.sqlite3"
    click Media "https://github.com/dsilvas2001/django_prueba/tree/main/media/imagenes"

    %% Styles
    classDef client fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef django fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef app fill:#FFECB3,stroke:#F9A825,stroke-width:2px;
    classDef database fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef storage fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef aws fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px;
```
