The RedBag-Core is the main backend of the RedBag project, developed at Fatec Registro. It is responsible for managing user interactions, authentication, database operations, and API integrations, ensuring seamless communication between the system components.
Built with Java Spring Boot, this API provides a robust and scalable solution, acting as the central hub that connects the frontend application with the RedBag-Predictor, a microservice responsible for cataract diagnosis in dogs.
π Access the RedBag-Predictor for more details.
Before running this project, ensure you have the following installed:
- Java 17+
- Cloudinary Account
- RedBag-Predictor (must be running for prediction functionality)
- Docker (optional but recommended)
Clone this project to your local machine:
git clone https://github.com/MateusOK/Redbag-Core
Navigate to the project directory and build the JAR file:
mvn clean package
Modify the application.yaml
file to match your Cloudinary credentials, Predictor, and database URL:
datasource:
url: ${SPRING_DATASOURCE_URL}
driverClassName:
username: ${SPRING_DATASOURCE_USERNAME}
password: ${SPRING_DATASOURCE_PASSWORD}
cloudinary:
cloud-name: ${CLOUDINARY_CLOUD_NAME}
api-key: ${CLOUDINARY_API_KEY}
api-secret: ${CLOUDINARY_API_SECRET}
app:
prediction-url: ${REDBAG_PREDICTOR_URL}
docker build -t redbag-core .
docker run -p 8080:8080 \
-e SPRING_DATASOURCE_URL=your_database_url \
-e SPRING_DATASOURCE_USERNAME=your_db_user \
-e SPRING_DATASOURCE_PASSWORD=your_db_password \
-e CLOUDINARY_CLOUD_NAME=your_cloudinary_name \
-e CLOUDINARY_API_KEY=your_cloudinary_key \
-e CLOUDINARY_API_SECRET=your_cloudinary_secret \
-e PYTHON_API_URL=your_redbag_predictor_url \
redbag-core
If you prefer using an .env
file, create it and use the following command:
docker run --env-file .env -p 8080:8080 redbag-core
Once the container is running, check if the API is accessible by visiting:
http://localhost:8080/swagger-ui/index.html#/
To access Swagger documentation and view all available endpoints, start the application and visit:
Method | Route | Description |
---|---|---|
POST | /api/auth/register |
Register a new user |
POST | /api/auth/login |
Authenticate and generate a token |
PUT | /api/users |
Update user data |
Request:
{
"name": "John Doe",
"username": "JohnDoe",
"email": "[email protected]",
"password": "password"
}
Response:
{
"id": 1,
"name": "John Doe",
"username": "JohnDoe",
"email": "[email protected]"
}
Request:
{
"usernameOrEmail": "JohnDoe",
"password": "password"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR..."
}
Method | Route | Description |
---|---|---|
POST | /api/animals/{userId} |
Create a new animal |
GET | /api/animals/{userId} |
Retrieve all animals for user |
PUT | /api/animals/{userId}/{animalId} |
Update animal data |
DELETE | /api/animals/{userId}/{animalId} |
Delete an animal |
Request:
{
"name": "Dog",
"color": "#FFFFFF"
}
Response:
{
"userId": 1,
"name": "Dog",
"color": "#FFFFFF"
}
Method | Route | Description |
---|---|---|
POST | /predict |
Returns a preliminary diagnosis result |
POST | /predict/{animalId} |
Saves the result to the database |
Request:
curl -X POST "localhost:8080/predict" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "image=@/path/to/image.jpg"
Response:
{
"prediction": "unhealthy",
"confidence": 0.89
}
Request:
curl -X POST "localhost:8080/predict/{animalId}" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "image=@/path/to/image.jpg"
Response:
{
"prediction": "healthy",
"confidence": 0.78
}
Special thanks to all contributors to this project:
This project is licensed under the MIT License.