# luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv architecture

> Architecture diagram of the GitHub repository luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv
- Repository: https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv

## Overview

##### Project Type and Purpose
- This is a full-stack real-estate lot management and sales application.
- Backend: Django REST API (Python) handling data models (“lotes”), authentication, image processing (OpenCV/NumPy/Shapely), and MySQL persistence.
- Frontend: Flutter mobile/web/desktop app providing UI screens, model classes, and service-layer wrappers around the REST API.

##### File Structure Analysis
- Top-level:
- gestion_lotes/ → Django project
- gestion_lotes_frontend/ → Flutter project
- Backend (gestion_lotes):
- gestion_lotes/settings.py, urls.py, wsgi.py/asgi.py → core config & routing
- lotes/ → Django app: models.py, serializers.py, views.py, permissions.py, urls.py, migrations
- manage.py → Django CLI
- Frontend (gestion_lotes_frontend/lib):
- components/ → reusable UI widgets
- screens/ → page layouts and routes
- models/ → data classes matching backend DTOs
- services/ → HTTP clients for auth, lotes, ventas, planos, uploads
- config/api_config.dart → base URLs, endpoints

##### Key Architectural Patterns
- Backend:
- MVC / MVT (Views = APIView/ViewSet, Models, Templates unused)
- RESTful API layer → URLs → Views → Serializers → Models → Database
- Image processing pipeline invoked in views or model methods
- Frontend:
- Component-based UI (Flutter widgets)
- Service layer abstracts HTTP calls
- State management implicit in screens (could be enhanced with Provider/Bloc)

##### Main Components and Their Relationships
- Frontend App
→ UI Widgets & Screens
→ Service Layer (AuthService, LotesService, UploadService…)
↔ HTTP/HTTPS
- Backend API
→ Django REST endpoints (/api/auth/, /api/lotes/, /api/planos/, /api/ventas/)
→ Image Processing Module (OpenCV, NumPy, Shapely)
→ Business Logic (permissions, serializers, validations)
→ MySQL Database (gestion_lotes schema)
- External/Infrastructure
→ MySQL server (could be local or cloud RDBMS)
→ File storage (media folder or object storage for plan images)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Mobile/Web App"
        direction TB
        AppMain["main.dart"]:::frontend
        ApiConfig["api_config.dart"]:::frontend
        Services["Service Layer"]:::frontend
        Models["Data Models"]:::frontend
        Components["UI Components"]:::frontend
        Screens["Screens & Navigation"]:::frontend

        AppMain --> Screens
        Screens --> Components
        Screens --> Services
        Services --> Models
        Services --> ApiConfig
    end

    %% Backend Layer
    subgraph "Django Backend"
        direction TB
        CoreConfig["settings.py"]:::backend
        UrlRouting["urls.py"]:::backend
        Interfaces["wsgi.py/asgi.py"]:::backend
        CLI["manage.py"]:::backend

        subgraph "Lotes App"
            direction TB
            LoteModels["models.py"]:::backend
            Serializers["serializers.py"]:::backend
            Views["views.py (Image Pipeline)"]:::process
            Permissions["permissions.py"]:::backend
            LoteUrls["urls.py"]:::backend
            Migrations["migrations/"]:::backend
            ImageLibs["OpenCV/NumPy/Shapely"]:::process

            Views --> ImageLibs
        end

        CoreConfig --> UrlRouting
        CoreConfig --> Interfaces
        CoreConfig --> CLI
        UrlRouting --> LoteUrls
        UrlRouting --> CLI
        UrlRouting --> Views
    end

    %% External Infrastructure
    MySQL["MySQL Database"]:::database
    FileStore["File Storage"]:::external

    %% Interactions
    Services -->|HTTP/HTTPS| UrlRouting
    Views -->|read/write| MySQL
    Views -->|store images| FileStore
    Views -->|retrieve images| FileStore
    Views -->|authorization checks| Permissions

    %% Data Flow
    LoteModels --> MySQL
    Serializers --> LoteModels
    Views --> Serializers

    %% Click Events
    click CoreConfig "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/gestion_lotes/settings.py"
    click UrlRouting "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/gestion_lotes/urls.py"
    click Interfaces "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/gestion_lotes/wsgi.py"
    click Interfaces "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/gestion_lotes/asgi.py"
    click CLI "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/manage.py"
    click LoteModels "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/lotes/models.py"
    click Serializers "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/lotes/serializers.py"
    click Views "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/lotes/views.py"
    click Permissions "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/lotes/permissions.py"
    click LoteUrls "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes/lotes/urls.py"
    click Migrations "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/tree/main/gestion_lotes/lotes/migrations/"
    click ApiConfig "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes_frontend/lib/config/api_config.dart"
    click Services "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/tree/main/gestion_lotes_frontend/lib/services/"
    click Models "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/tree/main/gestion_lotes_frontend/lib/models/"
    click Components "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/tree/main/gestion_lotes_frontend/lib/components/"
    click Screens "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/tree/main/gestion_lotes_frontend/lib/screens/"
    click AppMain "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes_frontend/lib/main.dart"
    click FullImageScreen "https://github.com/luisalbertoq/sistema-movil-de-deteccion-automatica-de-lotes-en-planos-imagenes--mediante-opencv/blob/main/gestion_lotes_frontend/lib/imagen_completa_screen.dart"

    %% Styles
    classDef frontend fill:#D6E8FF,stroke:#1E70BF,color:#1E70BF;
    classDef backend fill:#DFF2D8,stroke:#396E24,color:#396E24;
    classDef database fill:#FFE7C0,stroke:#B15A00,color:#B15A00;
    classDef process fill:#F0F0F0,stroke:#444,color:#444;
    classDef external fill:#FFF3BF,stroke:#BF8B00,color:#BF8B00;
```
