InsureFlow is an end-to-end vehicle insurance prediction system built using MLOps principles. This project implements a fully automated machine learning pipeline integrated with a modern web interface, enabling users to input vehicle details and get accurate insurance predictions. It also includes a robust CI/CD pipeline for continuous integration and deployment.
- Project Overview
- Architecture
- Tech Stack
- Features
- Setup Instructions
- MongoDB Atlas Setup
- ML Pipeline Workflow
- CI/CD Pipeline
- Deployment
- Contributing
- License
InsureFlow is designed to predict vehicle insurance eligibility based on multiple input features using machine learning models. The project follows an MLOps pipeline, covering data ingestion, data validation, data transformation, model training, model evaluation, model pusher, and deployment. The front end allows users to submit their details and view predictions in real-time, while the backend handles data processing and model inference.
This project demonstrates advanced backend complexity through its modular architecture, incorporating data pipelines, machine learning model management, and scalable API endpoints. The backend leverages Python for ML operations, ensuring high performance and reliability in a production environment.
The architecture of InsureFlow is designed for scalability, modularity, and robustness, integrating MLOps practices with a full-stack web application.
flowchart TD
A[User Interface - React.js Frontend] --> B[Backend API]
B --> C[MongoDB Atlas Database]
B --> D[ML Prediction Pipeline]
D --> E[Data Ingestion Component]
E --> F[Data Validation Component]
F --> G[Data Transformation Component]
G --> H[Model Trainer Component]
H --> I[Model Evaluation Component]
I --> J[Model Pusher Component]
J --> K[Trained Model Storage]
D --> K
C --> E
classDef default fill:#ffffff,stroke:#000000,stroke-width:2px,color:#000000;
This diagram illustrates the flow from user input through the backend API to the ML pipeline components, highlighting the interconnected modules that handle data processing, model training, and inference.
The backend architecture is highly complex, featuring:
- Modular Component Design: Each ML pipeline stage (ingestion, validation, transformation, training, evaluation, pusher) is implemented as a separate, reusable component with dependency injection and configuration management.
- Data Pipeline Orchestration: Automated workflows manage data flow between components, including error handling, logging, and artifact versioning.
- Model Management System: Implements model versioning, performance tracking, and automated deployment of the best-performing models.
- Database Abstraction: Custom data access layers abstract MongoDB operations, supporting schema validation and efficient querying.
- Configuration and Environment Management: Centralized configuration entities manage hyperparameters, database connections, and deployment settings across environments.
- Exception Handling and Logging: Comprehensive error tracking and logging frameworks ensure reliability and debuggability in production.
- Cloud Storage Integration: S3-compatible storage for model artifacts and datasets, with estimator classes for seamless cloud operations.
- Core Libraries: ipykernel, pandas, numpy, matplotlib, plotly, seaborn, scikit-learn, pymongo, from_root, dill, certifi, PyYAML, imblearn, joblib, python-dotenv
- Database: MongoDB Atlas
- Pipeline: Docker Image, Docker Hub, GitHub Actions, CI/CD
- Deployment: Render, Docker Hub, Vercel
- End-to-End ML Pipeline: Automated pipeline for data processing, model training, evaluation, and deployment, incorporating advanced techniques like feature engineering and hyperparameter tuning.
- Continuous Integration & Deployment: GitHub Actions trigger the CI/CD pipeline on every push to the main branch, ensuring rapid iteration and quality assurance.
- Dockerized Deployment: Both the app and model are containerized for consistent environments, enabling seamless scaling and portability.
- Database Integration: MongoDB Atlas for seamless data storage and retrieval, with optimized queries and indexing for performance.
- Model Management: Only the best-performing model is stored and used for prediction, with automated model selection based on evaluation metrics.
git clone https://github.com/karangupta982/InsureFlow.git
cd insureflow# Create virtual environment
python -m venv venv
source venv/bin/activate # For Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtCreate a .env file in the root directory and add:
MONGODB_URL="mongodb+srv://<username>:<password>@cluster0.mongodb.net/<dbname>?retryWrites=true&w=majority"- Sign up at MongoDB Atlas.
- Create a project and cluster (M0 service).
- Set up a DB user and IP access (
0.0.0.0/0). - Get the connection string and update the
.envfile.
- Data Ingestion: Extracts data from MongoDB into a DataFrame, handling large datasets with efficient querying and pagination.
- Data Validation: Checks schema consistency using
config.schema.yaml, ensuring data quality and integrity before processing. - Data Transformation: Prepares the data for model training, including feature engineering, encoding categorical variables, and handling imbalanced datasets with SMOTE.
- Model Training: Builds and evaluates multiple models using scikit-learn, with hyperparameter optimization and cross-validation.
- Model Evaluation: Compares models and selects the best one based on metrics like accuracy, precision, recall, and F1-score.
- Model Pusher: Deploys the best model to
my-model-mlopsprojfor inference, with versioning and rollback capabilities.
- Dockerization: Built Docker images for both the backend and ML pipeline, using multi-stage builds for optimization.
- GitHub Actions: Configured workflows in
.github/workflows/aws.yamlto automate builds and deployments, including testing and security scans. - Docker Hub: Pushed Docker images to the Docker Hub repository for version control and distribution.
- Pipeline Trigger: Every push to the main branch triggers the CI/CD pipeline, ensuring continuous delivery.
- Backend: Deployed on Render using
npm startto launch the server, with environment variable management and health checks. - Frontend: Deployed on Vercel for fast, global CDN delivery.
- Database: MongoDB Atlas stores all user inputs and predictions with high availability and backup.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
feature/your-feature). - Commit changes and push to your branch.
- Create a pull request.

