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.
- 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
- 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
| 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 |
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.
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)
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.
- Docker & Docker Compose installed on your machine
git clone https://github.com/s2sharpit/pawprotect.git
cd pawprotectCreate 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 configurationStart the entire stack with a single command:
docker compose up --buildOnce 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.
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
- Build & Push β Builds all service images and pushes them to GitHub Container Registry (
ghcr.io) - Deploy β SSHs into the DigitalOcean Droplet, pulls the latest code, generates
.envfrom GitHub Secrets, pulls pre-built images, and restarts containers
-
Provision a DigitalOcean Droplet with Docker installed
-
Add the following GitHub Secrets to your repository:
Category Secrets Server DO_HOST,DO_USERNAME,DO_SSH_KEY,DO_SSH_PASSPHRASEDatabase ROOT_PASSWORD,DB_SCHEMA,DB_USER,DB_PASSWORDAI GEMINI_API_KEY,AI_API_KEY,AI_SERVICE_URL,AI_MODEL_NAMEApp JWT_SECRET,ADMIN_EMAIL,ADMIN_PASSWORD,APP_FRONTEND_URL -
Push to
mainβ GitHub Actions handles the rest automatically
Run the initialization script to obtain Let's Encrypt certificates:
chmod +x init-letsencrypt.sh
./init-letsencrypt.shCertbot auto-renews certificates every 12 hours.
This project is for demonstration purposes.