Skip to content

This project was migrated from Flask to FastAPI to improve performance and provide automatic API documentation.

Notifications You must be signed in to change notification settings

victorluissantos/whatsApp-Bot-API

Repository files navigation

English Português Español

WhatsApp Bot API - FastAPI

This project was migrated from Flask to FastAPI to improve performance and provide automatic API documentation.

Main Changes

  • Framework: Migrated from Flask to FastAPI
  • Main file: main.py (previously app.py)
  • Documentation: Automatic Swagger UI available at /docs
  • Validation: Pydantic models for data validation
  • Performance: Improved performance with FastAPI

Available Endpoints

GET /

  • Home page with API documentation

POST /sendText

  • Sends text message via WhatsApp
  • Parameters: phone (string, max 22 chars), text (string, max 800 chars)

GET /sendText

  • Sends text message via WhatsApp (GET method)
  • Parameters: phone (string, max 22 chars), text (string, max 800 chars)

POST /sendMultText

  • Sends message with URL via WhatsApp
  • Parameters: phone (string, max 22 chars), text (string, max 800 chars)

GET /sendMultText

  • Sends message with URL via WhatsApp (GET method)
  • Parameters: phone (string, max 22 chars), text (string, max 800 chars)

System Screens

Home Screen

Home Screen

Swagger Screen

Access the interactive API documentation (Swagger UI) at /docs:

Swagger UI

API Documentation

Access /docs to view the interactive API documentation (Swagger UI).

Execution

With Docker Compose

docker compose up --build

Locally

pip install -r IaC/flask/requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000

Project Structure

├── main.py                 # Main FastAPI application
├── datasource/            # Data modules
├── static/               # Static files
├── templates/            # HTML Templates
├── IaC/flask/           # Docker configurations
│   ├── Dockerfile
│   ├── requirements.txt
│   └── entry_point.sh
└── docker-compose.yml

Environment Variables

Configure the following variables in the .env file:

  • MONGO_USER: MongoDB username
  • MONGO_PASSWORD: MongoDB password
  • MONGO_DB: Database name
  • FASTAPI_PORT: Application port (default: 8000)
  • FASTAPI_NAME: Container name (default: fastapi-app)

Initial Setup

  1. Copy the example file:
cp env.example .env
  1. Edit the .env file with your settings:
nano .env
  1. Run the project:
docker compose up --build

Contact

Developed by Victor Luis Santos
LinkedIn

About

This project was migrated from Flask to FastAPI to improve performance and provide automatic API documentation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published