This project is a FastAPI-based application that predicts housing prices in California based on various features. The application is containerized using Docker and includes monitoring with Prometheus and Grafana.
- Docker
- Docker Compose
git clone https://github.com/yourusername/california-housing.git
cd california-housing- Build the Docker images:
docker-compose build - Run the docker containers:
docker-compose up -d - The FastAPI application will be accessible at http://localhost:8000
- Prometheus will be accessible at http://localhost:9090
- Grafana will be accessible at http://localhost:3000
-
Start the FastApi Server
python src/app.py -
Open your browser and go to
http://127.0.0.1:8000/docsto access the swagger API documentation. -
Make a post request to
/predictendpoint to get the prediction with the required fields
src/: Source code for the applicationapp.py: Main application filemodel.py: Model loading and saving functionsdata_download.py: Script to download and load data
models/: Directory to store the trained modelsdata/: Directory to store data filesrequirements.txt: List of dependenciesDockerfile: Dockerfile to build the Docker imagedocker-compose.yml: Docker Compose file to run the application and monitoring services.gitignore: Git ignore file to exclude unnecessary files
The application includes monitoring with Promethius and Grafana
- Promethius is configfured to scrape metrics from the FastApi Application
- Grafana is configured to visualize the metrics captured by Prometheus
To deploy to the Docker container to AWS, you can use AWS Elastic Beanstalk, ECS (Elastic Container Service) or EKS (Elastic Kubernetes Service).
-
Install AWS Elastic Beanstalk CLI
pip install awsebcli -
Initialize the EB application
eb init -p docker your-app-name -
Create elastic beanstalk environment to deploy the application
eb.create your-env-name -
Open the app in web browser
eb open
Replace yourusername, your-app-name, and your-env-name with appropriate names for your application and environment. This will deploy your Docker container to AWS Elastic Beanstalk and make your application accessible via a public URL.
License This project is licensed under the MIT License.