Skip to content

A comprehensive AP (Accounts Payable) invoice processing system using Docling for intelligent document extraction, validation, and export capabilities.

Notifications You must be signed in to change notification settings

Aparnap2/invoicify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AP Intake & Validation System

Python FastAPI License

A comprehensive AP (Accounts Payable) invoice processing and validation system built with Python, FastAPI, and modern web technologies.

🎯 Overview

AP Intake & Validation is an enterprise-grade system designed to:

  • Process invoices from multiple sources (email, upload, API)
  • Validate and extract invoice data using AI/ML
  • Manage workflows for approval and processing
  • Integrate with external systems (QuickBooks, etc.)
  • Provide analytics and reporting capabilities

πŸ—οΈ Architecture

Modern Tech Stack

  • Backend: Python 3.11+, FastAPI, SQLAlchemy
  • Database: PostgreSQL with Alembic migrations
  • Cache: Redis for performance optimization
  • Queue: Celery with Redis broker
  • Frontend: React with TypeScript
  • Containerization: Docker & Docker Compose
  • Testing: Pytest with comprehensive coverage

Key Features

  • βœ… Email Integration - Gmail OAuth and IMAP support
  • βœ… AI-Powered Extraction - LLM-based invoice data extraction
  • βœ… Workflow Management - Configurable approval workflows
  • βœ… Multi-Provider Support - Email, QuickBooks, N8N integrations
  • βœ… Real-time Processing - WebSocket-based updates
  • βœ… Comprehensive API - RESTful API with OpenAPI docs
  • βœ… Security First - JWT auth, RBAC, encryption
  • βœ… Monitoring - Prometheus metrics, structured logging

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • PostgreSQL 13+
  • Redis 6+
  • Docker & Docker Compose (optional)

Development Setup

# 1. Clone the repository
git clone <repository-url>
cd ap_intake

# 2. Run the automated setup
chmod +x scripts/setup/dev-setup.sh
./scripts/setup/dev-setup.sh

# 3. Start the development server
uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Docker Setup

# Using development configuration
docker-compose -f config/docker/docker-compose.yml up -d

# Using production configuration
docker-compose -f config/docker/docker-compose.prod.yml up -d

πŸ“ Project Structure

ap_intake/
β”œβ”€β”€ πŸ“ app/                    # Main application code
β”‚   β”œβ”€β”€ πŸ“ api/               # API endpoints and routing
β”‚   β”œβ”€β”€ πŸ“ core/               # Core configuration and utilities
β”‚   β”œβ”€β”€ πŸ“ db/                 # Database models and sessions
β”‚   β”œβ”€β”€ πŸ“ models/             # SQLAlchemy model definitions
β”‚   β”œβ”€β”€ πŸ“ services/           # Business logic and services
β”‚   β”œβ”€β”€ πŸ“ utils/              # Utility modules (NEW!)
β”‚   └── πŸ“ workers/            # Background task workers
β”œβ”€β”€ πŸ“ config/                 # Configuration files
β”‚   β”œβ”€β”€ πŸ“ environments/       # Environment-specific configs
β”‚   β”œβ”€β”€ πŸ“ docker/             # Docker configurations
β”‚   └── πŸ“ database/           # Database configurations
β”œβ”€β”€ πŸ“ docs/                   # πŸ“š Documentation
β”‚   β”œβ”€β”€ πŸ“ architecture/         # System architecture docs
β”‚   β”œβ”€β”€ πŸ“ guides/              # Setup and usage guides
β”‚   └── πŸ“ summaries/           # Implementation summaries
β”œβ”€β”€ πŸ“ scripts/                # πŸ› οΈ Utility scripts
β”‚   β”œβ”€β”€ πŸ“ setup/              # Development setup scripts
β”‚   β”œβ”€β”€ πŸ“ deployment/         # Deployment scripts
β”‚   └── πŸ“ production/         # Production utilities
β”œβ”€β”€ πŸ“ tests/                  # πŸ§ͺ Test suite
β”‚   β”œβ”€β”€ πŸ“ fixtures/           # Test data and fixtures
β”‚   β”œβ”€β”€ πŸ“ e2e/               # End-to-end tests
β”‚   └── πŸ“ unit/               # Unit tests
β”œβ”€β”€ πŸ“ web/                    # Frontend application
└── πŸ“ examples/               # Example configurations

