This project is a FastAPI-based service that leverages OpenAI and Foursquare Places API to find restaurants based on natural language queries.
The application is containerized with Docker, deployed via Terraform (IaC), and integrated with GitHub Actions for CI/CD.
-
Healthcheck
GET /api/ping– Simple ping endpoint to verify that the API is running.
-
Restaurant Finder
GET /api/execute-
Accepts a natural language message (e.g., “Find me Japanese restaurants near Manila with good ratings”).
-
Calls OpenAI to parse the message into a structured JSON request accepted by Foursquare Places API.
-
Returns a standardized Restaurant DTO:
class RestaurantDto(BaseModel): name: str cuisine: str address: str operating_hours: str | None = None rating: float | None = None price_level: int | None = None
-
-
Infrastructure
- Terraform for infrastructure as code (
/infra). - GitHub Actions for automated builds & pushing Docker images to ECR.
- Optional CloudWatch support.
- Terraform for infrastructure as code (
-
Domain
- Configured with DuckDNS for custom domain setup.
- Python 3.11+
- Poetry for dependency management
- Docker (for containerized builds)
- Terraform (if you want to deploy infra)
- OpenAI and Foursquare API keys (for
/api/execute)
# Install dependencies
poetry install
# Activate virtual environment
$(poetry env activate)
# Run the app
python -m appThe API will be available at http://localhost:8000. Interactive Swagger docs: http://localhost:8000/docs
The project uses pytest. Note that you’ll need valid API keys for OpenAI and Foursquare:
OPENAI_API_KEY=your_key \
FOURSQUARE_SERVICE_KEY=your_key \
pytest -svBuild and run with Docker:
# Build image
docker build -t restaurant-finder-api .
# Run container
docker run --env-file .env -p 8000:8000 restaurant-finder-apiTerraform is used to provision infra in AWS:
cd infra
terraform init
terraform apply
⚠️ Don’t forget to build and push the Docker image to AWS ECR before applying Terraform.
| Variable | Description | Required |
|---|---|---|
OPENAI_API_KEY |
OpenAI API key | ✅ |
FOURSQUARE_SERVICE_KEY |
Foursquare API key | ✅ |
CW_LOG_GROUP_NAME |
CloudWatch Log Group name | ❌ |
CW_NAMESPACE |
CloudWatch namespace for custom metrics | ❌ |
INSTANCE_ID |
EC2/ECS instance identifier for metrics | ❌ |
This project uses DuckDNS for domain management. Update DNS accordingly after deployment.
- Save requests/responses (parsing) from OpenAI for dataset
- Add caching layer for frequent queries
- Improve test coverage (mock OpenAI & Foursquare calls)
- Expand infra to support multi-region deployments
- Add JWT authentication/authorization
- Expand
SearchPlacesDtoto accomodate other query