Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Insurance Comparison, Recommendation & Claim Assistant

Python FastAPI React Vite TailwindCSS PostgreSQL Celery Redis License

An end-to-end full-stack web application that helps users compare insurance policies, get personalized AI recommendations based on a 12-factor risk profile, file and track claims, and receive real-time background email notifications on status updates.


πŸ“Œ About the Project

This platform was built to simplify the complex world of insurance for everyday users. Whether someone is looking for the right health, auto, home, life, or travel policy β€” this system analyses their personal profile and recommends the most suitable options.

Key Highlights:

  • Users fill in a 12-factor risk profile (age, occupation, health, lifestyle, etc.)
  • The recommendation engine scores and ranks all available policies
  • Users can purchase policies and file claims with document uploads (stored on AWS S3)
  • Admins review claims through a dedicated panel and update statuses
  • Every status update triggers an automatic background email to the user via Celery + Redis

✨ Features

πŸ‘€ User Features

Feature Description
Authentication Secure JWT-based login and signup
Dashboard Personalized policy recommendations with scores
Policy Catalog Browse Health, Auto, Home, Life, Travel policies
Compare Policies Compare up to 3 policies side-by-side
Premium Calculator Estimate premium based on age and coverage
Risk Profile 12-factor lifestyle and financial profile editor
My Policies View all purchased policies
File a Claim 5-step guided claim wizard with document uploads
Claim Timeline Live status history for each claim
Email Alerts Auto email when admin updates claim status

πŸ”‘ Admin Features

Feature Description
Admin Dashboard Stats on total claims, amounts, pending actions
Claims Queue Filter, search, and review all claims
Claim Detail Panel View full claim info, documents, and history
Status Transitions Strict workflow: Submit β†’ Review β†’ Approve/Reject β†’ Pay
Background Emails FastAPI triggers a Celery task (non-blocking) to email the user

🧱 Tech Stack

Layer Technology
Frontend React + Vite + Tailwind CSS
Backend FastAPI (Python)
Database PostgreSQL + SQLAlchemy
Auth JWT (python-jose)
File Uploads AWS S3
Background Tasks Celery + Redis
Email Python smtplib (Gmail SMTP)

πŸ–₯️ Prerequisites β€” Install These First

1. Git

2. Python 3.10+

3. Node.js v18+

4. PostgreSQL

  • Download: https://www.postgresql.org/download/
  • During install, set a password for the postgres user β€” remember it
  • Default port: 5432
  • After install, open pgAdmin and create a database named: insurance_db

5. Docker Desktop (for Redis β€” required for email notifications)


πŸ“₯ Step 1 β€” Clone the Repository

git clone https://github.com/springboardmentor053-cyber/Insurance-Comparison-Recommendation-Claim-Assistant.git
cd Insurance-Comparison-Recommendation-Claim-Assistant

βš™οΈ Step 2 β€” Backend Setup

2.1 Go to the backend folder

cd backend

2.2 Create and activate a virtual environment

python -m venv venv
venv\Scripts\activate

You should see (venv) at the start of the terminal.

2.3 Install all Python dependencies

pip install -r requirements.txt

2.4 Create the .env file

Inside the backend/ folder, create a file named .env and paste the following β€” filling in your own values:

# ─── App Security ──────────────────────
SECRET_KEY=your-random-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

# ─── PostgreSQL Database ───────────────
POSTGRES_USER=postgres
POSTGRES_PASSWORD=YOUR_POSTGRES_PASSWORD
POSTGRES_SERVER=localhost
POSTGRES_PORT=5432
POSTGRES_DB=insurance_db

# ─── AWS S3 (for document uploads) ─────
AWS_ACCESS_KEY_ID=YOUR_AWS_KEY
AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET
AWS_S3_BUCKET_NAME=YOUR_BUCKET_NAME
AWS_REGION=ap-south-1

# ─── Email / SMTP (Gmail) ──────────────
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASSWORD=your_16_char_gmail_app_password
EMAILS_FROM_EMAIL=your_email@gmail.com

# ─── Celery / Redis ────────────────────
REDIS_URL=redis://localhost:6379/0

πŸ“Œ Gmail App Password: Go to Google Account β†’ Security β†’ 2-Step Verification β†’ App Passwords. Generate one for this app.

πŸ“Œ AWS S3: Create a bucket in AWS S3 and add the credentials. Used for storing claim documents.

2.5 Set up and seed the database

python ../database/create_tables.py
python seed.py

2.6 Verify credentials are loading correctly (optional)

python check_config.py

This prints all loaded settings so you can confirm everything is reading from .env properly.


πŸš€ Step 3 β€” Run the Full Backend (Single Command)

Make sure Docker Desktop is open first (for Redis), then run:

