Adopet is a platform designed to connect people who want to adopt pets with shelters. The platform provides an intuitive interface and robust backend to streamline the adoption process, making it easier for shelters and adopters to find the perfect match.
The project consists of:
- A Spring Boot API that stores people and animal shelters with endpoints to access and modify the data, including endpoints to access pets from a specific shelter, see only pets that aren't adopted yet and an endpoint to connect animal shelters with people interested in their pets.
- An Angular application to navigate through the endpoints in a friendly way, taking care of the authentication with jwt and sending some parameters automatically.
The final CS50x project needed to be something of my interest, that I solved an actual problem, that I impacted my community, or that I changed the world. So I thought that this idea of project was going to be perfect for that.
The project was developed in sprints lasting 1 week each, which had certain activities to be implemented. For better management of activities, trello was used.
- Built with Spring Boot for a robust and scalable backend.
- Frontend developed using Angular for a dynamic and responsive user experience.
- Fully containerized with Docker for simple deployment.
- Persistent data management with PostgreSQL.
I really wanted to try building something with Angular, after a lot of tutorials and documentations on the internet, I managed to build the front-end for the Spring API, and I am very proud of it.
The plan at first was going to have the API use authentication with OAuth and have the user login with GitHub and Google, but after a lot of time trying to learn how to implement it, I decided to use JWT to handle authentication, with has a lot easier.
- POSTS for
/auth,/tutoresand/abrigosdon't need authentication. - Requests for "
/tutores" requires the user to have the role "tutor". - The
/pets/adoptendpoint is open to anyone to see the pets available. - The
/abrigos/{id}endpoint is allowed for the role "tutor" to get the contact information. - The endpoints
/adocao,/pets,/abrigosrequire the user to have the role "abrigo".
- The controllers use jakarta.validation annotations to make sure that all the information store is adequate;
- The API uses JPA to connect to the PostgreSQL database running inside a docker container;
- AbrigoEntity and TutorEntity extends UserEntity, that contains the properties email, password and authorities; that facilitates the login process, having to search in one table for two possible entities, since the inheritance strategy for the entities is of type JOINED.
- Entities use UUID as their ids, with makes very unlikely that someone guesses the id of another person, but can also be inconvenient for the users when trying to get a entity by the id.
GlobalControllerExceptionHandler.java treats all the exceptions that can (or shouldn't) happen;
MapStructMapper.java builds mappers automatically just based on method signatures, saving a lot of time;
EncodeDecorator.java makes sure that all the entities with passwords, have them encoded before being saved;
SecurityConfig.java takes care of the security of the API, with CORS configuration for only the Front-End to be able to connect,
provides authentication related @Beans and secure endpoints based on roles;
TokenService.java validates the Json Web Tokens and generates then, sending the token with the subject (user email) and expiration date,
with the token also comes the expiration date again, user roles and the user id (to facilitate on the Front-end);
TokenAuthenticationFilter.java is a filter that sees every request and makes sure that the users who sent the "Bearer token"
can access the secured endpoints.
The API gets build for production using the command ./gradlew bootBuildImage.
- The design is based in this React project from this repository: https://github.com/sucodelarangela/adopet
- The
/homeendpoint shows all the pets that are not adopted yet, and the user does not need to be authenticated. - To get the animal shelter's contact information, the user needs to be authenticated and have the role "tutor".
- When the user gets authenticated and have the role "abrigo", it gets redirected to the
/petsendpoint, that shows all the pets registered from that animal shelter, and allows it to register a new pet. - When the user gets authenticated and have the role "tutor", it gets redirected to
/homeendpoint.
auth-interceptor.ts makes sure that all the requests for the API have the "Authentication" header with the Bearer token;
abrigo-auth.guard.ts and tutor-auth.guard.ts blocks users that doesn't have the "abrigo" and "tutor" roles;
login.service.ts takes care of the authentication; sends the login requests to the API and stores the response in
the local storage, checks users roles and logout the user, removing all the items in the local storage;
The Angular Front-end uses a Dockerfile to build.
Developing the Front-End gave me a lot of new ideas to add to the project that I ended up with no time left to finish it properly.
I definitely will continue to develop the project to polish it and finish completely, like adding a page to show details of the
logged-in user and the ability to logout, and a feature to send messages directly to the animal shelter via the API.
The Angular app is running on GitHub Pages and the Spring Boot API is running on a Google Cloud Virtual Machine, with DNS and HTTPS from Cloudflare.
The links to access are:
- Angular application https://adopet.marujo.site
- Spring Boot API https://api.marujo.site
To run locally you need to have Docker installed.
- Clone project
git clone https://github.com/WesleyMime/Adopet.git
- Enter the project folder
cd adopet
- Start services
docker compose up
The links to access are:
- Angular application http://localhost
- Spring Boot API http://localhost:8080
Distributed under the MIT license. See LICENSE.txt for more information.


