Skip to content

odanree/credit-history-app

Repository files navigation

Credit History Application

codecov Tests Python 3.11+ Code style: black

A comprehensive credit monitoring application integrating Plaid (transaction data) and Experian (credit reports).

πŸ—οΈ Architecture Options

Choose your approach based on your needs:

Option Storage Speed GDPR Complexity Best For
Stateless Session only ~200ms first, ~5-10ms cached Trivial βœ… Simple MVP, low liability
Hybrid Redis cache + minimal DB ~10ms avg Easy βœ… Moderate Production, scale
Traditional Full PostgreSQL DB ~5ms avg Complex Complex Analytics, trends

Performance Details (Stateless):

  • First request: ~200-500ms (fetches from Plaid API)
  • Cached requests: ~5-10ms (5-minute in-memory cache TTL)
  • Session storage: Encrypted token in cookie (secure, scales infinitely)

Quick recommendation:

πŸš€ Quick Start

Option 1: Stateless (Recommended for MVP)

Zero customer data storage. Fresh financial data from Plaid every request (with caching).

How it works:

  1. First request: Fetches latest data from Plaid (~200-500ms)
  2. Subsequent requests (within 5 min): Returns cached data (~5-10ms)
  3. Token encrypted: Stored securely in session cookie
  4. No database: GDPR/CCPA compliant by design
# Activate virtual environment
source .venv/bin/activate
python3 -m venv .venv  # First time only

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with Plaid credentials and TOKEN_ENCRYPTION_KEY

# Generate encryption key (one-time setup)
python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
# Add TOKEN_ENCRYPTION_KEY to .env

# Run stateless app
python3 -m src.app_stateless

Visit: http://localhost:5001 - token auto-loads from .env on first visit

See docs/STATELESS_QUICKSTART.md for detailed setup.

Option 2: Traditional Database (Database storage)

# Same setup as above, but run:
python3 -m src.app

Visit: http://localhost:5001

πŸ“ Project Structure

credit-history-app/
β”œβ”€β”€ src/                      # Source code
β”‚   β”œβ”€β”€ integrations/        # API integrations
β”‚   β”‚   β”œβ”€β”€ plaid_integration.py
β”‚   β”‚   └── experian_integration.py
β”‚   β”œβ”€β”€ templates/           # Flask templates
β”‚   β”‚   β”œβ”€β”€ dashboard.html   # Main credit dashboard
β”‚   β”‚   └── setup.html       # Initial setup/configuration page
β”‚   β”œβ”€β”€ app.py              # Flask web dashboard (traditional)
β”‚   β”œβ”€β”€ app_stateless.py    # Flask web dashboard (stateless, no DB)
β”‚   └── main.py             # Combined API client
β”œβ”€β”€ scripts/                 # Utility scripts
β”‚   β”œβ”€β”€ setup_plaid_token.py
β”‚   └── run_plaid_only.py
β”œβ”€β”€ tests/                   # Test files
β”‚   └── test_*.py
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ .env.example             # Example environment variables
β”œβ”€β”€ README.md                # This file - overview & quick start
β”œβ”€β”€ SECURITY.md              # Security & vulnerability disclosure
β”œβ”€β”€ docs/                    # Detailed documentation
β”‚   β”œβ”€β”€ README.md           # Full setup & configuration guide
β”‚   β”œβ”€β”€ ARCHITECTURE.md     # Multi-tenant database design
β”‚   β”œβ”€β”€ STATELESS_ARCHITECTURE.md # Zero-storage options
β”‚   β”œβ”€β”€ MIGRATION_GUIDE.md  # Migrate to stateless
β”‚   β”œβ”€β”€ SECURITY_ANALYSIS.md # Detailed security review
β”‚   β”œβ”€β”€ STATELESS_QUICKSTART.md # Stateless quick start
β”‚   β”œβ”€β”€ DEPLOYMENT.md       # Deploy to Render
β”‚   β”œβ”€β”€ CONTRIBUTING.md     # Development workflow
β”‚   └── WORKFLOW.md         # Git workflow guide
└── .github/                 # GitHub configs
    └── copilot-instructions.md

πŸ“š Documentation

