A comprehensive AP (Accounts Payable) invoice processing and validation system built with Python, FastAPI, and modern web technologies.
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
- 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
- β 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
- Python 3.11+
- PostgreSQL 13+
- Redis 6+
- Docker & Docker Compose (optional)
# 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# 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 -dap_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 Hub - Complete documentation index
- ποΈ Architecture Overview - System design
- π οΈ Developer Experience - DX improvements
- π Implementation Roadmap - Progress tracking
- π§ Gmail Setup - Email integration
- π Production Setup - Production deployment
- β‘ Quick Setup - Simplified setup
- π Implementation Summaries - All progress summaries
- π Refactoring Progress - Current status
# 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/# Install pre-commit hooks
pre-commit install
# Run manually
pre-commit run --all-files# Copy example configuration
cp config/environments/.env.example .env
# Edit with your settings
vim .env# 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- 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
# 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 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- Development:
config/environments/.env.development - Testing:
config/environments/.env.test - Production:
config/environments/.env.production
pyproject.toml- Python dependencies and project metadataconfig/database/alembic.ini- Database migration configurationconfig/docker/docker-compose.yml- Development container setupconfig/environments/.env.example- Environment variable template
# Create new migration
uv run alembic revision --autogenerate -m "Description"
# Apply migrations
uv run alembic upgrade head
# Rollback migration
uv run alembic downgrade -1# View application logs
tail -f logs/app.log
# View worker logs
tail -f logs/worker.log- API Health:
GET /health- Application health status - Database Health:
GET /health/db- Database connectivity - Redis Health:
GET /health/redis- Cache connectivity
- Prometheus:
/metrics- Application metrics - Performance: Built-in performance monitoring
- Error Tracking: Structured error logging
- JWT Tokens: Secure token-based authentication
- RBAC: Role-based access control
- OAuth Integration: Gmail, QuickBooks OAuth flows
- API Keys: Secure API key management
- Encryption: Sensitive data encryption at rest
- Input Validation: Comprehensive input sanitization
- SQL Injection Prevention: Parameterized queries
- XSS Protection: Output encoding and CSP headers
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Run development setup (
./scripts/setup/dev-setup.sh) - Make changes with tests
- Run tests and linting (
uv run pytest && uv run black app/) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Create Pull Request
- Python: Follow PEP 8, use type hints
- Documentation: Comprehensive docstrings
- Testing: Maintain 85%+ coverage
- Security: Follow security best practices
This project is licensed under the MIT License - see the LICENSE file for details.
- π Full Documentation - Complete guide
- π§ Setup Guides - Step-by-step setup
- ποΈ Architecture - System design
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Wiki: GitHub Wiki
| π― 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