Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐾 PawProtect β€” Pet Insurance AI Management System

PawProtect is a modern, full-stack pet insurance management platform. Pet owners can register pets, purchase insurance policies, and submit claims β€” with AI-powered medical document analysis automating eligibility assessments and receipt data extraction. Administrators get a complete management dashboard for policy oversight and claims adjudication.


✨ Features

For Pet Owners

  • AI Eligibility Check β€” Upload veterinary medical records (PDF); Gemini AI extracts pet details, medical history, pre-existing conditions, and determines insurance eligibility automatically
  • Policy Management β€” Browse and compare insurance plans, subscribe to policies, and manage active coverage
  • AI-Powered Claim Submission β€” Submit claims with receipt upload; AI extracts treatment details, diagnosis, medications, and amounts from veterinary bills
  • Pet Health Chatbot β€” Context-aware AI assistant that answers pet health questions with pet-specific knowledge
  • Personal Dashboard β€” View stats, active policies, recent claims, and activity at a glance

For Administrators

  • Claims Review β€” Approve or reject claims with deductible calculations and decision tracking
  • Insurance Plan Management β€” Full CRUD for plans with coverage details, popularity flags, and active/inactive toggles
  • User Management β€” View all users with their pets and policy details
  • Platform Analytics β€” Global dashboard with KPIs: total users, active policies, claims by timeframe, approval rates, and revenue metrics

πŸš€ Tech Stack

Layer Technologies
Frontend Angular 21 (SSR), Angular Material, NgRx Signal Store, Tailwind CSS 4, Chart.js, Lucide Icons, TypeScript 5.9
Backend Java 17, Spring Boot 4, Spring Security (JWT), Spring Data JPA, Hibernate, Lombok, SpringDoc OpenAPI (Swagger UI)
AI Service Python 3.10, FastAPI, Google Gen AI SDK (Gemini 2.0 Flash), Pydantic v2, pypdf
Database MySQL 8.0
Infrastructure Docker & Docker Compose, Nginx (Reverse Proxy, Rate Limiting, TLS), Let's Encrypt / Certbot
CI/CD GitHub Actions β†’ GitHub Container Registry β†’ DigitalOcean Droplet

πŸ› οΈ Architecture

This project follows a microservices architecture with an API Gateway pattern:

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚              Docker Network (internal)             β”‚
                          β”‚                                                    β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   80/443     β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  Client  β”‚ ─────────────┼─>β”‚   Nginx   β”‚ ─/api/─>β”‚  Spring Boot     β”‚        β”‚
β”‚ (Browser)β”‚              β”‚  β”‚  (Proxy)  β”‚         β”‚  Backend :8080   β”‚        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚  β”‚  :80/:443 β”‚         β”‚  28 REST APIs    │──┐     β”‚
                          β”‚  β”‚           β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚     β”‚
                          β”‚  β”‚           β”‚                β”‚              β”‚     β”‚
                          β”‚  β”‚           β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚     β”‚
                          β”‚  β”‚           β”‚ ────/──>β”‚  Angular SSR     β”‚  β”‚     β”‚
                          β”‚  β”‚           β”‚         β”‚  Frontend :4000  β”‚  β”‚     β”‚
                          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚     β”‚
                          β”‚       β”‚                                      β”‚     β”‚
                          β”‚       β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚     β”‚
                          β”‚       β”‚    β”‚  FastAPI AI      β”‚<β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
                          β”‚       β”‚    β”‚  Service :8001   β”‚              β”‚     β”‚
                          β”‚       β”‚    β”‚  (Gemini API)    β”‚              β”‚     β”‚
                          β”‚       β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚     β”‚
                          β”‚       β”‚                                      β”‚     β”‚
                          β”‚       β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚     β”‚
                          β”‚       β”‚    β”‚  MySQL 8.0       β”‚<β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
                          β”‚       β”‚    β”‚  Database :3306  β”‚                    β”‚
                          β”‚       β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Nginx β€” Single public entry point. Routes /api/ to backend, / to frontend. Provides rate limiting (5 req/s per IP) and TLS termination.
  • Spring Boot Backend β€” Handles all business logic, JWT authentication, and orchestrates calls to the AI service.
  • Angular SSR Frontend β€” Server-side rendered with Express, served on port 4000. Pre-renders the landing page; all other routes rendered on-demand.
  • FastAPI AI Service β€” Internal-only microservice for Gemini API interactions. Secured with API key authentication. Not exposed publicly.
  • MySQL β€” Persistent data store. Internal-only, accessible only by the backend.

πŸ“‚ Project Structure

pawprotect/
β”œβ”€β”€ backend/                        # Spring Boot REST API
β”‚   β”œβ”€β”€ src/main/java/com/org/petGuard/
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ config/             # CORS, RestTemplate, OpenAPI config
β”‚   β”‚   β”‚   β”œβ”€β”€ exception/          # Global exception handler
β”‚   β”‚   β”‚   └── security/           # JWT filter, auth entry point, SecurityConfig
β”‚   β”‚   └── domain/
β”‚   β”‚       β”œβ”€β”€ ai/                 # AI service integration (controller, service)
β”‚   β”‚       β”œβ”€β”€ auth/               # Registration, login, JWT token management
β”‚   β”‚       β”œβ”€β”€ claim/              # Claim entity, CRUD, admin review logic
β”‚   β”‚       β”œβ”€β”€ dashboard/          # User & admin analytics endpoints
β”‚   β”‚       β”œβ”€β”€ insurance/          # Insurance plan entity & management
β”‚   β”‚       β”œβ”€β”€ pet/                # Pet entity, CRUD, soft-delete
β”‚   β”‚       β”œβ”€β”€ policy/             # Policy entity, subscription, cancellation
β”‚   β”‚       └── user/               # User entity, admin user listing
β”‚   β”œβ”€β”€ Dockerfile                  # Multi-stage: JDK 17 build β†’ JRE 17 runtime
β”‚   └── pom.xml
β”‚
β”œβ”€β”€ petguard/                       # Angular 21 SSR Frontend
β”‚   β”œβ”€β”€ src/app/
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ constants/          # Centralized API endpoint URLs
β”‚   β”‚   β”‚   β”œβ”€β”€ guards/             # Auth & admin route guards
β”‚   β”‚   β”‚   β”œβ”€β”€ interceptors/       # Cookie-forwarding HTTP interceptor
β”‚   β”‚   β”‚   β”œβ”€β”€ models/             # TypeScript interfaces
β”‚   β”‚   β”‚   β”œβ”€β”€ services/           # API services (auth, pet, claim, plan, policy, ai, user)
β”‚   β”‚   β”‚   └── store/              # NgRx Signal Stores (auth, pet)
β”‚   β”‚   β”œβ”€β”€ features/
β”‚   β”‚   β”‚   β”œβ”€β”€ landing/            # Marketing landing page (pre-rendered)
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/               # Login & registration pages
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/          # User dashboard with 9 pages + AI chatbot
β”‚   β”‚   β”‚   └── admin/              # Admin panel with dashboard, plans, claims, users
β”‚   β”‚   └── shared/                 # Shared components
β”‚   β”œβ”€β”€ Dockerfile                  # Multi-stage: Node 20 build β†’ Node 20 SSR runtime
β”‚   └── package.json
β”‚
β”œβ”€β”€ petguard-ai/                    # FastAPI AI Microservice
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/endpoints.py        # 5 AI endpoints (health, eligibility, receipts, chat)
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py           # Settings from environment variables
β”‚   β”‚   β”‚   └── security.py         # API key authentication
β”‚   β”‚   β”œβ”€β”€ schemas/schemas.py      # Pydantic request/response models
β”‚   β”‚   └── services/
β”‚   β”‚       β”œβ”€β”€ ai_service.py       # Gemini API integration & prompt engineering
β”‚   β”‚       └── document_service.py # PDF text extraction via pypdf
β”‚   β”œβ”€β”€ Dockerfile                  # Multi-stage: Python 3.10 build β†’ slim runtime
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ docs/                           # Sample PDFs & API documentation
β”œβ”€β”€ .github/workflows/deploy.yml    # CI/CD pipeline (build β†’ push β†’ deploy)
β”œβ”€β”€ docker-compose.yml              # 6-service orchestration
β”œβ”€β”€ nginx.conf                      # Reverse proxy, rate limiting, TLS config
β”œβ”€β”€ init-letsencrypt.sh             # Let's Encrypt certificate initialization
└── .env                            # Environment variables (gitignored)

πŸ”Œ API Overview

The backend exposes 28 REST endpoints under /api/v1:

Resource Endpoints Access
Auth (/auth) Register, Login, Logout, Get Profile Public / Authenticated
Pets (/pets) Add, List, Get, Update, Delete (soft) Authenticated (owner)
Insurance Plans (/plans) List, Get, Create, Update, Toggle Status Authenticated / Admin
Policies (/policies) Subscribe, List, Get, Cancel Authenticated (owner)
Claims (/claims) Submit (with file upload), List, Get, List All, Review Authenticated / Admin
AI (/ai) Chat, Check Eligibility Authenticated
Dashboard (/dashboard) User Stats, Global Stats Authenticated / Admin

Full interactive API docs available at /swagger-ui.html when running locally.


πŸ’» Local Setup

Prerequisites

1. Clone the Repository

git clone https://github.com/s2sharpit/pawprotect.git
cd pawprotect

2. Environment Configuration

Create a .env file in the root directory:

# Database
ROOT_PASSWORD=your_root_password
DB_SCHEMA=your_DB_SCHEMA
DB_USER=your_DB_USER
DB_PASSWORD=your_DB_PASSWORD

# AI Service (Google AI Studio)
GEMINI_API_KEY=your_gemini_api_key        # Get from https://aistudio.google.com/apikey
AI_API_KEY=your_internal_secret_key       # Any strong secret (shared between backend ↔ AI)
AI_SERVICE_URL=http://ai:8001             # Internal Docker service URL
AI_MODEL_NAME=your_AI_MODEL_NAME

# Security
JWT_SECRET=your_jwt_signing_secret        # Min 256-bit secret for HMAC-SHA
ADMIN_EMAIL=your_adming_email
ADMIN_PASSWORD=your_admin_password

# App
APP_FRONTEND_URL=http://localhost          # Used for CORS configuration

3. Run the Application

Start the entire stack with a single command:

docker compose up --build

Once all services are healthy:

Service URL
Frontend http://localhost
Backend API http://localhost/api
API Docs (Swagger) http://localhost/api/swagger-ui.html
Health Check http://localhost/api/actuator/health

Note: The first build may take a few minutes as Docker downloads base images and installs dependencies. Subsequent starts will be much faster due to layer caching.


🚒 Deployment

The project uses a two-stage CI/CD pipeline via GitHub Actions, triggered on every push to main:

Push to main β†’ Build Docker Images β†’ Push to GHCR β†’ SSH into Droplet β†’ Pull & Restart

Pipeline Details

  1. Build & Push β€” Builds all service images and pushes them to GitHub Container Registry (ghcr.io)
  2. Deploy β€” SSHs into the DigitalOcean Droplet, pulls the latest code, generates .env from GitHub Secrets, pulls pre-built images, and restarts containers

Setup Deployment

  1. Provision a DigitalOcean Droplet with Docker installed

  2. Add the following GitHub Secrets to your repository:

    Category Secrets
    Server DO_HOST, DO_USERNAME, DO_SSH_KEY, DO_SSH_PASSPHRASE
    Database ROOT_PASSWORD, DB_SCHEMA, DB_USER, DB_PASSWORD
    AI GEMINI_API_KEY, AI_API_KEY, AI_SERVICE_URL, AI_MODEL_NAME
    App JWT_SECRET, ADMIN_EMAIL, ADMIN_PASSWORD, APP_FRONTEND_URL
  3. Push to main β€” GitHub Actions handles the rest automatically

SSL/TLS Setup (First-Time Only)

Run the initialization script to obtain Let's Encrypt certificates:

chmod +x init-letsencrypt.sh
./init-letsencrypt.sh

Certbot auto-renews certificates every 12 hours.


πŸ“„ License

This project is for demonstration purposes.

About

A Pet Insurance Management App

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages