# adrianjs2009/proyecto_fct_python architecture

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

- Interactive diagram: https://gitdiagram.com/adrianjs2009/proyecto_fct_python
- Repository: https://github.com/adrianjs2009/proyecto_fct_python

## Overview

- Django Project & Settings: Represent the core of the application, including components like settings.py, urls.py, asgi.py, and wsgi.py. This is the entry and configuration point for the entire API.
- API Endpoint Layer (Interfaces): This is represented by the “drones/interfaces” directory. It contains view logic (e.g., view functions or ViewSets) and serializers that map HTTP requests to domain models.
- Business/Application Layer: Shown under “drones/application”. This layer encapsulates the business logic and services that handle flight command executions and drone/matrix management.
- Domain Layer: Under “drones/domain”, which includes domain-specific logic such as repositories and custom exceptions that enforce business rules.
- Data Models & Infrastructure: Found in “drones/models.py” and “drones/infrastructure”. This is the low-level data representation layer that interacts with the database (SQLite as noted in db.sqlite3).

##### Relationships and Flow
- External API Clients send HTTP requests (using Swagger, ReDoc endpoints, etc.) that are received by the Django project via URL routing defined in AeroMatrix/urls.py.
- Requests reach the API Endpoint Layer (Interfaces) where serializers validate and convert data before handing over to the business/application layer.
- The Application Layer’s services (in drones/application) process the core business logic (e.g., executing command sequences, validating collision/boundaries) and interact with domain logic.
- The Domain Layer (drones/domain) further validates operations and interacts with repositories.
- Data Models (from drones/models.py) and the Infrastructure layer then execute CRUD operations on the persistence layer (SQLite database).

##### Architectural Patterns and Design Principles
- Layered (or Onion/Hexagonal) Architecture: Separation into presentation (interfaces), application (services), domain, and infrastructure layers indicates a clean separation of concerns.
- Domain Driven Design (DDD) Influence: The use of a distinct domain layer for repositories and custom exceptions to encapsulate business logic.
- Usage of Django and DRF: Leverage built-in capabilities for URL routing, serialization, authentication, and auto-generated API documentation.

##### Technologies and Frameworks
- Python 3.13, Django 5.1, Django REST Framework, and drf-spectacular for auto-generated documentation.
- SQLite as the persistence mechanism in this project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    ext("External API Clients (/api/drones/,/api/flights/)"):::external

    %% Django Core Subgraph
    subgraph "Django Core"
        settings("Settings.py"):::django
        urls("Urls.py"):::django
        asgi("ASGI.py"):::django
        wsgi("WSGI.py"):::django
    end

    %% API Endpoint Layer
    subgraph "Interfaces Layer"
        interfaces("API Endpoints (drones/interfaces)"):::interfaces
    end

    %% Business/Application Layer
    subgraph "Business/Application Layer"
        business("Business Logic (drones/application)"):::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        exceptions("Exceptions (drones/domain/exceptions.py)"):::domain
        repositories("Repositories (drones/domain/repositories.py)"):::domain
    end

    %% Data Models & Infrastructure
    subgraph "Data Models & Infrastructure"
        models("Data Models (drones/models.py)"):::data
        infraModels("Infrastructure (drones/infrastructure/models.py)"):::data
    end

    %% Persistence Layer
    subgraph "Persistence"
        db("SQLite Database"):::database
        migrations("Migrations (drones/migrations)"):::database
    end

    %% Connections
    ext -->|"sends request"| urls
    urls -->|"routes to"| interfaces
    interfaces -->|"calls"| business
    business -->|"invokes"| exceptions
    business -->|"invokes"| repositories
    exceptions -->|"accesses"| models
    repositories -->|"accesses"| models
    models -->|"performs CRUD"| db
    infraModels -->|"performs CRUD"| db
    db -->|"schema update"| migrations

    %% Click Events for Django Core
    click settings "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/AeroMatrix/settings.py"
    click urls "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/AeroMatrix/urls.py"
    click asgi "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/AeroMatrix/asgi.py"
    click wsgi "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/AeroMatrix/wsgi.py"

    %% Click Event for API Endpoints Layer
    click interfaces "https://github.com/adrianjs2009/proyecto_fct_python/tree/main/backend/AeroMatrix/drones/interfaces"

    %% Click Event for Business/Application Layer
    click business "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/drones/application/services.py"

    %% Click Events for Domain Layer
    click exceptions "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/drones/domain/exceptions.py"
    click repositories "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/drones/domain/repositories.py"

    %% Click Events for Data Models & Infrastructure
    click models "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/drones/models.py"
    click infraModels "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/drones/infrastructure/models.py"

    %% Click Events for Persistence Layer
    click db "https://github.com/adrianjs2009/proyecto_fct_python/blob/main/backend/AeroMatrix/db.sqlite3"
    click migrations "https://github.com/adrianjs2009/proyecto_fct_python/tree/main/backend/AeroMatrix/drones/migrations"

    %% Styling
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef django fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef interfaces fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef application fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef domain fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef data fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef database fill:#F08080,stroke:#333,stroke-width:2px;
```