.\start_backend.ps1

This script will automatically:

  1. βœ… Check your .env file exists
  2. βœ… Verify and print all credentials
  3. βœ… Start Redis via Docker if not already running
  4. βœ… Open a new terminal window with the Celery email worker
  5. βœ… Start the FastAPI server with uvicorn --reload

⚠️ First-time PowerShell users: If you get a script execution error, run this first:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

βœ… Backend API: http://localhost:8000
βœ… API Docs (Swagger): http://localhost:8000/docs


🎨 Step 4 β€” Frontend Setup

Open a new terminal window:

cd frontend
npm install
npm run dev

βœ… Frontend App: http://localhost:5173


πŸ” Step 5 β€” Login & Use the App

Open your browser and go to http://localhost:5173

Role Email Password
User user@example.com password
Admin admin@example.com password

Or click Sign Up to create a new account.


πŸ“‹ Quick Reference

Task Command Run in
Start full backend .\start_backend.ps1 backend/
Start frontend npm run dev frontend/
Check .env config python check_config.py backend/
Start Celery only celery -A app.worker.celery_app worker --loglevel=info --pool=solo backend/
API docs http://localhost:8000/docs Browser
App URL http://localhost:5173 Browser

πŸ“‚ Project Structure

Insurance-Comparison-Recommendation-Claim-Assistant/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py                  # FastAPI app entry point
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py            # Settings loaded from .env
β”‚   β”‚   β”‚   └── celery_app.py        # Celery application setup
β”‚   β”‚   β”œβ”€β”€ models/                  # SQLAlchemy DB models
β”‚   β”‚   β”‚   β”œβ”€β”€ user.py
β”‚   β”‚   β”‚   β”œβ”€β”€ policy.py
β”‚   β”‚   β”‚   β”œβ”€β”€ claim.py             # Includes ClaimStatusHistory
β”‚   β”‚   β”‚   └── user_policy.py
β”‚   β”‚   β”œβ”€β”€ schemas/                 # Pydantic request/response schemas
β”‚   β”‚   β”œβ”€β”€ crud/                    # Database CRUD operations
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ recommendation_engine.py  # 12-factor scoring engine
β”‚   β”‚   β”‚   β”œβ”€β”€ email_service.py     # SMTP email sender
β”‚   β”‚   β”‚   └── s3_service.py        # AWS S3 file upload
β”‚   β”‚   └── api/v1/endpoints/        # All API route handlers
β”‚   β”œβ”€β”€ worker.py                    # Celery background email task
β”‚   β”œβ”€β”€ seed.py                      # Sample data seeder
β”‚   β”œβ”€β”€ check_config.py              # .env verification helper
β”‚   β”œβ”€β”€ start_backend.ps1            # One-command startup script
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ database/
β”‚   └── create_tables.py             # DB table creation
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/              # All React UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx        # Recommendations + policies
β”‚   β”‚   β”‚   β”œβ”€β”€ ClaimWizard.jsx      # 5-step claim filing flow
β”‚   β”‚   β”‚   β”œβ”€β”€ MyClaims.jsx         # Claim list + timeline
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminClaims.jsx      # Admin review panel
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDashboard.jsx   # Admin stats overview
β”‚   β”‚   β”‚   β”œβ”€β”€ Profile.jsx          # User + risk profile editor
β”‚   β”‚   β”‚   β”œβ”€β”€ PremiumCalculator.jsx
β”‚   β”‚   β”‚   └── ComparePolicies.jsx
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.jsx      # JWT auth management
β”‚   β”‚   └── App.jsx                  # Routing + layout
β”‚   └── package.json
β”‚
└── README.md

πŸ“§ How Email Notifications Work

Admin updates claim status
        ↓
FastAPI saves status to DB
        ↓
FastAPI calls .delay() β†’ drops task into Redis
        ↓
Celery worker picks up task (background)
        ↓
Email sent to user's registered email

βœ… The FastAPI server is never blocked. The email always sends in the background.


πŸ”„ Claim Status Lifecycle

draft β†’ submitted β†’ under_review β†’ approved β†’ paid
                         ↓
                      rejected

Each transition is strictly enforced. Admins cannot skip steps β€” e.g., you cannot approve a claim that hasn't been reviewed first.


⚠️ Important Notes

  • Never commit your .env file β€” it contains database passwords and API keys. It is already in .gitignore.
  • Docker Desktop must be open before running start_backend.ps1 for Redis to work.
  • If you don't have AWS S3, document uploads will not work but the rest of the app functions normally.

About

Full-stack insurance policy comparison, AI recommendation engine, claim submission wizard & background status email notifications (FastAPI, React, PostgreSQL, Celery, Redis).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages