https://github.com/ecureuill/milhasapi
API developed as resut of the 7th Back-end Challenge of Alura.
https://github.com/ecureuill/milhasapi
ai allura alura-challenge alura-challenges alurachallenges flywaydb java mockmvc mysql openai-java spring-boot vitrinedev
Last synced: 3 months ago
JSON representation
API developed as resut of the 7th Back-end Challenge of Alura.
- Host: GitHub
- URL: https://github.com/ecureuill/milhasapi
- Owner: ecureuill
- Created: 2023-07-27T00:05:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-14T18:09:35.000Z (almost 2 years ago)
- Last Synced: 2025-01-18T01:42:42.950Z (5 months ago)
- Topics: ai, allura, alura-challenge, alura-challenges, alurachallenges, flywaydb, java, mockmvc, mysql, openai-java, spring-boot, vitrinedev
- Language: Java
- Homepage:
- Size: 409 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: .github/README.md
Awesome Lists containing this project
README
# :airplane: Milhas API




The goal is to provide information and resource related to possible travel destinations, showing photos, texts and also resources about testimonials from other travelers. In addition to integrating AI into your application.
-------------
## :mag: Table Of Content
- [About](#scroll-about)
- [Used Technologies](#used-technologies)
- [The Challenge](#dart-the-challenge)
- [Project Steps](#project-steps)
- [Walkthrough](#footprints-walkthrough)
- [API Doc](#scroll-api-doc)
- [Running Locally](#rocket-running-locally)## :scroll: About
API in development to the [7th Back-end Challenge](https://www.alura.com.br/challenges/back-end-7/) of Alura.
### Used Technologies:
- Language: Java
- Framework: Spring Boot
- Migration Tool: Flywaydb
- Documentation: SpringDoc Swagger
- OpeanAI Integration: [openai-java](https://github.com/TheoKanning/openai-java)
- Other libraries: Lombok, DataFaker
- Database: MySQL
- Development environment: Docker
- Code Editor: VS Code## :dart: The Challenge
> In this 7th Backend challenge, we are going to develop an API that will be integrated with Frontend. Our challenge is to provide information and resources from the database related to possible travel destinations, displaying photos and eye-catching text that encourages the user to want to visit that destination.
>
> In addition, we will also provide resources on testimonials from other travelers and, finally, we will integrate AI into our application.### Project steps
- **First Week**
- [x] **Testimonial CRUD** Create `/depoimentos` endpoint to perform CRUD operations.
- [x] **Random Testimonials**: Create `depoimentos-home` endpoint to show 3 random testimonials
- [x] **CORS** Enable CORS request from any origin on the development phase.
- [x] **Test** Verify the status code of GET, POST, PUT, DELETE of `/depoimentos` endpoint- **Second Week**
- [x] **Destination CRUD** Create `/destinos` endpoint to perform CRUD operations.
- [x] **Search Destination** by name.
- [x] **Test** `destinos` endpoint- **Third and Fourth Week**
- [x] **Update `destinos` endpoint** with the fields
- id
- Photo 1
- Photo 2
- Name
- Meta (max 160 characters)
- Description text (optional)
- [x] `/destinos/{id}` endpoint should retrieve
- Photo 1
- Photo 2
- Name
- Meta
- Description text
- [x] **AI integration** to generate description about destination, in case of some destination has no description
- [x] **Test** `destinos` endpoint## :footprints: Walkthrough
Check my steps to develop this project [here](DEV_WALKTHROUGH.md)
## :scroll: API Doc
This projects uses [SpringDoc](https://springdoc.org/) (Swagger) to generate API documentation. You can check it by runing the project and accessing [swagger-ui](localhost:8080/swagger-ui/index.html)
## :rocket: Running locally
```bash
# clone the repository
git clone https://github.com/ecureuill/milhasapi.git# Navigate to the cloned directory
cd milhasapi
```MilhasAPI uses MySQL as the database. Create a MySQL database, named **milhasapi** and update the database configuration in `src/main/resources/application.properties` file:
```bash
spring.datasource.url=jdbc:mysql://[URL]:[PORT]/milhasapi
spring.datasource.username=[USERNAME]
spring.datasource.password=[PASSWORD]
```
MilhasAPI is integrated to ChatGPT to generate destination description. Create an API key on [openai platform](platform.openai.com) and export it as environmet variable.```bash
export OPENAI_KEY=123
```
Run the project```bash
mvn spring-boot:run
```To use this API, you can make HTTP requests to the provided endpoints using tools like cURL or Postman.