πŸ“š Documentation

🎯 Essential Reading

πŸš€ Setup Guides

πŸ“Š Progress Reports

πŸ› οΈ Development

Code Quality Tools

# Code formatting
uv run black app/

# Type checking
uv run mypy app/

# Linting
uv run flake8 app/

# Testing with coverage
uv run pytest --cov=app tests/

Pre-commit Hooks

# Install pre-commit hooks
pre-commit install

# Run manually
pre-commit run --all-files

Environment Variables

# Copy example configuration
cp config/environments/.env.example .env

# Edit with your settings
vim .env

πŸ§ͺ Testing

Run Tests

# All tests
uv run pytest

# With coverage
uv run pytest --cov=app --cov-report=html

# Specific test file
uv run pytest tests/test_invoice_processing.py -v

Test Structure

  • Unit Tests: tests/unit/ - Individual component tests
  • Integration Tests: tests/integration/ - Service integration tests
  • E2E Tests: tests/e2e/ - End-to-end workflow tests
  • Fixtures: tests/fixtures/ - Test data and configurations

πŸš€ Deployment

Development

# Using Docker Compose
docker-compose -f config/docker/docker-compose.yml up -d

# Using uvicorn directly
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000

Production

# Production Docker setup
docker-compose -f config/docker/docker-compose.prod.yml up -d

# With environment file
docker-compose -f config/docker/docker-compose.prod.yml --env-file .env up -d

Environment Configuration

  • Development: config/environments/.env.development
  • Testing: config/environments/.env.test
  • Production: config/environments/.env.production

πŸ”§ Configuration

Key Configuration Files

  • pyproject.toml - Python dependencies and project metadata
  • config/database/alembic.ini - Database migration configuration
  • config/docker/docker-compose.yml - Development container setup
  • config/environments/.env.example - Environment variable template

Database Migrations

# Create new migration
uv run alembic revision --autogenerate -m "Description"

# Apply migrations
uv run alembic upgrade head

# Rollback migration
uv run alembic downgrade -1

πŸ“Š Monitoring & Logging

Application Logs

# View application logs
tail -f logs/app.log

# View worker logs
tail -f logs/worker.log

Health Checks

  • API Health: GET /health - Application health status
  • Database Health: GET /health/db - Database connectivity
  • Redis Health: GET /health/redis - Cache connectivity

Metrics

  • Prometheus: /metrics - Application metrics
  • Performance: Built-in performance monitoring
  • Error Tracking: Structured error logging

πŸ” Security

Authentication & Authorization

  • JWT Tokens: Secure token-based authentication
  • RBAC: Role-based access control
  • OAuth Integration: Gmail, QuickBooks OAuth flows
  • API Keys: Secure API key management

Data Protection

  • Encryption: Sensitive data encryption at rest
  • Input Validation: Comprehensive input sanitization
  • SQL Injection Prevention: Parameterized queries
  • XSS Protection: Output encoding and CSP headers

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Run development setup (./scripts/setup/dev-setup.sh)
  4. Make changes with tests
  5. Run tests and linting (uv run pytest && uv run black app/)
  6. Commit changes (git commit -m 'Add amazing feature')
  7. Push to branch (git push origin feature/amazing-feature)
  8. Create Pull Request

Code Standards

  • Python: Follow PEP 8, use type hints
  • Documentation: Comprehensive docstrings
  • Testing: Maintain 85%+ coverage
  • Security: Follow security best practices

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

Documentation

Community


πŸŽ‰ Quick Links

🎯 Purpose πŸ”— Link
πŸ“– Documentation docs/README.md
πŸš€ Quick Start scripts/setup/dev-setup.sh
πŸ—οΈ Architecture docs/architecture/
πŸ“Š Progress docs/summaries/
πŸ§ͺ Testing tests/
βš™οΈ Configuration config/

Version: 1.0.0
Last Updated: 2025-11-25
Maintainers: AP Intake Development Team

About

A comprehensive AP (Accounts Payable) invoice processing system using Docling for intelligent document extraction, validation, and export capabilities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published