Rest API that handles all the logic of tickets, users, and requests for administrative purposes of the Food Bank - Guadalajara. The endpoints of this API aim to work with any client, a web or mobile application.
- Developer: Superadmin.
- Admin: They can approve or reject user sign-ups. They can assign tickets to users. They can manage all the tickets, users (not devs) and requests.
- Employee: Can create and update tickets. They can see the tickets and requests assigned to them or created by them. They can create a request to the admin to authorize a process.
- Python 3.12.4
- FastAPI
- MongoDB
- Mailgun (for email sending)
- AWS (for file storage)
- Heroku (for deployment)
- Pytest (for testing)
- SonarCloud (for code quality)
- Ask for
.env
variables, follow.env.example
and create a local.env
file with the correct values. - Create python env:
python -m venv env
- Activate env:
source env/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run API:
fastapi dev src/main.py
- Go to
http://127.0.0.1:8000/docs
to see the documentation on swagger.
Tha application works with MongoDB database, you can create your own instance in the cloud and follow the .env.example instructions to connect to it. Or run a local instance.
If you want to populate the database with some data, you can run the src/seed/seed.py
script using python -m src.seed.seed
- Create an account
- Create a cluster
- Create a database called
food-bank
- Install MongoDB locally
- Run the MongoDB service
- Create a database called
food-bank
Create an account in Mailgun and get the credentials, then set them in the .env
file. Then create templates for the emails in the Mailgun dashboard.
auth-request
: Template name for the email that is sent to the admin when a user signs up and needs approval to access the app.notification-user-auth
: Template name for the email that is sent to the user when an admin approves the sign up.notify-tickets
: Template name for the email that is sent to the user is assigned to a ticket.
In this project, we use AWS S3 to store images. To use this service you need to create an account, get the credentials and set them in the .env
file. Then you need to create a bucket and set the permissions to allow public access to the images, the bucket name should be called
food-bank-bucket
.
To run unit tests you can use pytest
command.
Go to the API documentation to see the endpoints and try them out. The credentials to access the API are:
- Email: dev@example.com
- Password: dev
- Email: admin@mail.com
- Password: admin
- Email: employee@example.com
- Password: employee