> ## 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.

# Microservices Architecture Overview

> Architecture of standalone microservices in the LearnWay ecosystem: AI Microservice and Notification Microservice.

# Microservices Architecture Overview

To maintain high responsiveness and prevent heavy computational or external API workloads from degrading core backend performance, LearnWay decouples specialized subsystems into standalone microservices.

```mermaid theme={null}
graph TD
    subgraph CorePlatform["⚡ Core Orchestration"]
        Backend["LearnWay Core Monolith (learnway-backend)"]
        RedisQueue["Redis & BullMQ Message Broker"]
    end

    subgraph MicroservicesSuite["⚙️ Standalone Microservices"]
        AIService["AI Microservice (learnway-ai-service)<br/>• Google Gemini 1.5 Pro / Flash<br/>• Context Injection Engine<br/>• 24h Deterministic Cache"]
        NotifService["Notification Microservice (learnway-notification-service)<br/>• Firebase Cloud Messaging (FCM)<br/>• Resend Transactional Email<br/>• Device Token Registry"]
    end

    Backend <-->|Direct RPC / HTTP| AIService
    Backend -->|Enqueue Job Events| RedisQueue
    RedisQueue -->|Async Event Processing| NotifService
```

***

## Standalone Microservices Directory

* **[AI Microservice (`learnway-ai-service/`)](/architecture/microservices/ai-service)**:
  * Generative AI tutoring, dynamic onboarding skill assessments, and automated Capstone Project code evaluations.
  * Injects course lesson slides and student history into Google Gemini prompt pipelines with Redis caching.

* **[Notification Microservice (`learnway-notification-service/`)](/architecture/microservices/notification-service)**:
  * Multi-channel delivery engine coordinating mobile push notifications (FCM), transactional emails (Resend), and in-app alert synchronization.
  * Dedicated token lifecycle management and BullMQ background queue workers.

***

## Key Benefits of Decomposition

1. **Independent Scalability**: High-frequency LLM tutoring requests or mass push broadcast batches scale in dedicated container instances without consuming thread pool resources on the core REST/WebSocket server.
2. **Failure Isolation**: Upstream rate limits or temporary third-party API latency (Gemini, FCM, Resend) never impact user login, lesson navigation, or PvP quiz battles.
3. **Optimized Resource Profiles**: The AI service can be allocated memory and compute tuned for prompt streaming and payload transformations, while the core backend remains lightweight.
