Skip to content

Invoice Case Hub - AI-assisted invoice resolution system

Notifications You must be signed in to change notification settings

FirstCastSolutions423/invoice-case-hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

Invoice Case Hub

AI-assisted invoice resolution system with Microsoft 365, Linear, and GitHub integrations

πŸš€ Overview

This application provides an intelligent invoice case management system that:

  • Searches across Microsoft 365 (Outlook, OneDrive, SharePoint) for invoice-related documents
  • Creates and manages cases for invoice resolution
  • Synchronizes with Linear for project management
  • Provides GitHub integration for external AI assistant access
  • Implements intelligent retry logic with exponential backoff
  • Offers real-time webhook support for document updates

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend  │────▢│   Backend    │────▢│  Database   β”‚
β”‚    (React)  β”‚     β”‚   (Express)  β”‚     β”‚ (PostgreSQL)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚         External Services         β”‚
        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
        β”‚  Microsoft 365 β”‚  Linear  β”‚ GitHub β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

invoice-case-hub/
β”œβ”€β”€ client/              # Frontend React application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/  # React components
β”‚   β”‚   β”œβ”€β”€ pages/       # Page components
β”‚   β”‚   β”œβ”€β”€ hooks/       # Custom React hooks
β”‚   β”‚   └── lib/         # Utilities and helpers
β”œβ”€β”€ server/              # Backend Express application
β”‚   β”œβ”€β”€ routes.ts        # API endpoints
β”‚   β”œβ”€β”€ storage.ts       # Data storage interface
β”‚   β”œβ”€β”€ linear.ts        # Linear integration
β”‚   β”œβ”€β”€ github.ts        # GitHub integration
β”‚   β”œβ”€β”€ microsoft-graph-clients.ts  # M365 integration
β”‚   └── supabase.ts      # Case management service
β”œβ”€β”€ shared/              # Shared types and schemas
β”‚   └── schema.ts        # Database schema and types
└── migrations/          # Database migrations

πŸ”Œ API Endpoints

Core Endpoints

Method Endpoint Description
POST /api/search Search for invoice references across M365
GET /api/search-history Get search history
GET /api/stats Get system statistics
POST /api/cases Create a new case
GET /api/cases/:id Get case details
GET /api/cases/:id/artifacts Get case artifacts

GitHub Integration

Method Endpoint Description
POST /api/github/init-repo Initialize GitHub repository
POST /api/cases/:id/sync-github Sync case to GitHub issue
POST /api/github/commit Commit project state
GET /api/github/repo-status Get repository status

Linear Integration

Method Endpoint Description
POST /api/linear/init-project Initialize Linear project
POST /api/cases/:id/sync-linear Sync case to Linear issue

Webhook Endpoints

Method Endpoint Description
POST /hooks/m365 Microsoft 365 webhook
POST /hooks/linear Linear webhook

πŸ—„ Database Schema

Cases Table

CREATE TABLE cases (
  id UUID PRIMARY KEY,
  ref_norm TEXT NOT NULL,
  tenant_id TEXT NOT NULL,
  customer TEXT,
  service_date TIMESTAMP,
  status TEXT DEFAULT 'open',
  linear_issue_id VARCHAR,
  github_issue_number INTEGER,
  github_repo_url VARCHAR,
  created_at TIMESTAMP DEFAULT NOW(),
  updated_at TIMESTAMP DEFAULT NOW()
);

Artifacts Table

CREATE TABLE artifacts (
  id UUID PRIMARY KEY,
  case_id UUID REFERENCES cases(id),
  source TEXT NOT NULL,
  artifact_type TEXT NOT NULL,
  title TEXT,
  m365_link TEXT,
  metadata JSONB DEFAULT '{}'
);

πŸ”§ Environment Variables

Variable Description Required
DATABASE_URL PostgreSQL connection string Yes
TENANT_ID Microsoft 365 tenant ID Yes
CLIENT_ID Microsoft app client ID Yes
CLIENT_SECRET Microsoft app client secret Yes
REDIS_URL Redis connection URL Optional
BETTER_STACK_SOURCE_TOKEN Logging token Optional

🚦 Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • Microsoft 365 organization with app registration
  • Linear account (optional)
  • GitHub account (optional)

Installation

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env

# Run database migrations
npm run db:push

# Start development server
npm run dev

πŸ€– AI Assistant Integration

This repository is optimized for AI assistant consumption with:

  • Comprehensive documentation: All endpoints, schemas, and flows are documented
  • Clear architecture: Modular design with separation of concerns
  • Type safety: Full TypeScript coverage with Zod validation
  • Webhook support: Real-time updates via webhooks
  • Error handling: Robust retry logic with exponential backoff
  • Monitoring: Built-in metrics and logging

Key Integration Points

  1. Case Management: Create and track invoice resolution cases
  2. Document Search: Search across Microsoft 365 services
  3. Issue Tracking: Sync with Linear and GitHub for project management
  4. Webhook Processing: Real-time updates from external services
  5. Artifact Storage: Store and link related documents

πŸ“Š Recent Changes

  • 2025-10-07: Added GitHub integration for AI assistant access
  • 2025-10-07: Implemented automatic README generation
  • 2025-10-07: Added GitHub sync triggers for high-priority cases
  • 2025-10-07: Created comprehensive project documentation

πŸ“ License

This project is proprietary and confidential.


Generated on 2025-10-07T16:22:24.866Z for AI assistant consumption

About

Invoice Case Hub - AI-assisted invoice resolution system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published