This microservice provides real-time rental price predictions through a RESTful API interface. Built with a production-grade MLOps architecture, it transforms a machine learning model into a scalable, maintainable API service.
The application follows a modular microservice architecture:
app/
├── api/ # API endpoint definitions
│ ├── prediction.py # Prediction endpoints
│
├── config/ # Configuration management
│ ├── __init__.py
│ ├── logger.py
│ └── model.py
├── logs/ # Application logs
├── model/ # ML model artifacts
├── schema/ # Data validation schemas
│ └── apartment.py
└── services/ # Business logic layer
├── model_inference.py
└── run.py
- Framework: Flask
- ML Model Serving: Custom inference service
- Data Validation: Pydantic
- Poetry (Dependency Management)
- Ruff (Code Quality)
- GitHub Actions (CI/CD)
- Make (Automation)
- Python 3.9+
- Poetry
- Make (optional)
Clone the repository:
git clone https://github.com/Mohammed-abdulaziz-eisa/Rental-Price-Prediction-App-to-Micro-Transformation-API-Development.git
cd Rental Price Prediction App to Micro Transformation API Development
Install dependencies:
poetry install
Configure environment:
cp .env.example .env
# Edit .env with your configurations
Start the API server:
poetry run python3 run.py
or
make runner
# it will install dependencies and run the server
Make predictions:
curl -X POST http://localhost:5000/predict \
-H "Content-Type: application/json" \
-d '{
"area": 85,
"construction_year": 2015,
"bedrooms": 2,
"garden_area": 20,
"balcony_area": 1,
"parking_present": 1,
"furnished": 0,
"garage_present": 0,
"storage_present": 1
}'
Predicts rental price based on apartment features.
Request Body Schema:
{
"area": int,
"bedrooms": int,
// Additional features as defined in schema/apartment.py
}
Response:
{
"predicted_price": float,
}
The project uses Ruff for code formatting and linting:
poetry run ruff format .
poetry run ruff check .
# also you can use flake8 for linting
poetry run flake8 .
poetry run pytest
Logs are stored in app/logs/app.log
with the following levels:
- INFO: General application flow
- WARNING: Unexpected but handled situations
- ERROR: Application errors requiring attention
- DEBUG: Detailed information for development
The application is containerized and can be deployed using Docker:
docker build -t rental-price-api .
docker run -p 5000:5000 rental-price-api
The application includes basic monitoring endpoints:
/health
: API health check/metrics
: Basic performance metrics
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'feat: add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Mohamed-abdulaziz-eisa - [mohamed.abdulaziz.eisa@gmail.com]