This project was developed with python 3.10, using Django Rest Freamework. To the developing envorinment was used Sqlite3.
Professionals who work in a freelance job referral network and need to buy, sell, or exchange technology products (laptops, mouses, keyboards, etc.) that allow them to perform their work quickly, optimizing their costs with work structures.
- A RESTful API must be developed to meet the functional requirements of the presented visual project.
- In this API, there are a total of 7 entities, the 3 main entities are: user, negotiation, and offer.
- In addition to the 3 main entities, we have: messages, freight, payment, and invitation. The relationship would be:
- User can generate multiple invitations;
- An invitation is linked to a new user registration;
- A user carries out multiple negotiations;
- A user sends multiple offers in a negotiation;
- A user sends and receives multiple messages linked to a negotiation;
- A payment is associated with a negotiation and is made by a user;
- Each created endpoint, with its respective method, must receive parameters, if applicable, such as JSON object. These parameters are available in the endpoint description.
- Every endpoint will return a JSON.
- Authentication will be done using JWT (JSON Web Token). All endpoint returns must have the correct HTTP Code for the return action.
- Correct the behavior of picture updates, as currently they are duplicating the image instead of deleting or replacing it.
- Implement a payment method and link the payment to the bid to validate the sale acceptance.
- Add filters to the endpoints that return a list.
- During delivery consultation, return a list of all available methods.
- Improve the error messages.
After completing the following steps, the documentation will be available at these addresses.
To run the following steps, make sure you are in the folder ecommerce_api
.
-
Create a Python 3.10 virtual environment.
python -m venv venv && source venv/bin/activate
-
Install the requirements.
pip install -r requirements.txt
-
Run the “migrations”, to create the initial database schema.
python manage.py makemigrations && \ python manage.py migrate
-
Create a superuser to begin using the API and get access to the admin dashboard.
python manage.py createsuperuser
-
Run the project.
python manage.py runserver
Before proceeding with the following steps, ensure that you are in the root of the project and have Docker and Docker Compose installed in your environment.
Run the next command to build the container.
docker-compose up --build
This command will execute all steps, listed under Execução local (sem o uso do docker)..
The default user to admin dashboard is:
- Username: admin
- Password: admin
These configs, can be modified in the docker-compose.yml
file, by changing the values for the DJANGO_ADMIN_USER and DJANGO_ADMIN_PASSWORD arguments.
Once the API is running, these links can be used.
Admin Dashboard: http://127.0.0.1:8000/admin/ Swagger Documentation: http://127.0.0.1:8000/swagger/ Redoc Documentation: http://127.0.0.1:8000/redoc/
The API uses path versioning and currently supports v1
and v2
. The version number must be included at the beginning of the path.
The final url must like this http://127.0.0.1:8000/api/v1/authenticate/
.
- POST: /{version}/authenticate/
- DELETE: /{version}/authenticate/
- POST: /{version}/authenticate/refresh/
- GET: /{version}/deals/
- POST: /{version}/deals/
- GET: /{version}/deals/{id}/
- PUT: /{version}/deals/{id}/
- DELETE: /{version}/deals/{id}/
- GET: /{version}/deals/{deal_id}/bids/
- POST: /{version}/deals/{deal_id}/bids/
- GET: /{version}/deals/{deal_id}/bids/{id}/
- PUT: /{version}/deals/{deal_id}/bids/{id}/
- DELETE: /{version}/deals/{deal_id}/bids/{id}/
- GET: /{version}/deals/{deal_id}/messages/
- POST: /{version}/deals/{deal_id}/messages/
- GET: /{version}/deals/{deal_id}/messages/{id}/
- PUT: /{version}/deals/{deal_id}/messages/{id}/
- DELETE: /{version}/deals/{deal_id}/messages/{id}/
- GET: /{version}/deals/{deal_id}/payments
- POST: /{version}/deals/{deal_id}/payments
- GET: /{version}/deals/{deal_id}/deliveries
- GET: /{version}/users/
- POST: /{version}/users/
- GET: /{version}/users/invites/
- POST: /{version}/users/invites/
- GET: /{version}/users/invites/{id}/
- PUT: /{version}/users/invites/{id}/
- DELETE: /{version}/users/invites/{id}/
- GET: /{version}/users/{id}/
- PUT: /{version}/users/{id}/