Skip to content

zlucasftw/alura-curso-java-spring-boot-3-documente-teste-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Med Voll API πŸ₯

Java Jakarta EE Spring Boot Spring Security Spring Data JPA Flyway JUnit Mockito Maven MySQL IntelliJ IDEA Insomnia Swagger

Clique aqui para acessar o README PT-BR

πŸ“‹ Description

Med Voll API is a robust healthcare management system built with Java and Spring Boot 3. This project was developed as part of the course "Spring Boot 3: Document, Test, and Prepare an API for Deployment". It provides comprehensive functionality for managing patients, doctors, and medical appointments, offering seamless operations for registration, listing, updating, and deletion of records.

πŸ› οΈ Technologies

  • Java: Core programming language
  • Jakarta Validation: Data validation
  • Spring Boot 3: Latest version of the application framework
  • Spring Data JPA: Database operations
  • Spring Security: Authentication and authorization
  • Flyway: Database migration tool
  • Maven: Dependency management and build automation
  • MySQL: Database management system
  • Swagger: API documentation
  • IntelliJ IDEA: Integrated development environment
  • Insomnia: API testing and development tool

πŸ“ Project Structure

src/main/java/med/voll/api/
β”œβ”€β”€ controller/     # API endpoints
β”œβ”€β”€ domain/        # Business logic and repositories
└── infra/         # Configurations and infrastructure

πŸ”„ API Endpoints

πŸ‘€ Patients

Method Endpoint Description
POST /pacientes Register new patient
GET /pacientes List active patients
GET /pacientes/{id} Get patient details
PUT /pacientes Update patient info
DELETE /pacientes/{id} Deactivate patient

πŸ‘¨β€βš•οΈ Doctors

Method Endpoint Description
POST /medicos Register new doctor
GET /medicos List active doctors
GET /medicos/{id} Get doctor details
PUT /medicos Update doctor info
DELETE /medicos/{id} Remove doctor

πŸ“… Appointments

Method Endpoint Description
POST /consultas Schedule appointment
DELETE /consultas Cancel appointment

πŸ“š API Documentation

Access the API documentation through Swagger. Configuration example:

@Configuration
public class SpringDocConfigurations {
    
    @Bean
    public OpenAPI customerOpenAPI() {
        return new OpenAPI()
                .components(new Components()
                        .addSecuritySchemes("bearer-key",
                                new SecurityScheme()
                                    .type(SecurityScheme.Type.HTTP)
                                    .scheme("bearer")
                                    .bearerFormat("JWT")));
    }
}

πŸš€ Getting Started

Prerequisites

  • Java 17+
  • Maven
  • MySQL Server
  • IntelliJ IDEA (recommended) or your preferred IDE

Spring Initializr

To quickly set up the project using Spring Initializr:

  1. Go to Spring Initializr
  2. Select the following options:
    • Project: Maven Project
    • Language: Java
    • Spring Boot: 3.0.0 (or the latest stable version)
    • Project Metadata:
      • Group: med.voll
      • Artifact: api
      • Name: medvoll-api
      • Package Name: med.voll.api
      • Packaging: Jar
      • Java: 17+
  3. Add the following dependencies:
    • Spring Web
    • Spring Data JPA
    • Spring Security
    • MySQL Driver
    • Flyway Migration
    • Spring Boot DevTools
  4. Click on Generate to download the project as a zip file.
  5. Extract the zip file and open it in IntelliJ IDEA.

Database Setup

  1. Create a MySQL database for the project
  2. Create a .env file in the project root with the following variables:
DB_ADDRESS=YOUR_DATABASE_ADDRESS
DB_NAME=YOUR_DATABASE_NAME
DB_USER=YOUR_DATABASE_USER
DB_PASSWORD=YOUR_DATABASE_PASSWORD
JWT_SECRET=YOUR_JWT_SECRET

Application Properties

The project uses the following configuration in application.properties:

spring.config.import=file:.env[.properties]

spring.datasource.url=jdbc:mysql://${DB_ADDRESS}/${DB_NAME}
spring.datasource.username=${DB_USER}
spring.datasource.password=${DB_PASSWORD}

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

server.error.include-stacktrace=never

api.security.token.secret=${JWT_SECRET:12345678}

Installation Steps

  1. Clone the repository:
git clone https://github.com/zlucasftw/alura-curso-java-spring-boot-3-documente-teste-deploy.git
  1. Navigate to project directory:
cd alura-curso-java-spring-boot-3-documente-teste-deploy
  1. Create and configure the .env file as described above

  2. Run the application:

mvn spring-boot:run

The application will start and Flyway will automatically run the database migrations.

Verifying the Installation

  1. The application will be available at http://localhost:8080
  2. Access the Swagger documentation at http://localhost:8080/swagger-ui.html
  3. Test the endpoints using Insomnia or your preferred API testing tool

🀝 Contributing

Contributions are welcome! Feel free to:

  • Open issues
  • Submit pull requests
  • Suggest improvements

πŸ“„ License

This project is licensed under the AGPL V3 License - see the LICENSE file for details.


Part of the course "Spring Boot 3: Document, Test, and Prepare an API for Deployment"

About

Project part of the course "Spring Boot 3: Document, Test, and Prepare an API for Deployment"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages