Skip to content

trueashik/ClaimNova

Repository files navigation

🌟 ClaimNova

Autonomous, AI-driven Returns and RMA SaaS platform with real-time fraud detection and intelligent claim processing.

ClaimNova transforms the massive headache of e-commerce returns into a seamless, fully automated, zero-touch process. Built with Amazon Nova's High-Thinking models for multimodal reasoning and orchestrated by Airia's Active Agents, wrapped in a premium glassmorphic UI.


πŸš€ Enterprise Features

  • πŸ€– Autonomous AI Agent: A conversational interface that handles the entire return process via chat, reducing manual support tickets and overhead.
  • πŸ›‘οΈ Intelligent Fraud Detection: Utilizes Amazon Nova's phenomenal multimodal understanding to cross-reference conversational text with user-uploaded images of defects, assigning a highly accurate fraud probability score before processing refunds.
  • ⚑ Multi-Agent Orchestration: Deployed as an Active Agent using Airia, seamlessly executing SQL database queries and managing decision-making workflows between the frontend and backend.
  • πŸ“Š Real-Time Admin Dashboard: Live, synchronized interface for administrators to monitor incoming orders, claims, and AI resolutions using Supabase Realtime, enforcing a Human-In-The-Loop (HITL) capability.
  • πŸ”” Smart Slack Automation: Configurable real-time webhook alerts pushed directly to Slack when high fraud is detected or high-value claims require human review.
  • 🎨 Premium UI/UX: A stunning, modern, glassmorphic white theme built with TailwindCSS, shadcn/ui, and Framer Motion animations.

πŸ—οΈ System Architecture

High-Level Flow

graph TD
    A[Customer initiates chat] -->|Types issue or records voice| B(Airia Active Agent Orchestrator)
    B -->|Requests evidence| C{User provides evidence}
    C -->|Uploads Image/Receipt| D[Amazon Nova: Multimodal Analysis]
    C -->|Text Description| E[Amazon Nova: High-Thinking Reasoning]

    D --> F[AI Fraud Engine]
    E --> F

    F -->|Calculates Confidence Score| G{Decision Matrix}

    G -->|Low Fraud & Valid| H[βœ… Approve Refund]
    G -->|Medium Fraud| I[⚠️ Flag for Human-in-the-Loop]
    G -->|High Fraud / Invalid| J[❌ Reject Claim]

    H --> K[(Supabase Database)]
    I --> K
    J --> K

    K -->|Realtime Subscription| L[Admin Dashboard]
    K -->|Webhook Trigger| M[Slack Notification]
Loading

How It Works

The system operates through a multi-stage AI pipeline:

  1. Customer Chat β€” The customer interacts with Nova, the AI assistant, via a chat interface. They describe their issue in text or use voice input (transcribed via Groq Whisper).

  2. Order Lookup β€” When the customer provides an Order ID (format: ORD-XXXX-XXX), the system fetches order details from Supabase and injects them into the AI context for fraud cross-referencing.

  3. Evidence Collection β€” The AI requests photographic evidence for physical damage claims. Uploaded images are converted to base64 and attached to the Airia pipeline payload.

  4. AI Analysis β€” The request is sent to the Airia Pipeline which routes to Amazon Nova's multimodal models. Nova analyzes text + images together for:

    • Product verification (does the photo match the ordered item?)
    • Damage assessment
    • Fraud probability scoring (Low / Medium / High)
    • Confidence scoring (0–100)
  5. Fallback β€” If Airia is unavailable, the system falls back to Groq (Llama 3.3 70B) for text-only reasoning.

  6. Decision & Persistence β€” The AI emits a structured JSON verdict. The backend creates/updates a claim record in Supabase with the verdict, fraud score, and resolution.

  7. Real-Time Dashboard β€” Admins see claims appear instantly via Supabase Realtime subscriptions. They can override AI decisions (Human-In-The-Loop).

  8. Slack Alerts β€” High-fraud or high-value claims trigger configurable Slack webhook notifications.


πŸ› οΈ Tech Stack

Layer Technology Purpose
Framework Next.js 16 (App Router) Server-side rendering, API routes, React Server Components
Language TypeScript Type-safe development
UI Library React 19 Component-based UI
Styling TailwindCSS v4, shadcn/ui Utility-first CSS, pre-built accessible components
Animations Framer Motion Smooth page transitions, micro-animations
State Zustand Lightweight client-side state management
Database Supabase (PostgreSQL) Structured data, Realtime subscriptions, REST API
AI Engine Amazon Nova (via Airia) Multimodal reasoning, image analysis, fraud detection
AI Fallback Groq (Llama 3.3 70B) Text-only LLM fallback
Voice Groq Whisper Audio transcription for voice messages
Notifications Slack Webhooks Real-time fraud/refund alerts
Font Poppins (Google Fonts) Clean, modern typography

πŸ“ Project Structure

ClaimNova/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ chat/route.ts          # AI chat endpoint (Airia + Groq fallback)
β”‚   β”‚   β”‚   └── notify/route.ts        # Slack webhook notification endpoint
β”‚   β”‚   β”œβ”€β”€ page.tsx                    # Main split-screen view (Chat + Admin)
β”‚   β”‚   β”œβ”€β”€ layout.tsx                  # Root layout with Poppins font
β”‚   β”‚   └── globals.css                # Global styles, design tokens, animations
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ chat/
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatPanel.tsx           # Chat container with header
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatInput.tsx           # Message input with file/voice attachments
β”‚   β”‚   β”‚   β”œβ”€β”€ MessageBubble.tsx       # Chat message rendering
β”‚   β”‚   β”‚   β”œβ”€β”€ FileUpload.tsx          # Drag-and-drop file attachment
β”‚   β”‚   β”‚   └── VoiceRecorder.tsx       # Voice recording with Whisper transcription
β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDashboard.tsx      # Live admin panel with claims/orders tables
β”‚   β”‚   β”‚   β”œβ”€β”€ AddOrderModal.tsx       # Create new orders
β”‚   β”‚   β”‚   β”œβ”€β”€ AddClaimModal.tsx       # Manually file claims
β”‚   β”‚   β”‚   └── NotificationSettings.tsx # Configure Slack webhook
β”‚   β”‚   └── ui/                         # shadcn/ui primitives
β”‚   └── lib/
β”‚       β”œβ”€β”€ supabase.ts                 # Supabase client, TypeScript interfaces
β”‚       β”œβ”€β”€ chat-store.ts               # Zustand store with localStorage persistence
β”‚       └── utils.ts                    # Utility functions (cn helper)
β”œβ”€β”€ supabase/
β”‚   └── database_schema.md             # SQL DDL for orders & claims tables
β”œβ”€β”€ public/                             # Static assets
β”œβ”€β”€ Dockerfile                          # Multi-stage production build
β”œβ”€β”€ docker-compose.yml                  # Container orchestration wrapper
β”œβ”€β”€ .dockerignore                       # Docker context exclusions
β”œβ”€β”€ next.config.ts                      # Next.js configuration (standalone output)
β”œβ”€β”€ package.json                        # Dependencies and scripts
β”œβ”€β”€ tsconfig.json                       # TypeScript configuration
└── .env.local                          # Environment variables (not committed)

βš™οΈ Getting Started

Prerequisites

  • Node.js β‰₯ 18 (recommended: 20 LTS)
  • npm β‰₯ 9
  • A Supabase project (create one free)
  • An Airia account with an active pipeline (airia.ai)
  • (Optional) A Groq API key for voice transcription and LLM fallback
  • (Optional) A Slack Incoming Webhook URL for alerts

πŸ–₯️ Local Development

1. Clone the repository

git clone https://github.com/trueashik/ClaimNova.git
cd ClaimNova

2. Install dependencies

npm install

3. Configure environment variables

Create a .env.local file in the project root:

# ── Supabase (Required) ──
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

# ── AI Orchestrator (Required for AI features) ──
ORCHESTRATOR_WEBHOOK_URL=https://api.airia.ai/v2/PipelineExecution/your-pipeline-id
AIRIA_API_KEY=your-airia-api-key

# ── Groq (Optional β€” voice transcription + LLM fallback) ──
GROQ_API_KEY=your-groq-api-key

Tip: Get your Supabase URL and anon key from your project's Settings β†’ API page.

4. Set up the database

Run the SQL from supabase/database_schema.md in your Supabase SQL Editor to create the required orders and claims tables with their custom enum types.

Quick reference β€” table summary
Table Purpose Key Fields
orders Customer orders catalog order_id (PK), product_name, order_amount, delivery_status, return_window_days
claims Filed return/refund claims claim_id (PK), order_id (FK), ai_status, ai_fraud_probability, ai_confidence_score, resolution, approved_refund_amount

5. Start the development server

npm run dev

Open http://localhost:3000 β€” you'll see the split-screen interface with the Customer Chat on the left and the Admin Dashboard on the right.


🐳 Docker Deployment

ClaimNova includes Docker support for containerized production deployments.

Option A: Docker Compose (recommended)

# Make sure .env.local exists with your keys (see step 3 above)
docker compose up --build

The app will be available at http://localhost:3000.

To run in the background:

docker compose up --build -d

To stop:

docker compose down

Option B: Docker CLI

# Build the image
docker build -t claimnova .

# Run the container
docker run -p 3000:3000 --env-file .env.local claimnova

Docker Architecture

The Dockerfile uses a multi-stage build optimized for production:

Stage Base Image Purpose
deps node:20-alpine Install production dependencies with npm ci
builder node:20-alpine Build the Next.js standalone bundle
runner node:20-alpine Minimal production image (~150 MB) with non-root user

πŸ” Environment Variables Reference

Variable Required Description
NEXT_PUBLIC_SUPABASE_URL βœ… Your Supabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY βœ… Supabase anonymous/public API key
ORCHESTRATOR_WEBHOOK_URL βœ…* Airia pipeline execution endpoint
AIRIA_API_KEY βœ…* Airia API key for authentication
GROQ_API_KEY ❌ Groq API key for Whisper transcription and Llama fallback

* Without Airia keys, the AI chat will fall back to Groq if configured, or return a service-unavailable message.


πŸ—„οΈ Database Schema

ClaimNova uses Supabase (PostgreSQL) with two core tables and Realtime subscriptions enabled for live dashboard updates.

Full SQL definitions: supabase/database_schema.md

erDiagram
    ORDERS ||--o{ CLAIMS : "has"
    ORDERS {
        varchar order_id PK
        varchar customer_name
        varchar customer_email
        varchar product_name
        text product_description
        varchar product_category
        varchar vendor_name
        timestamptz order_date
        timestamptz delivery_date
        varchar delivery_status
        numeric order_amount
        int return_window_days
        timestamptz created_at
    }
    CLAIMS {
        varchar claim_id PK
        varchar order_id FK
        text customer_issue
        varchar issue_category
        jsonb multimodal_evidence
        enum ai_status
        enum ai_fraud_probability
        numeric ai_confidence_score
        text ai_assessment_notes
        enum authority_status
        varchar authority_reviewer_id
        text authority_notes
        enum resolution
        numeric approved_refund_amount
        timestamptz filed_at
        timestamptz resolved_at
        timestamptz updated_at
    }
Loading

πŸ”Œ API Routes

POST /api/chat

The core AI chat endpoint. Accepts multipart/form-data with:

Field Type Description
message string User's text message
order_id string Active order ID for context
customer_issue string Description of the issue
claim_id string Active claim ID
history JSON string Previous conversation messages
order_details JSON string Cached order details from session
accumulated_evidence JSON string Previously uploaded evidence (base64 data URIs)
file_* File Uploaded images, audio, or PDFs

Returns a structured JSON response with reply, verification_status, fraud_probability, confidence_score, assessment_notes, resolution, and refund_amount.

POST /api/notify

Sends Slack webhook notifications. Accepts JSON:

{
  "type": "fraud" | "refund" | "verification",
  "orderId": "ORD-XXXX-XXX",
  "claimId": "CLM-XXXXXXXX",
  "details": "Formatted message string",
  "slackWebhookUrl": "https://hooks.slack.com/services/..."
}

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m 'Add your feature'
  4. Push to your branch: git push origin feature/your-feature
  5. Open a Pull Request

πŸ“œ License

This project is private. All rights reserved.


Built with ❀️ by Ashik Ahmed
Powered by Amazon Nova β€’ Airia β€’ Supabase

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages