This repository handles the backend functionalities of FindAFriend, an API designed for pet adoption. The API allows organizations to register and management pets available for adoption. Users can search for pets and find nearby organizations. The backend is built with Domain-Driven Design (DDD) and Clean Architecture principles.
- 🛠️ Features
- 🚀 Technologies Used
- 💾 Setup and Installation
- ⚙️ How to Run
- 📚 API Documentation
- 🛣️ Application Routes
- 🧪 Running Tests
-
Pet Registration and Management: Organizations can register, edit and delete pets available for adoption, including details like breed, age and energy level.
-
Pet Search: Users can search for pets available for adoption based on different criteria (e.g., city, age, breed).
-
Nearby Organizations: Users can search for organizations near them to find pets available for adoption.
-
Nest.js - A progressive Node.js framework.
-
Prisma - ORM for database access.
-
Vitest - Unit and e2e testing.
-
Docker - Containerization for execution.
-
JWT - Used for secure user authentication and authorization.
- Clone the repository:
https://github.com/DanielF-Cardoso/FindAFriend.git
- Run Docker: To use Postgress service with Docker
docker-compose up -d
- Set up environment variables: Create a .env file based on the provided example
cp .env-example .env
- Install dependencies:
npm install
- Set up the database: Ensure Prisma is properly configured and apply migrations
npx prisma migrate dev
- Run the application locally:
npm run start:dev
- Run the application in production: Build the project and run it using the compiled files:
npm run build npm run start
The API includes a complete Swagger documentation that can be accessed at the following route after starting the server:
http://localhost:3333/api/docs
-
POST /orgs
Register a new organization. -
POST /orgs/auth
Authenticate an organization and return a JWT token. -
GET /orgs/nearby
Find nearby organizations based on geographic coordinates (latitude and longitude). -
DELETE /orgs/pets/{id}
Delete a specific pet belonging to an organization. (Requires authentication) -
PUT /orgs/pets/{id}
Update details of a specific pet belonging to an organization. (Requires authentication) -
POST /orgs/pets
Register a new pet for adoption. (Requires authentication)
-
GET /pet/{id}
Retrieve details of a specific pet. -
GET /pets/search
Search for pets based on criteria such as city, age, or breed.
- Run the Unit test:
npm run test
- Run the Unit tests in watch mode:
npm run test:watch
- Run the Unit tests with coverage:
npm run test:cov
- Run end-to-end tests:
npm run test:e2e
- Run end-to-end tests in watch mode:
npm run test:e2e:watch