This project was migrated from Flask to FastAPI to improve performance and provide automatic API documentation. It now uses RabbitMQ for asynchronous message queueing, while MongoDB keeps message status history and webhook configuration.
- Framework: Migrated from Flask to FastAPI
- Main file:
main.py(previouslyapp.py) - Documentation: Automatic Swagger UI available at
/docs - Validation: Pydantic models for data validation
- Performance: Improved performance with FastAPI
- Async messaging: RabbitMQ queue for async sends (
/sendMessageAsync) with status persisted in MongoDB
- Home page with API documentation
- Sends text message via WhatsApp
- Parameters:
phone(string, max 22 chars),text(string, max 800 chars)
- Sends text message via WhatsApp (GET method)
- Parameters:
phone(string, max 22 chars),text(string, max 800 chars)
- Sends message with URL via WhatsApp
- Parameters:
phone(string, max 22 chars),text(string, max 800 chars)
- Sends message with URL via WhatsApp (GET method)
- Parameters:
phone(string, max 22 chars),text(string, max 800 chars)
Access the interactive API documentation (Swagger UI) at /docs:
Access /docs to view the interactive API documentation (Swagger UI).
docker compose up --buildpip install -r IaC/flask/requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000- By default, Selenium runs hidden (
headless) inmain.pywith:WINDOW_SHOW_DEBUG = False
- To show the browser window for debugging, change it to:
WINDOW_SHOW_DEBUG = True
- Rebuild and restart containers after changing this value:
docker compose down
docker compose up -d --buildThe VNC server is exposed on host port 5914 (see 5914:5914 in docker-compose.yml). After the stack is up, confirm the port is listening before opening the viewer:
ss -tln | grep 5914Or test TCP connectivity:
nc -zv 127.0.0.1 5914With Docker Compose, you can also show the published mapping for the service port:
docker compose port fastapi 5914- Open the container desktop via VNC:
gvncviewer 127.0.0.1:5914- If you use TigerVNC:
vncviewer 127.0.0.1:5914- When the VNC client asks for a password, use:
V0oiye3R
├── 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
Configure the following variables in the .env file:
MONGOUSER: MongoDB usernameMONGOPASSWORD: MongoDB passwordMONGODB: Database nameFASTAPIPORT: Application port (default: 8000)FASTAPINAME: Container name (default: fastapi-app)RABBITMQ_USER: RabbitMQ usernameRABBITMQ_PASS: RabbitMQ passwordTZ: Container timezone (IANA time zone name). Affects system time, Python, and the Chrome session used for WhatsApp Web. If unset, Compose defaults toUTC.
The FastAPI service image includes tzdata and passes TZ from your .env (see docker-compose.yml). Without it, the container often runs in UTC, so message times in WhatsApp Web can look offset from your local time.
- Set
TZin.envto your region (examples below). - Restart the stack:
docker compose down && docker compose up -d --build(rebuild once after pulling changes that addtzdata).
Find your zone name
- Full list of identifiers: Wikipedia — tz database time zones (column TZ identifier is what you put in
TZ). - Pick a city on the map: timeanddate.com — world clock (use the matching IANA name from the list above if the site shows only a label).
| Region / use case | TZ value (IANA) |
|---|---|
| Brazil (Brasília) | America/Sao_Paulo |
| Portugal | Europe/Lisbon |
| Spain (peninsula) | Europe/Madrid |
| United Kingdom | Europe/London |
| US Eastern | America/New_York |
| US Pacific | America/Los_Angeles |
| UTC | UTC |
- Copy the example file:
cp env.example .env- Edit the
.envfile with your settings:
nano .env- Run the project:
docker compose up --buildDeveloped by Victor Luis Santos
LinkedIn