πŸ”‘ Features

  • πŸ’³ Credit card balance & utilization tracking
  • πŸ“Š Transaction history & spending analysis
  • πŸ“ˆ Credit report integration (Experian)
  • 🌐 Web dashboard with visualizations
  • πŸ“± Responsive mobile-friendly UI
  • βš™οΈ Setup wizard for initial Plaid configuration
  • πŸ₯ Health check endpoints for deployment monitoring

βš™οΈ Tech Stack

  • Python 3.11+
  • Flask - Web framework
  • Plaid API - Financial data
  • Experian API - Credit reports
  • Gunicorn - Production server
  • pytest - Testing framework

πŸ§ͺ Testing

Run Tests

# Activate virtual environment
.\.venv\Scripts\Activate.ps1

# Install test dependencies
pip install -r requirements.txt

# Run all tests
pytest

# Run with coverage
pytest --cov=src --cov-report=html

# Run specific test file
pytest tests/test_plaid_integration.py

# Run tests matching pattern
pytest -k "test_plaid"

View Coverage Report

# Generate HTML coverage report
pytest --cov=src --cov-report=html

# Open in browser
start htmlcov/index.html

Test Structure

tests/
β”œβ”€β”€ conftest.py                  # Pytest configuration & fixtures
β”œβ”€β”€ test_plaid_integration.py    # Plaid API tests (mocked)
β”œβ”€β”€ test_experian_integration.py # Experian API tests (mocked)
└── test_app.py                  # Flask app tests

Coverage Goal: 70%+ for core business logic

πŸ› οΈ Development

Available Endpoints

Web Dashboard:

  • GET / - Main dashboard (shows setup instructions if credentials not configured)
  • GET /health - Health check endpoint (for deployment monitoring)
  • GET /config-status - Check configuration status

API Endpoints:

  • GET /api/data - Full credit data (transactions, cards, balances)
  • GET /api/transactions - Transactions only

Setup on First Run

When you first run the app, if PLAID_ACCESS_TOKEN is not configured:

  1. The dashboard displays an interactive setup page
  2. Guides you through getting Plaid credentials
  3. Instructions for running scripts/setup_plaid_token.py
  4. Easy steps to configure environment variables on Render
# Create feature branch
git checkout -b feature/your-feature

# Make changes and commit
git commit -m "feat: your feature"

# Push and create PR
git push -u origin feature/your-feature
gh pr create --base main

See CONTRIBUTING.md for full workflow.

πŸ” Security & Compliance

This application handles sensitive financial data and implements industry-standard security practices:

Data Protection

  • Encryption in Transit: All API calls use HTTPS/TLS 1.3
  • Encryption at Rest: Sensitive credentials encrypted in database
  • Password Security: Passwords hashed with bcrypt (12+ rounds)
  • Token Management: Short-lived access tokens with refresh rotation

Privacy & Compliance

  • GDPR Compliant: User data export and deletion endpoints
  • CCPA Ready: Privacy controls and audit logging
  • Audit Logging: All sensitive operations logged with timestamps and user context
  • Data Isolation: Per-user data access β€” users can only view their own data

Best Practices

  • Input Validation: All user input validated and sanitized
  • Rate Limiting: Auth endpoints protected against brute force attacks
  • Error Handling: Generic error messages (implementation details never exposed)
  • Third-Party Security: Vendors (Plaid, Experian) vetted for SOC 2 compliance

Responsible Disclosure

Found a security vulnerability? Please email security@example.com with:

  • Description of the vulnerability
  • Steps to reproduce
  • Potential impact
  • Suggested fix (if any)

We'll respond within 24 hours and credit you in our security notes.

See SECURITY.md for detailed security information and deployment checklist.

🚒 Deployment

Deploy to Render with one click:

  1. Connect GitHub repository
  2. Render auto-detects config/render.yaml
  3. Set environment variables
  4. Deploy!

See DEPLOYMENT.md for details.

πŸ“„ License

MIT License - See LICENSE for details

πŸ”— Links

About

Credit history monitoring app with Plaid & Experian API integration. Features: real-time credit card tracking, utilization analysis, transaction history, and beautiful Flask web dashboard.

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors