Skip to content

System Architecture

This document provides a detailed overview of the ReversePilot system architecture, including database schema, service layer, and integration architecture.

Technology Stack

Backend

  • Framework: Django 4.2+
  • Language: Python 3.x
  • API: Django REST Framework
  • Authentication: OAuth2 Provider
  • Database: PostgreSQL (production) / SQLite (development)
  • Cache: Redis
  • File Storage: AWS S3

Frontend

  • Web application (separate repository)
  • RESTful API consumption
  • OAuth2 authentication

Application Structure

dc_los_django/
├── company/          # Company and user management
├── loan/            # Loan management and processing
├── documents/       # Document generation
├── apps/
│   ├── credit_report/    # Credit reporting integration
│   └── fha_integration/  # FHA Connection integration
└── dc_los_django/   # Project settings and configuration

Database Schema

Core Models

Company Models

  • Company: Company/organization information
  • User: System users with hierarchy and permissions
  • PermissionGroup: Collections of permissions
  • CompanySigner: Authorized document signers

Loan Models

  • Loan: Main loan application record
  • LoanProduct: Product configuration (HECM, proprietary)
  • Borrower: Loan applicant information
  • Property: Subject property information
  • Fee: Loan fees and charges
  • Appraisal: Property appraisal information
  • Title: Title information
  • CreditReport: Credit report data

Key Relationships

Company
  ├── Users (1:N)
  ├── LoanProducts (1:N)
  └── Loans (1:N)
      ├── Borrowers (1:N)
      ├── Property (1:1)
      ├── Fees (1:N)
      ├── CreditReports (1:N)
      └── Documents (1:N)

Service Layer

Loan Services

Location: loan/services/

  • loan_calculation.py: Principal limit and loan calculations
  • expected_rate.py: Expected rate calculations
  • interest_rate.py: Interest rate management
  • loan_documents_service.py: Document generation
  • fee_sync_service.py: Fee synchronization

Integration Services

  • flood_api.py: FloodCert.org integration
  • cleartrust_api.py: ClearTrust integration
  • mismo_service/: MISMO XML generation

Document Generation

Hard-Coded Documents

Location: documents/hard_coded_documents/

  • HTML Templates: Jinja2 templates for document generation
  • Python Data Generators: Functions that populate template data
  • Generator: Main document generation orchestrator

Document Flow

  1. User requests document generation
  2. System selects appropriate template
  3. Data generator extracts loan data
  4. Template is rendered with data
  5. HTML is converted to PDF
  6. PDF is stored and returned

Integration Architecture

  • XML-based API integration
  • MISMO 3.4 format
  • Automatic data parsing
  • PDF and XML storage

Flood Certificates (FloodCert.org)

  • REST API integration
  • Property address-based lookup
  • Automatic flood zone determination

FHA Connection

  • SOAP/XML integration
  • Multiple endpoint support
  • Credential management
  • Response parsing

MERS

  • MIN generation
  • Registration API
  • Loan tracking

Authentication & Authorization

OAuth2 Authentication

  • Token-based authentication
  • Refresh token support
  • Token expiration
  • Scope-based permissions

Permission System

  • Permission groups
  • Module-based permissions
  • Role assignment
  • Status transition permissions

Data Flow

Loan Creation Flow

  1. User creates loan via API
  2. System validates borrower age
  3. System selects appropriate loan product
  4. System creates loan record
  5. System creates initial fees
  6. System creates borrower and property records

Document Generation Flow

  1. User requests document
  2. System loads template
  3. System calls data generator
  4. System renders template with data
  5. System converts to PDF
  6. System stores PDF
  7. System returns PDF to user

Calculation Flow

  1. User requests calculation
  2. System retrieves loan data
  3. System retrieves current rates
  4. System calculates principal limit
  5. System calculates set-asides
  6. System returns calculation results

Caching Strategy

Redis Cache

  • Calculation results
  • Rate data
  • User sessions
  • API response caching

File Storage

AWS S3

  • Document PDFs
  • Credit report files
  • Appraisal documents
  • Other loan documents

Security

Data Protection

  • Encrypted data storage
  • Secure file storage
  • Encrypted credentials
  • Audit logging

Access Control

  • OAuth2 authentication
  • Permission-based authorization
  • Role-based access
  • Status transition controls

Deployment Architecture

Production Environment

  • Django application server (Gunicorn)
  • PostgreSQL database
  • Redis cache
  • AWS S3 storage
  • Load balancer
  • SSL/TLS encryption

Development Environment

  • Django development server
  • SQLite database
  • Local file storage
  • Development tools

Performance Considerations

Database Optimization

  • Indexed fields
  • Query optimization
  • Connection pooling
  • Database replication (production)

Caching

  • Calculation result caching
  • Rate data caching
  • Document template caching
  • API response caching

Async Processing

  • Background tasks for:
  • Credit report processing
  • Document generation
  • Email notifications
  • Report generation

Monitoring & Logging

Logging

  • Application logs
  • API access logs
  • Error logs
  • Audit logs

Monitoring

  • Application performance
  • Database performance
  • API response times
  • Error rates

Next Steps


For architecture questions, contact the development team.