FastAPI backend service for Weni CLI.
- FastAPI-based REST API
- Poetry for dependency management
- Type hints and validation with Pydantic
- Structured project layout
- Configuration management with environment variables
- Linting with Ruff and Mypy
- Python 3.12 or higher
- Poetry
- Clone the repository:
git clone https://github.com/weni-ai/weni-cli-backend.git
cd weni-cli-backend- Install dependencies with Poetry:
poetry install- Create a
.envfile based on the example:
cp .env.example .env- Configure environment variables in the
.envfile.
# Using poetry
poetry run uvicorn app.main:app --reload --host=0.0.0.0 --port=8000
# Or activate the virtual environment first
poetry shell
python -m app.serverThe API will be available at http://localhost:8000.
poetry run pytest# Run ruff linter
poetry run ruff check .
# Run mypy type checker
poetry run mypy .The project includes Docker configuration for both development and production environments.
Run the application with hot reload for development:
docker-compose up api-devThe API will be available at http://localhost:8001.
Run the application in production mode:
docker-compose up apiThe API will be available at http://localhost:8000.
Build the production image:
docker build -t weni-cli-backend:latest -f docker/Dockerfile .Build the development image:
docker build -t weni-cli-backend:dev -f docker/Dockerfile.dev .Run the production container:
docker run -p 8000:8000 --env-file .env weni-cli-backend:latestRun the development container with mounted volume for hot reload:
docker run -p 8000:8000 -v $(pwd):/app --env-file .env weni-cli-backend:dev