Technical Deep Dive

System Architecture

Kairon is engineered with a strictly decoupled, layered architecture to ensure maintainability, testability, and peak performance on all Android devices.

Clean Architecture Layers

The app follows Clean Architecture principles, ensuring that business logic is independent of UI and data sources.

┌─────────────────────────────────────────────────────────────┐
│                    Presentation Layer                       │
│  ┌─────────────────────────────────────────────────────┐    │
│  │                 UI Components                      │    │
│  │  • Screens (Home, Weekly, Import, Settings)       │    │
│  │  • Widgets (Cards, Sheets, Dialogs)               │    │
│  │  • Theme & Animations                             │    │
│  └─────────────────────────────────────────────────────┘    │
│  ┌─────────────────────────────────────────────────────┐    │
│  │              State Management                      │    │
│  │  • Riverpod Providers                             │    │
│  │  • Reactive UI Updates                            │    │
│  │  • State Persistence                               │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────┐
│                     Domain Layer                           │
│  ┌─────────────────────────────────────────────────────┐    │
│  │                 Business Logic                      │    │
│  │  • Entities (ClassEntity, TimetableEntity)        │    │
│  │  • Use Cases & Services                            │    │
│  │  • Validation Rules                                │    │
│  └─────────────────────────────────────────────────────┘    │
│  ┌─────────────────────────────────────────────────────┐    │
│  │              Repository Interfaces                 │    │
│  │  • ClassRepository                                 │    │
│  │  • TimetableRepository                             │    │
│  │  • AuthRepository                                  │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────┐
│                      Data Layer                            │
│  ┌─────────────────────────────────────────────────────┐    │
│  │                 Data Sources                        │    │
│  │  • SQLite Database (Sqflite)                       │    │
│  │  • Secure Storage (FlutterSecureStorage)           │    │
│  │  • File System (PDF/Image processing)              │    │
│  └─────────────────────────────────────────────────────┘    │
│  ┌─────────────────────────────────────────────────────┐    │
│  │             Repository Implementations              │    │
│  │  • SqfliteClassRepository                          │    │
│  │  • SqfliteTimetableRepository                      │    │
│  │  • SecureAuthRepository                            │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘

Unidirectional Data Flow

Predictable state transitions ensure a smooth user experience and easier debugging.

User Interaction → UI Event → Provider Update → Repository Call → Database/Storage → Response → UI Update
      │                │            │                │                │            │            │
      ▼                ▼            ▼                ▼                ▼            ▼            ▼
   Tap Button    → onPressed() → ref.read() → repo.method() → SQL/File Ops → Result → setState()

Design Patterns

Repository Pattern

Abstracts data access behind interfaces, allowing for platform-specific implementations and easy mocking for tests.

Provider Pattern (Riverpod)

Handles declarative state management and reactive UI updates with a focus on compile-time safety.

Service Layer

Encapsulates complex business logic and cross-cutting concerns like validation and OCR processing.

Security & Privacy

Privacy by design is at the core of Kairon's development.

Authentication Flow:
Biometric/PIN → Secure Storage → Auth State → UI Permissions

Data Protection:
User Data → AES-256 Encryption → Secure Storage → Platform Keychain

Network Security:
Offline-First → Local Processing → No External APIs → Privacy by Design