AHC Intelligence — Quantum Compliance SaaS

💡 Inspiration

Cross-border financial regulations and compliance mandates (KYC/AML) have ceased to be an exclusive burden for multinational banking institutions. Today, severe regulatory pressure falls heavily upon non-financial obligated subjects: law firms, risk consultants, asset managers, and especially public notaries. In jurisdictions like Uruguay, these professionals face strict statutory liabilities and severe administrative or criminal sanctions under AML frameworks if they fail to perform rigorous due diligence.

The current state of the industry is alarming. Professionals execute Know Your Customer (KYC) procedures by manually fracturing queries across disconnected legacy databases. Furthermore, document forensic analysis is often limited to a visual inspection prone to human error, and comprehensive contract auditing drains dozens of billable bill hours.

We were inspired to democratize institutional-grade financial intelligence. Our vision was to unify a secure, production-ready ecosystem of multi-modal autonomous agents capable of neutralizing compliance risks, turning a complex legal maze into an instant, single-pane-of-glass technical workflow.


🛠️ How We Developed the Project & AI-Native Architecture

To handle high-stakes regulatory data, we rejected traditional monolithic systems or client-side heavy inference models, which jeopardize user experience and expose sensitive corporate logic. Instead, we engineered a decoupled, cloud-native, and asynchronous hybrid architecture designed for extreme token efficiency:

Serverless Frontend & Real-Time State (Google Firebase)

  • Firebase Hosting: Delivers our Single Page Application (SPA) frontend with ultra-low latency, hardened with strict security headers (HSTS, X-Frame-Options: DENY, X-Content-Type-Options) to prevent clickjacking and injection vectors.
  • Cloud Firestore: Functions as our real-time NoSQL database and, fundamentally, as an asynchronous transactional message queue via the tareas_pendientes collection.
  • Firebase Storage: Handles the secure, encrypted, and isolated ingestion of sensitive user-uploaded documentation (passports, national IDs, corporate deeds) before secure backend processing.

Asynchronous Heavy Processing & Orchestration (Google Cloud Run)

All heavy computational workflows are delegated to an optimized Docker container deployed on Google Cloud Run within the us-central1 region. We configured the service with a minimum instance policy ($min_instances = 1$), completely eliminating cold starts and ensuring our processing backend responds within milliseconds.

The backend architecture concurrently runs two critical modules:

  1. High-Speed Polling Loop: A continuous execution thread that monitors the Firestore tareas_pendientes collection every 10 seconds to detect new documents marked with a PENDIENTE state.
  2. Subscription Monitor (PayPal Live): A background worker checking state webhooks every 30 seconds to validate live payment activations, mitigating pricing tier fraud.

Multi-Agent Structural Prompting

Our core intelligence does not rely on simple wrapper APIs. We developed a proprietary framework of four independent agents powered by Gemini 2.5 Flash, using rigidly structured system instructions that force the model to output quantitative risk metrics via deterministic JSON objects:

  • agent_compliance.py (KYC/AML & Forensics): Integrates Google Search Grounding to perform live cross-border sanction tracking (OFAC, PEPs). For forensics, it executes a 4-layer multi-modal inspection evaluating file metadata, Error Level Analysis (ELA) for digital pixel tampering, typographical consistency, and AI-driven signature/seal verification.
  • agent_contracts.py (Contract Audit): Analyces the legal semantics of complex documentation to flag asymmetric commercial liabilities, missing clauses, and regulatory non-compliance.
  • agent_legal_chat.py (Regulatory Guide): A conversational agent acting as an interactive compliance consultant, allowing professionals to query long-form legal frameworks against uploaded PDFs.
  • agent_markets.py (Financial & Asset Module): Specializes in automated investment portfolio auditing, combining technical and fundamental analysis anchored via real-time search grounding to assess market sentiment.

🚀 Challenges We Faced & Engineering Solutions

Challenge 1: Secure Credential Injection in Ephemeral Environments

Problem: The Firebase Admin SDK private key (serviceAccountKey.json) contains escape characters, line breaks, and highly sensitive cryptographic strings. Passing this raw string into Cloud Run environment variables often corrupts the format during runtime instantiation, while keeping physical files in the source tree poses massive security vulnerabilities. Solution: We built a deployment pipeline where the entire configuration JSON is locally encoded into a single flat string using Base64 ($FIREBASE_CREDENTIALS_B64$). Upon container startup, our runtime wrapper (entrypoint.py) decodes the string directly into volatile memory, completely avoiding physical disk persistence and guaranteeing a zero-knowledge cloud deployment.

Challenge 2: Mitigating Token Costs & API Latency via Local SQLite Caching

Problem: In risk assessment workflows, different professionals frequently query the exact same legal entity or corporate identity within short time windows. Repeatedly triggering multi-modal LLM inferences and search grounding for identical records generated unsustainable API token overhead. Solution: We designed a lightning-fast local cache layer leveraging an SQLite database inside the Cloud Run storage layer. Before calling the Gemini API, the agent hashes the query parameters. If a valid, non-expired entry exists, it serves the comprehensive intelligence report at an exact marginal cost of $\$0$ in tokens. We added a defensive detection metric where any historical test reports containing SIMULADO flags are automatically purged, forcing a live, real-world API re-analysis.

Challenge 3: Enforcing Atomic Credit Ledgers Against Client-Side Tampering

Problem: Allowing the frontend client to manipulate or decrement a user's balance when consuming AI features represents a critical B2B vulnerability; malicious actors could intercept the HTTP traffic to bypass paywalls. Solution: All financial transactional logic was completely isolated within the Cloud Run backend. The frontend merely initializes a task. The processing engine, utilizing atomic transactions via Firebase Admin SDK's FieldValue.increment(), acts as the sole authority. It evaluates if the account has a sufficient balance ($credits_{available} \ge credits_{cost}$) and decrements the precise ledger cost (varying from 25 credits for a basic forensic check up to 75 credits for advanced portfolio auditing), entirely neutralizing client-side browser exploits.


🧠 What We Learned

Building AHC Intelligence solidified a core engineering truth: Artificial Intelligence in high-liability verticals like legal and financial compliance cannot be treated as a casual chatbot. It must act as a structured, deterministic infrastructure component. We learned to tame the stochastic nature of LLMs through strict type-forcing schemas, ensuring that risk metrics delivered to professionals remain completely homogeneous, auditable, and reliable.

Furthermore, we proved that decoupling our architecture (leaving client reactivity to Firebase and scaling heavy inference via Cloud Run) yields massive operational benefits. It allows us to provide a fluid, snappy web application to end-users while executing multi-modal processing and mathematical portfolio rebalancing on an enterprise grade backend.

Built With

Share this project:

Updates