Skip to content

AdrianJS2009/AeroMatrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚁 AeroMatrix

📋 Table of Contents


🛠️ How to Clone and Run the Application

  1. Clone the repository:

    git clone https://github.com/AdrianJS2009/AeroMatrix.git
    cd Proyecto_FCT
  2. Set up the database:

    • Ensure MySQL is installed and running.
    • Create a database named dronesdb.
  3. Configure the application properties:

    • Edit the file src/main/resources/application.properties with your database credentials.
    spring.datasource.url=jdbc:mysql://localhost:3306/dronesdb
    spring.datasource.username=
    spring.datasource.password=
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  4. Run the application:

    ./mvnw spring-boot:run

🏛️ Architecture and Design Patterns

The project follows a combination of Domain-Driven Design (DDD) and Hexagonal Architecture, organized in layers with clear responsibilities:

1. Domain-Driven Design (DDD)

  • Core Domain:
    • Entities like Drone and Matrix (in domain/) encapsulate core business logic.
    • Enums like Orientation and MovementCommand define domain rules (e.g., valid directions).
  • Aggregates:
    • Matrix acts as the aggregate root, managing its associated drones.

2. Hexagonal Architecture

  • Domain Core:
    • Entities and services (DroneService, FlightService) are independent of infrastructure.
  • Repositories:
    • Interfaces like DroneRepository define how the core interacts with the outside world.
  • Adapters:
    • DroneController and MatrixController adapt HTTP requests.
    • DroneRepository (JPA) provides data access without coupling to specific DB.

3. Key Patterns

  • Repository:
    • Abstracts data access (DroneRepository, MatrixRepository)
  • Service:
    • Services like FlightService coordinate complex operations
  • DTO (Data Transfer Object):
    • Classes like DroneDto decouple API from internal entities.
  • Centralized Error Handling:
    • GlobalExceptionHandler handles exceptions using @ControllerAdvice.

🏗️ Project Structure

Proyecto_FCT/
├── backend/
│   └── src/
│       ├── main/
│       │   ├── java/com/drones/fct/
│       │   │   ├── config/              # ⚙️ Global configuration classes
│       │   │   ├── controller/          # 🌍 REST Controllers
│       │   │   ├── domain/              # 🧠 Domain entities (models)
│       │   │   ├── dto/                 # 📦 Data Transfer Objects
│       │   │   ├── exception/           # 🚨 Custom exceptions and global handlers
│       │   │   ├── repository/          # 🗃️ JPA Repositories (data access layer)
│       │   │   ├── service/             # 🔧 Business logic and services
│       │   │   └── FctApplication.java  # 🚀 Main Spring Boot application class
│       │   └── resources/               # ⚙️ Application properties, configs, etc.
│       └── test/java/com/drones/fct/
│           ├── service/                # 🧪 Unit tests for services
│           ├── controller/             # 🧪 Integration tests for controllers
│           ├── repository/             # 🧪 Repository layer tests
│           └── exception/              # 🧪 Exception handling tests
│
├── frontend/drone-flight-control/
│   ├── public/                         # 🌐 Static files
│   ├── src/
│   │   ├── api/                        # 🔌 API calls and interfaces
│   │   ├── components/                 # 🧩 Reusable UI components
│   │   ├── context/                    # 🧠 Global context and providers
│   │   ├── pages/                      # 📄 Application routes and views
│   │   └── types/                      # 📝 TypeScript types and interfaces
│   ├── .env.local                      # 🔐 Local environment variables
│   ├── index.html                      # 🏠 HTML entry point
│   ├── package.json                    # 📦 Project dependencies and scripts
│   ├── tsconfig.json                   # ⚙️ TypeScript configuration
│   ├── tailwind.config.js              # 🎨 Tailwind CSS configuration
│   └── vite.config.ts                  # ⚡ Vite build configuration


🌐 API Endpoints

Matrices

  • Create a matrix:

    POST /api/matrices-flight/create
    {
      "maxX": 10,
      "maxY": 10
    }
  • Get matrix by ID:

    GET /api/matrices-flight/get/{id}
  • Update a matrix:

    PUT /api/matrices-flight/update/{id}
    {
      "maxX": 15,
      "maxY": 15
    }
  • Delete a matrix:

    DELETE /api/matrices-flight/delete/{id}

Drones

  • Create a drone:

    POST /api/drones
    {
      "matrixId": 1,
      "name": "Drone1",
      "model": "ModelX",
      "x": 0,
      "y": 0,
      "orientation": "N"
    }
  • Get drone by ID:

    GET /api/drones/{droneId}
  • Update a drone:

    PUT /api/drones/{droneId}
    {
      "name": "Drone1",
      "model": "ModelX",
      "x": 1,
      "y": 1,
      "orientation": "E"
    }
  • Delete a drone:

    DELETE /api/drones/{droneId}

Flights

  • Execute commands on a drone:

    POST /api/flights/drone/{droneId}/commands
    {
      "commands": ["TURN_LEFT", "MOVE_FORWARD"]
    }
  • Execute commands on multiple drones:

    POST /api/flights/drones/commands
    {
      "droneIds": [1, 2],
      "commands": ["TURN_LEFT", "MOVE_FORWARD"]
    }
  • Execute multiple command sequences on multiple drones:

    POST /api/flights/drones/batch-commands
    {
      "commands": [
        {
          "droneId": 1,
          "commands": ["TURN_LEFT", "MOVE_FORWARD"]
        },
        {
          "droneId": 2,
          "commands": ["TURN_RIGHT", "MOVE_FORWARD"]
        }
      ]
    }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors