> ## Documentation Index
> Fetch the complete documentation index at: https://docs.learnway.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# In-House Systems vs. Third-Party Integrations

> Comprehensive breakdown of LearnWay proprietary in-house software versus integrated third-party infrastructure and external APIs.

# In-House Systems vs. Third-Party Integrations

The LearnWay ecosystem combines **proprietary in-house platforms** with **enterprise-grade third-party infrastructure** to deliver a performant, gasless, and gamified learn-and-earn experience.

***

## Ecosystem Boundary Map

```mermaid theme={null}
graph TD
    subgraph InHouse["🏢 In-House Built Platforms & Microservices"]
        Mobile["learnway-mobile (Mobile Client)"]
        Backend["learnway-backend (Core API)"]
        AIService["learnway-ai-service (AI Engine)"]
        NotifService["learnway-notification-service"]
        TxRelayer["learnway-transaction-processor"]
        AltoBundler["/alto (Hosted Bundler)"]
        TxAPI["transactions_apiv2 (Ledger API)"]
        Contracts["learnway_onchain_infrastructure (Contracts)"]
    end

    subgraph ThirdParty["🌐 Third-Party Providers & External Infrastructure"]
        Lisk["Lisk L2 Blockchain"]
        Gemini["Google Gemini (LLMs)"]
        Goldsky["Goldsky (Subgraph Indexer)"]
        DIDit["DIDit (KYC & Identity Verification)"]
        Fonbnk["Fonbnk (Fiat/Mobile Money Rails)"]
        FCM["Firebase Cloud Messaging (FCM)"]
        Resend["Resend (Transactional Email)"]
        RevenueCat["RevenueCat (App Store / Play Billing)"]
        MediaCDN["ImageKit / IPFS (Media & NFTs)"]
    end

    Mobile --> Backend
    Mobile --> AltoBundler
    Mobile --> DIDit
    DIDit -->|Signed Verification Webhook| Backend
    Backend --> Contracts
    Backend --> AIService
    Backend --> NotifService
    Backend --> TxRelayer

    AIService --> Gemini
    NotifService --> FCM
    NotifService --> Resend
    TxRelayer --> Lisk
    AltoBundler --> Lisk
    Lisk --> Goldsky
    Goldsky --> TxAPI
    TxAPI --> Mobile
    Backend --> Fonbnk
    Mobile --> RevenueCat
```

***

## 1. In-House Built Systems (Core IP)

All components in this category were developed in-house to power LearnWay's unique business logic, gamification rules, on-chain execution, and user experience.

| In-House Component          | Repository / Service               | Architectural Responsibilities                                                                                                                                                                                                                                          |
| :-------------------------- | :--------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Core Monolith API**       | `learnway-backend`                 | Central NestJS REST API, course/lesson state machine, gamification computation, WebSocket PvP quiz battle matchmaker, and `VerifyingPaymaster` policy engine.                                                                                                           |
| **Mobile Client App**       | `learnway-mobile/`                 | Cross-platform mobile client with embedded smart account wallet integration, interactive lesson player, AI tutor chat UI, and biometric PIN vault.                                                                                                                      |
| **Smart Contract Suite**    | `learnway_onchain_infrastructure/` | Solidity smart contracts on Lisk L2: `LearnWayAdmin.sol` (RBAC), `LearnWayManager.sol` (Coordinator), `XPContract.sol` & `GemContract.sol` (Gamification State Engines), `BadgesNFT.sol` (ERC-721), `LearnWayCertificate.sol` (ERC-1155), and `VerifyingPaymaster.sol`. |
| **AI Inference Service**    | `learnway-ai-service/`             | Prompt assembly, course slide context injection engine, 24-hour deterministic Redis cache, onboarding skill evaluator, and automated Capstone Project code grading.                                                                                                     |
| **Notification Engine**     | `learnway-notification-service/`   | Standalone BullMQ message worker, mobile device token lifecycle manager & invalid token pruner, and multi-channel template renderer.                                                                                                                                    |
| **Blockchain Relayer**      | `learnway-transaction-processor/`  | Dedicated transaction execution relayer using Redis atomic nonce locks, 15-second automated gas price escalation, and block confirmation receipt polling.                                                                                                               |
| **Transaction History API** | `transactions_apiv2/`              | Dedicated wallet ledger query service serving historical token transfers and reward logs directly to mobile clients.                                                                                                                                                    |
| **Hosted Pimlico Bundler**  | `/alto`                            | Self-hosted Alto ERC-4337 bundler instance simulating, batching, and submitting client `UserOperation`s to Lisk L2.                                                                                                                                                     |

***

## 2. Integrated Third-Party Infrastructure & APIs

LearnWay integrates best-in-class external services to ensure enterprise scalability, global payment accessibility, and high availability.

| Third-Party Provider | Category              | Purpose in LearnWay                                                                                                      | Integration Mechanism       |
| :------------------- | :-------------------- | :----------------------------------------------------------------------------------------------------------------------- | :-------------------------- |
| **Lisk L2**          | Blockchain L2         | EVM-compatible OP Stack Layer 2 rollup providing sub-cent transaction execution and rapid finality.                      | JSON-RPC (Ethers v6 / Viem) |
| **Google Gemini**    | Generative AI         | Gemini 1.5 Pro & Flash models powering interactive lesson tutoring, quiz hints, and student project evaluation.          | Google Generative AI SDK    |
| **DIDit**            | KYC & Identity Engine | Decentralized identity & KYC verification absorbing user biometric/document compliance and AML risk.                     | Hosted SDK + Signed Webhook |
| **Goldsky**          | Web3 Subgraph Indexer | Real-time on-chain event streaming from Lisk L2, indexing badge mints and transfers into dedicated query databases.      | Goldsky Subgraphs / GraphQL |
| **Fonbnk**           | Fiat / On-Ramp Rails  | Fiat-to-crypto (USDT/fUSD) on-ramp via African & LatAm mobile money and airtime rails (NGN, KES, GHS, UGX, ZAR, BRL).    | REST API + HMAC Webhooks    |
| **Firebase (FCM)**   | Mobile Push Delivery  | Cross-platform push notifications delivering streak reminders, match alerts, and contest announcements to iOS & Android. | Firebase Admin SDK          |
| **Resend**           | Transactional Email   | High-deliverability email pipeline for 6-digit OTP verification codes, password resets, and certificates.                | Resend API / React Email    |
| **RevenueCat**       | Mobile Payments       | In-app purchases, subscription management, and receipt validation across Apple App Store and Google Play.                | REST API + Webhooks         |
| **ImageKit / IPFS**  | Media & Asset CDN     | Media transformation for slide assets and decentralized immutable storage for NFT badge metadata and artwork.            | REST API & IPFS Gateways    |
| **Redis**            | In-Memory Data Store  | High-performance distributed locks, rate-limiting counters, and BullMQ asynchronous message queues.                      | ioredis / BullMQ            |
| **PostgreSQL**       | Primary Database      | Relational database persisting users, curriculum, progress, battle histories, and transaction ledgers.                   | TypeORM                     |

***

## Architectural Separation Principles

1. **Decoupled Failure Domains**: Failure in any third-party service (e.g. Gemini LLM outage or Fonbnk API maintenance) is isolated by circuit breakers and does not bring down core lesson navigation or local user progress.
2. **Abstracted Interfaces**: Third-party providers are wrapped behind internal NestJS services and providers (e.g., `PaymentService`, `BlockchainProviderService`, `AiService`), allowing providers to be swapped or multi-homed without modifying domain business logic.
3. **Optimized Cost Architecture**: In-house caching layers (such as the 24-hour deterministic Redis cache for AI responses) minimize external API token consumption and vendor costs.
