Skip to content

CRUD API built with SOLID principles using JDK 22, Quarkus 3.12.3, Maven 3.9.8, MySQL and Docker 4.32.0, as of now.

Notifications You must be signed in to change notification settings

Thercules/crud-api-users-quarkus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRUD-Solicitação Serviços

This project uses Quarkus, the Supersonic Subatomic Java Framework.

Installation and Setup

Back-end

IntelliJ Community Edition

  1. Download and install IntelliJ Community Edition.
  2. Configure IntelliJ to use JDK 22 by going to File > Project Structure > Project > Project SDK and adding JDK 22. IntelliJ Screenshot

Maven

  1. Download Maven from the official site.
  2. Extract the archive and set the M2_HOME environment variable to the extracted directory.
  3. Add M2_HOME/bin to your system PATH.

JDK 22

  1. Download JDK 22 from the official Oracle website or use OpenJDK.
  2. Set the JAVA_HOME environment variable to the JDK installation directory.
  3. Add JAVA_HOME/bin to your system PATH.

MySQL

  1. Install MySQL following the instructions on MySQL's official website.
  2. Create a database for the application.
  3. Configure your application.properties file in Quarkus to connect to your MySQL instance.

Docker

  1. Install Docker following the instructions on Docker's official website.
  2. Use Docker to run MySQL and your application containers. Docker Screenshot

Front-end

Node.js

  1. Download and install the latest version of Node.js from the official website.
  2. Verify the installation by running:
    node -v
    npm -v

VSCode

  1. Download and install Visual Studio Code.
  2. Open your project in VSCode.

Vue.js 2

  1. Install Vue CLI globally by running:
    npm install -g @vue/cli@4.5.15
  2. Create a new Vue.js 2 project or navigate to your existing project directory and install dependencies:
    npm install
  3. Configure your vue.config.js for the port you want and set up a proxy layer to the port where your API is running to avoid CORS issues:
    const { defineConfig } = require('@vue/cli-service')
    
     module.exports = defineConfig({
       transpileDependencies: true,
       devServer: {
     	port: 8084,
     	proxy: {
     	  '/api': {
     		target: 'http://localhost:8080', // Port where your API is running
     		changeOrigin: true,
     		pathRewrite: { '^/api': '' },
     	  },
     	},
       },
     }) 
  4. Run the Vue.js development server on port 8084:
    npm run serve 

NOTE: Ensure your front-end runs on port 8084, while your API runs on port 8080 using Docker to avoid conflicts.

Project Overview

This project is a modern CRUD API built with SOLID principles using:

  • JDK 22
  • Quarkus 3.12.3
  • Maven 3.9.8
  • MySQL
  • Docker 4.32.0

It includes endpoints for managing services, users, and service requests.

Running the Application

Development Mode

To run the application in development mode with live coding enabled:

./mvnw compile quarkus:dev

NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

Packaging and Running the Application

To package the application:

./mvnw package

This produces the quarkus-run.jar file in the target/quarkus-app/ directory. It’s not an über-jar as the dependencies are copied into the target/quarkus-app/lib/ directory. You can run the application using:

java -jar target/quarkus-app/quarkus-run.jar

To build an über-jar:

./mvnw package -Dquarkus.package.jar.type=uber-jar

Run the über-jar with:

java -jar target/*-runner.jar

Creating a Native Executable

To create a native executable:

./mvnw package -Dnative

Or, if you don't have GraalVM installed, use a container for the native build:

./mvnw package -Dnative -Dquarkus.native.container-build=true

Run your native executable with:

./target/thiago-code-1.0.0-SNAPSHOT-runner

For more information on native executables, consult Quarkus Native Guide.

API Endpoints

Services

  • GET /servicos
    Retrieve all services. VSCode Screenshot

  • GET /servicos/{id}
    Retrieve a specific service by ID.

  • POST /servicos
    Create a new service.
    Request Body Example:

    {
      "id": 1,
      "name": "Service Name",
      "description": "Service Description"
    }
  • PUT /servicos
    Update an existing service.
    Request Body Example:

    {
      "id": 1,
      "name": "Updated Service Name",
      "description": "Updated Description"
    }
  • DELETE /servicos/{id}
    Delete a service by ID.

Users

  • GET /users
    Retrieve all users.

  • GET /users/{id}
    Retrieve a specific user by ID.

  • POST /users
    Create a new user.
    Request Body Example:

    {
      "id": 1,
      "name": "User Name",
      "cpf": "12345678901"
    }
  • PUT /users
    Update an existing user.
    Request Body Example:

    {
      "id": 1,
      "name": "Updated User Name",
      "cpf": "09876543210"
    }
  • DELETE /users/{id}
    Delete a user by ID.

Service Requests

  • POST /solicitacoesServicos
    Create a new service request.
    Request Body Example:

    {
      "userId": 1,
      "servicoId": 2,
      "status": "PENDING"
    }
  • GET /solicitacoesServicos
    Retrieve all service requests.

  • GET /solicitacoesServicos/{id}
    Retrieve a specific service request by ID.

  • PUT /solicitacoesServicos/{id}
    Update the status of a service request.
    Request Body Example:

    {
      "status": "COMPLETED"
    }
  • DELETE /solicitacoesServicos/{id}
    Delete a service request by ID. Insomnia Screenshot

Related Guides

Frontend Preview

Frontend Preview

Author

Thiago-Hercules

About

CRUD API built with SOLID principles using JDK 22, Quarkus 3.12.3, Maven 3.9.8, MySQL and Docker 4.32.0, as of now.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages