- How to Clone and Run the Application
- Architecture and Design Patterns
- Project Structure
- API Endpoints
- Database Configuration
-
Clone the repository:
git clone https://github.com/AdrianJS2009/AeroMatrix.git cd Proyecto_FCT -
Set up the database:
- Ensure MySQL is installed and running.
- Create a database named
dronesdb.
-
Configure the application properties:
- Edit the file
src/main/resources/application.propertieswith 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
- Edit the file
-
Run the application:
./mvnw spring-boot:run
The project follows a combination of Domain-Driven Design (DDD) and Hexagonal Architecture, organized in layers with clear responsibilities:
- Core Domain:
- Entities like
DroneandMatrix(indomain/) encapsulate core business logic. - Enums like
OrientationandMovementCommanddefine domain rules (e.g., valid directions).
- Entities like
- Aggregates:
Matrixacts as the aggregate root, managing its associated drones.
- Domain Core:
- Entities and services (
DroneService,FlightService) are independent of infrastructure.
- Entities and services (
- Repositories:
- Interfaces like
DroneRepositorydefine how the core interacts with the outside world.
- Interfaces like
- Adapters:
DroneControllerandMatrixControlleradapt HTTP requests.DroneRepository(JPA) provides data access without coupling to specific DB.
- Repository:
- Abstracts data access (
DroneRepository,MatrixRepository)
- Abstracts data access (
- Service:
- Services like
FlightServicecoordinate complex operations
- Services like
- DTO (Data Transfer Object):
- Classes like
DroneDtodecouple API from internal entities.
- Classes like
- Centralized Error Handling:
GlobalExceptionHandlerhandles exceptions using@ControllerAdvice.
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
-
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}
-
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}
-
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"] } ] }