brunomcr / 1MLET_FASE1_TECH_CHALLENGE

Embrapa API
1 stars 0 forks source link
api-rest docker mongodb python webscrapper

1MLET_FASE1_TECH_CHALLENGE

Overview

This API is part of the Machine Learning Engineering FIAP Pos-Tech program. It provides a programmatic way to access data from the Embrapa website and allows users to retrieve relevant information through well-defined endpoints.

Project Requirements

Solution Architecture Diagram

1MLET_FASE1_TECH_CHALLENGE.drawio.png

Dependency and Control Flow Diagram

Grafico_Dependencia_Fluxo_Controle_API.png

Subsystem Sequence Diagram

uml.drawio.png

Prerequisites

Configuration

Environment Variables

The application uses environment variables for configuration. Ensure the following variables are set:

You can set these variables in a .env file in the root directory:

MONGO_INITDB_ROOT_USERNAME=your_mongo_username
MONGO_INITDB_ROOT_PASSWORD=your_mongo_password
JWT_SECRET_KEY=your_jwt_secret_key
JWT_ALGORITHM=HS256
JWT_TOKEN_EXPIRE_MINUTES=15

Usage Instructions

Running with Docker

Build and Start with Docker Compose

docker-compose up --build -d

Populating the Database

First you have to scrap the Embrapa website data by running the following command:

python -m src.helpers.scrapper.async_web_scrapper

Alternatively you can uncomment the web-scrapping portion from app.py.

The database is populated automatically when the application starts for the first time.

API Documentation

The API provides endpoints for accessing production, processing, trade, import, and export data from the Embrapa website.

Endpoints

How to use:

Generate the token:

curl -X GET \
  "http://localhost:8000/auth/token" \
  -H  "accept: application/json"

Use the generated token to fetch information from endpoints. Below is the example:

curl -X GET \
  "http://127.0.0.1:8000/production/2022" \
  -H "accept: application/json" \
  -H "Authorization: Bearer <your-token>"

Alternatively, the project has a collection of endpoint calls that can be called by Bruno and can also be used by the swagger documentation.

Contributors (Group 43)