# icecream0910/kw-klas-plus architecture

> Architecture diagram of the GitHub repository icecream0910/kw-klas-plus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/icecream0910/kw-klas-plus
- Repository: https://github.com/icecream0910/kw-klas-plus

## Overview

##### Main Components

a) Client-Side Components:
- Android Native UI Layer
- Activities (MainActivity, HomeActivity, LoginActivity, etc.)
- Custom Components (AnimatedButton, etc.)
- Widgets (LibraryQRWidget)
- WebView Integration Layer
- BackgroundWebView
- Custom WebView implementations

b) External Services:
- KLAS Main Server
- Library QR System
- KLAS GPT Service (Beta)
- WebView Content Server

##### Architecture Pattern Representation

**┌─────────────────────────────────────────────┐**
- UI Layer                      │
- ┌─────────────┐  ┌─────────────┐          │
- Native    │  │   WebView   │          │
- Activities │  │  Interface  │          │
- ┘  └─────────────┘          │
- ┤
- Business Logic                  │
- ┌─────────────┐  ┌─────────────┐          │
- QR Scanner  │  │  Video      │          │
- Service     │  │  Player     │          │
- ┘  └─────────────┘          │
- ┤
- External Services               │
- ┌─────────────┐  ┌─────────────┐          │
- KLAS API   │  │ Library QR  │          │
- Interface  │  │  System     │          │
- ┘  └─────────────┘          │
- ┘

##### Key Interactions to Highlight

- Authentication flow between LoginActivity and KLAS server
- WebView communication with KLAS system
- QR code scanning and library system interaction
- Video player PIP mode implementation
- Widget updates and system integration

##### Implementation Details

- Double lines for data persistence

##### Component Grouping

Related components:
**Main Features Group:**
- Lecture viewing system
- Assignment tracking
- QR attendance
- Library card widget

**Support Features Group:**
- GPT integration
- Menu viewing
- Notice system
- Grade tracking

##### Technical Stack Indication

- Kotlin
- Android SDK
- WebView
- Camera API
- Widget API

Remember to:
- Use consistent styling
- Version information
- Document main data flows
- Security boundaries

This system design should effectively communicate both the high-level architecture and the detailed implementation specifics of the KLAS+ application while maintaining clarity and usefulness for development team members.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef webview fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef business fill:#9b59b6,stroke:#8e44ad,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white

    %% UI Layer
    subgraph UILayer["UI Layer"]
        direction TB
        MainActivity["MainActivity"]:::ui
        HomeActivity["HomeActivity"]:::ui
        LoginActivity["LoginActivity"]:::ui
        LectureActivity["LectureActivity"]:::ui
        AnimatedButton["AnimatedButton"]:::ui
        LibraryQRWidget["LibraryQRWidget"]:::ui
    end

    %% WebView Layer
    subgraph WebViewLayer["WebView Integration Layer"]
        direction TB
        BackgroundWebView["BackgroundWebView"]:::webview
        WebViewContent["WebView Content"]:::webview
    end

    %% Business Logic Layer
    subgraph BusinessLayer["Business Logic Layer"]
        direction TB
        QRScanner["QR Scanner Service"]:::business
        VideoPlayer["Video Player"]:::business
        SpeedModal["Speed Control"]:::business
        LibraryQRModal["Library QR Modal"]:::business
    end

    %% External Services Layer
    subgraph ExternalLayer["External Services"]
        direction TB
        KLASServer["KLAS Main Server"]:::external
        LibrarySystem["Library QR System"]:::external
        KLASGPTService["KLAS GPT Service"]:::external
    end

    %% Relationships
    MainActivity --> HomeActivity
    LoginActivity --> KLASServer
    HomeActivity --> BackgroundWebView
    BackgroundWebView --> WebViewContent
    WebViewContent --> KLASServer
    
    LibraryQRWidget --> LibrarySystem
    QRScanner --> LibrarySystem
    VideoPlayer --> SpeedModal
    LibraryQRWidget --> LibraryQRModal
    
    HomeActivity --> KLASGPTService
    HomeActivity --> VideoPlayer
    HomeActivity --> QRScanner

    %% Click events for component mapping
    click MainActivity "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/MainActivity.kt"
    click HomeActivity "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/HomeActivity.kt"
    click LoginActivity "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/LoginActivity.kt"
    click LectureActivity "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/LectureActivity.kt"
    click BackgroundWebView "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/BackgroundWebView.kt"
    click AnimatedButton "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/components/AnimatedButton.kt"
    click LibraryQRWidget "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/LibraryQRWidget.kt"
    click QRScanner "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/QRScanActivity.kt"
    click VideoPlayer "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/VideoPlayerActivity.kt"
    click SpeedModal "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/modal/SpeedModal.kt"
    click LibraryQRModal "https://github.com/icecream0910/kw-klas-plus/blob/main/app/src/main/java/com/icecream/kwklasplus/modal/LibraryQRModal.kt"

    %% Legend
    subgraph Legend
        direction TB
        UI["UI Components"]:::ui
        WV["WebView Components"]:::webview
        BL["Business Logic"]:::business
        EX["External Services"]:::external
        SP["Support Components"]:::support
    end
```
