AI-assisted invoice resolution system with Microsoft 365, Linear, and GitHub integrations
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
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Frontend ββββββΆβ Backend ββββββΆβ Database β
β (React) β β (Express) β β (PostgreSQL)β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββ
β External Services β
βββββββββββββββββ¬ββββββββββββββββββββ€
β Microsoft 365 β Linear β GitHub β
βββββββββββββββββ΄ββββββββββββββββββββ
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
| 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 |
| 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 |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/linear/init-project |
Initialize Linear project |
| POST | /api/cases/:id/sync-linear |
Sync case to Linear issue |
| Method | Endpoint | Description |
|---|---|---|
| POST | /hooks/m365 |
Microsoft 365 webhook |
| POST | /hooks/linear |
Linear webhook |
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()
);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 '{}'
);| 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 |
- Node.js 18+
- PostgreSQL database
- Microsoft 365 organization with app registration
- Linear account (optional)
- GitHub account (optional)
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Run database migrations
npm run db:push
# Start development server
npm run devThis 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
- Case Management: Create and track invoice resolution cases
- Document Search: Search across Microsoft 365 services
- Issue Tracking: Sync with Linear and GitHub for project management
- Webhook Processing: Real-time updates from external services
- Artifact Storage: Store and link related documents
- 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
This project is proprietary and confidential.
Generated on 2025-10-07T16:22:24.866Z for AI assistant consumption