Skip to content

jbouder/crew-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Patriot Life Member Center

A Member Center application for Patriot Life Insurance, a fictitious life insurance company serving military personnel and their families. Built with FastAPI, React, and PostgreSQL.

Features

  • 🏠 Home Page - Information about benefits for non-members
  • πŸ“Š Member Dashboard - View membership details, active benefits, and coverage summary
  • πŸ” Benefit Search & Enrollment - Browse and enroll in available benefits
  • πŸ’¬ AI Chat Assistant - CrewAI-powered chatbot with personalized member support
  • πŸ—ƒοΈ PostgreSQL Database - Store member profiles and benefit enrollments
  • 🐳 Docker Compose - Easy deployment with all services

AI Chat Assistant

The application includes an AI-powered chat assistant built with CrewAI and AWS Bedrock. The assistant can answer questions about insurance products and provide personalized information for logged-in members.

Agents

The chat system uses specialized AI agents powered by AWS Bedrock:

Agent Role Description Tools
AI Assistant Coordinator Main orchestrator Handles all user interactions, answers general questions using the knowledge base, and fetches personalized member data when needed All tools listed below
Member Profile Specialist Profile queries Retrieves personal information, military service details (branch, rank, active duty status), and membership information (member number, status, start date) Get Member Profile
Benefits Specialist Benefits & enrollments Provides current enrollments, available plans, eligibility requirements, premium costs, beneficiary designations, and coverage summaries by category Get Current Benefits and Enrollments, Get Available Benefits, Get Benefit Coverage Summary
Premium Calculator Specialist Quotes & cost comparisons Calculates premium estimates, compares plans side-by-side, and helps estimate coverage needs based on income, dependents, and debts Calculate Premium, Compare Plans, Estimate Coverage Needs
Eligibility Verification Specialist Eligibility checks Verifies member eligibility for specific benefits, explains military status implications, and details documentation requirements for enrollment Check Eligibility, Get Military Status, Verify Documentation Requirements
Document Assistant Specialist Forms & documentation Helps members navigate forms and paperwork, explains required documents for various actions, and clarifies form fields Get Required Documents, Generate Form, Explain Form Fields

Agent Tools

Tool Description
Get Member Profile Retrieves the logged-in member's personal details, military service information, and membership status
Get Current Benefits and Enrollments Fetches active benefit enrollments with coverage details, premiums, and beneficiary information
Get Available Benefits Lists all available benefit plans with eligibility indicators based on the member's profile
Get Benefit Coverage Summary Provides a high-level summary of the member's total coverage grouped by category
Calculate Premium Calculates monthly premium estimates based on coverage amount, age, and health factors
Compare Plans Compares multiple benefit plans within a category with side-by-side feature and cost comparison
Estimate Coverage Needs Analyzes income, dependents, and debts to recommend appropriate coverage levels
Check Eligibility Verifies if the member qualifies for a specific benefit based on age, military status, and other factors
Get Military Status Retrieves the member's military service status and explains benefit eligibility implications
Verify Documentation Requirements Lists required and optional documents needed to enroll in a specific benefit
Get Required Documents Provides document checklists for various actions (enrollment, claims, beneficiary changes, etc.)
Generate Form Returns information about specific forms including download links and completion tips
Explain Form Fields Provides detailed explanations of form fields to help members complete paperwork correctly

Knowledge Base Integration

The assistant integrates with AWS Bedrock Knowledge Base to retrieve relevant information about insurance products from documentation stored in S3. This enables the agent to answer detailed questions about:

  • SGLI, VGLI, FSGLI, and S-DVI coverage
  • Disability and accident protection plans
  • Critical illness and supplemental life insurance
  • Eligibility requirements and enrollment procedures

Screenshots

The application includes:

  • Public home page with benefit information
  • Member login portal
  • Dashboard with coverage summary and active enrollments
  • Benefit catalog with search and filter capabilities
  • Enrollment modal with beneficiary designation

Project Structure

member-center/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py           # FastAPI application with API endpoints
β”‚   β”œβ”€β”€ agents.py         # CrewAI agent definitions and tools
β”‚   β”œβ”€β”€ models.py         # SQLAlchemy database models
β”‚   β”œβ”€β”€ database.py       # Database connection and seeding
β”‚   β”œβ”€β”€ config.py         # Configuration settings
β”‚   β”œβ”€β”€ requirements.txt  # Python dependencies
β”‚   └── Dockerfile        # Backend container
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.tsx        # Public home page
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.tsx       # Member login
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.tsx   # Member dashboard
β”‚   β”‚   β”‚   └── Benefits.tsx    # Benefit search & enrollment
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Navigation.tsx  # Navigation bar
β”‚   β”‚   β”‚   └── ChatAssistant.tsx # AI chat widget
β”‚   β”‚   β”œβ”€β”€ api.ts              # API service
β”‚   β”‚   β”œβ”€β”€ types.ts            # TypeScript types
β”‚   β”‚   β”œβ”€β”€ App.tsx             # Main app with routing
β”‚   β”‚   └── main.tsx
β”‚   β”œβ”€β”€ Dockerfile        # Frontend container
β”‚   β”œβ”€β”€ nginx.conf        # Nginx configuration
β”‚   └── package.json
β”œβ”€β”€ data/                 # Knowledge base documents
β”‚   β”œβ”€β”€ sgli.md
β”‚   β”œβ”€β”€ vgli.md
β”‚   β”œβ”€β”€ fsgli.md
β”‚   └── ...
β”œβ”€β”€ docker-compose.yml    # Docker Compose with PostgreSQL
└── README.md

Prerequisites

  • Docker and Docker Compose (recommended)
  • Or for local development:
    • Python 3.10+
    • Node.js 18+
    • PostgreSQL 16+

Quick Start with Docker Compose

  1. Clone the repository and navigate to it:

    git clone <repository-url>
    cd crew-chat
  2. Copy the environment example file and update with your values:

    cp .env.example .env

    Edit .env and configure your AWS credentials:

    • AWS_ACCESS_KEY_ID - Your AWS access key
    • AWS_SECRET_ACCESS_KEY - Your AWS secret key
    • AWS_REGION - AWS region (default: us-east-1)
    • BEDROCK_MODEL_ID - Bedrock model ID (default: us.anthropic.claude-sonnet-4-20250514-v1:0)
    • BEDROCK_KNOWLEDGE_BASE_ID - Your Bedrock Knowledge Base ID
  3. Start all services (PostgreSQL, Backend, Frontend):

    docker compose up --build
  4. Access the application:

  5. Demo credentials:

To stop the application:

docker compose down

# To also remove the database volume:
docker compose down -v

Local Development Setup

Database

Start PostgreSQL:

docker compose up postgres -d

Or install PostgreSQL locally and create a database:

CREATE DATABASE membercenter;
CREATE USER membercenter WITH PASSWORD 'membercenter_password';
GRANT ALL PRIVILEGES ON DATABASE membercenter TO membercenter;

Backend

  1. Navigate to the backend directory:

    cd backend
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Set the database URL (if not using Docker):

    export DATABASE_URL=postgresql://membercenter:membercenter_password@localhost:5432/membercenter
  5. Start the server:

    python main.py
    # Or: uvicorn main:app --reload

The API will be available at http://localhost:8000

Frontend

  1. Navigate to the frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm run dev

The UI will be available at http://localhost:5173

API Endpoints

Health

  • GET / - Health check
  • GET /health - Health status

Chat

  • POST /api/chat - Send a message to the AI assistant (accepts message and optional user_id for personalized responses)

Members

  • POST /api/members/login - Member login
  • GET /api/members/{member_id} - Get member by ID
  • GET /api/members/{member_id}/dashboard - Get member dashboard data
  • POST /api/members - Create new member

Benefits

  • GET /api/benefits - List all benefits (filter by category)
  • GET /api/benefits/{benefit_id} - Get benefit details

Enrollments

  • GET /api/members/{member_id}/enrollments - List member enrollments
  • POST /api/members/{member_id}/enrollments - Enroll in benefit
  • DELETE /api/members/{member_id}/enrollments/{enrollment_id} - Cancel enrollment

Database Models

Member

  • Personal information (name, email, address)
  • Military service details (branch, rank, active duty status)
  • Membership information (member number, status)

Benefit

  • Coverage details (amount, premium, deductible)
  • Category (Life Insurance, Disability, Accident, Critical Illness, Supplemental)
  • Eligibility requirements (age range, active duty requirement)

Enrollment

  • Links members to benefits
  • Tracks effective dates and status
  • Stores beneficiary information

Technologies

  • Backend: Python, FastAPI, SQLAlchemy, Pydantic
  • AI/ML: CrewAI, AWS Bedrock (Claude), AWS Bedrock Knowledge Base
  • Frontend: React, TypeScript, React Router, Vite
  • Database: PostgreSQL
  • Deployment: Docker, Nginx

Available Benefits (Demo Data)

  1. SGLI - Service Members' Group Life Insurance ($400,000)
  2. FSGLI - Family Service Members' Group Life Insurance ($100,000)
  3. VGLI - Veterans' Group Life Insurance ($250,000)
  4. S-DVI - Service-Disabled Veterans Insurance ($10,000)
  5. Military Disability Protection Plus ($5,000/mo)
  6. Accident Protection Plan ($50,000)
  7. Critical Illness Shield ($75,000)
  8. Supplemental Term Life ($500,000)

License

MIT

About

Web App with CrewAI powered Agentic Chatbot

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •