CoolLib — Native Android Client

Jetpack Compose Kotlin MVVM Hilt DI

A high-performance library management mobile application featuring a "Book-Style" custom design system. Built with Clean Architecture, it provides an offline-first experience with real-time synchronization to the Spring backend.

Architectural Philosophy

CoolLib Android is engineered using Modern Android Development (MAD) practices. By implementing a reactive data pipeline and strict layer separation, the app ensures a fluid user experience even under complex data states and varying network conditions.

Key Technical Wins

Clean Architecture

Implemented strict MVVM with isolated Data, Domain, and UI layers using Kotlin-First principles for maximum maintainability.

Performance Tuning

Reduced data load times by 60% via Coroutines (async/awaitAll) for concurrent repository-level data mapping and transformation.

Dependency Injection

Engineered a robust DI graph with Hilt, utilizing custom Qualifiers (@IoDispatcher) for granular threading control.

Reactive Pipeline

Built a real-time data flow using StateFlow/SharedFlow integrated with Room for a reliable "Offline-First" experience.


Data Flow Architecture

Android App Architecture
flowchart LR subgraph DI ["`**Hilt Dependency Injection**`"] Hilt end subgraph Data ["`**Data Layer**`"] direction TB Room[(Room Database)] DAO(Data Access Objects) Impl(RepositoryImpl) end subgraph Domain ["`**Domain Layer**`"] direction TB RepoI(interface Repository) UC(UseCases / Interactors) end subgraph Presentation ["`**UI Layer**`"] direction TB VM(ViewModel) UIState([UiState]) Compose(Jetpack Compose) end Room <--> DAO Impl --> DAO Impl -.->|Implements| RepoI UC --> RepoI VM --> UC VM -- "Exposes" --> UIState UIState -- "Renders" --> Compose Compose -- "User Action" --> VM Hilt -.->|Inject| DAO Hilt -.->|Binds interface to| Impl Hilt -.->|Inject| UC Hilt -.->|Inject| VM style Hilt fill:#0284c7,stroke:#0369a1,stroke-width:2px,color:#ffffff style Room fill:#334155,stroke:#1e293b,stroke-width:2px,color:#ffffff style DAO fill:#475569,stroke:#334155,stroke-width:2px,color:#ffffff style Impl fill:#64748b,stroke:#475569,stroke-width:2px,color:#ffffff style RepoI fill:#0d9488,stroke:#0f766e,stroke-width:2px,color:#ffffff style UC fill:#14b8a6,stroke:#0d9488,stroke-width:2px,color:#ffffff style VM fill:#16a34a,stroke:#15803d,stroke-width:2px,color:#ffffff style UIState fill:#bbf7d0,stroke:#16a34a,stroke-width:2px,color:#14532d style Compose fill:#f0fdf4,stroke:#16a34a,stroke-width:2px,color:#166534 style DI fill:none,stroke:#0284c7,stroke-dasharray: 5 5 style Data fill:none,stroke:#475569,stroke-dasharray: 5 5 style Domain fill:none,stroke:#0d9488,stroke-dasharray: 5 5 style Presentation fill:none,stroke:#16a34a,stroke-dasharray: 5 5 linkStyle default stroke:#64748b,stroke-width:1.5px

Strict Unidirectional Data Flow (UDF) powered by Kotlin StateFlow and Hilt DI.

Single Source of Truth (SSOT)

Data Fetching Logic (Search vs Detail)
graph LR %% ==================== 搜索场景 ==================== subgraph Search_Scenario ["`**BookScreen - Search (Remote Only)**`"] SUI(Search UI) SVM(SearchViewModel) SRepo(BookRepository) SAPI[Retrofit API] SUI -->|1. Type Query| SVM SVM -->|2. Call| SRepo SRepo -->|3. HTTP GET| SAPI SAPI -.->|4. DTO List| SRepo SRepo -.->|5. Domain Models| SVM SVM -.->|6. Update StateFlow| SUI end %% 强制垂直隔离线 Search_Scenario --- Detail_Scenario linkStyle 0 stroke:transparent,stroke-width:0px; %% ==================== 详情页场景 ==================== subgraph Detail_Scenario ["`**BookDetailScreen - Cache First**`"] DUI(Detail UI) DVM(DetailViewModel) DRepo(BookRepositoryImpl) DB[(Room DB)] DAPI[Retrofit API] %% UI 到 Repo 的请求流 DUI -->|1. Request ID| DVM DVM -->|2. Fetch| DRepo %% 缓存优先策略 (Cache-First) DRepo -->|3. Check Cache| DB DB -.->|4a. Found: Return Data| DRepo %% 缓存未命中流 (Cache Miss) DRepo -->|4b. Miss: Fetch Remote| DAPI DAPI -->|5. Save Network DTO| DB DB -.->|6. Emit Updated Data| DRepo %% 统一返回 UI 流 DRepo -.->|7. Domain Model| DVM DVM -.->|8. BookUiState| DUI end %% ==================== 现代 Slate & Teal 样式 ==================== %% 节点样式 style SUI fill:#f0fdf4,stroke:#16a34a,stroke-width:2px,color:#166534 style DUI fill:#f0fdf4,stroke:#16a34a,stroke-width:2px,color:#166534 style SVM fill:#16a34a,stroke:#15803d,stroke-width:2px,color:#ffffff style DVM fill:#16a34a,stroke:#15803d,stroke-width:2px,color:#ffffff style SRepo fill:#0d9488,stroke:#0f766e,stroke-width:2px,color:#ffffff style DRepo fill:#0d9488,stroke:#0f766e,stroke-width:2px,color:#ffffff style SAPI fill:#475569,stroke:#334155,stroke-width:2px,color:#ffffff style DAPI fill:#475569,stroke:#334155,stroke-width:2px,color:#ffffff style DB fill:#334155,stroke:#1e293b,stroke-width:2px,color:#ffffff %% 容器样式 style Search_Scenario fill:none,stroke:#64748b,stroke-width:1.5px,stroke-dasharray: 3 3 style Detail_Scenario fill:none,stroke:#64748b,stroke-width:1.5px,stroke-dasharray: 3 3 %% 全局线条 linkStyle default stroke:#64748b,stroke-width:1.5px

*Search provides real-time results, while Details use an on-demand caching strategy.*


Tech Stack

  • UI Framework: Jetpack Compose, Material 3, Coil, Compose Navigation
  • Logic & Concurrency: MVVM, Clean Architecture, Coroutines, Kotlin Flow, Hilt (DI)
  • Data Persistence: Retrofit, Moshi, Room (Local DB), DataStore

Core Features

Method Endpoint Business Logic & Description Auth
POST /api/loan/checkout Initiate Loan: Validates scanned ISBN against library inventory. Checks user borrowing limits and calculates the initial 14-day due date.
GET /api/loan/active Real-time Status: Returns a list of current holdings. Backend performs dynamic calculations for "Days Remaining" and marks items as OVERDUE if past deadline.
PATCH /api/loan/extend/{id} Renewal Request: Extends due date by 7 days. Conflict Check: Request is rejected if the book has an active Reservation by another user. Policy-Driven
GET /api/loan/history Audit Trail: Accesses archived loan records. Useful for Personal Analytics and verifying returned dates to resolve disputes.
PUT /api/loan/reminders Fulfillment Logic: Syncs device FCM Token to backend. Triggers automated push alerts 2 days before the due date to minimize late fees. Automation
Reliability
Local-First Persistence

Ensuring acid-compliant data integrity with Room. Designed for seamless offline-to-online synchronization and complex relational queries.

Performance
Asynchronous Orchestration

Eliminating UI stutters by offloading heavy I/O to Coroutines. Utilizing Flow for predictable, thread-safe data streams.

Scalability
Domain-Centric Logic

Decoupling business rules from UI frameworks. This modular approach enables rapid feature iteration and high unit-test coverage.

Agility
Declarative Composition

Leveraging State-Hoisting and unidirectional data flow for a 100% type-safe UI that adapts fluidly to dynamic content states.

Search Engine Architecture

A multi-layered discovery system designed to transform high-velocity user input into precise, sub-millisecond local data matches.

Sub-ms Room FTS5

Implementing Full-Text Search (FTS5) virtual tables for instant prefix matching across thousands of book metadata records.

Debounced Stream Processing

Leveraging Kotlin Flow operators to throttle search emissions, preserving battery and CPU resources during rapid typing.

"Paper-like" Tactile UX

Modern high-contrast typography and Custom Compose Canvas highlighting ensure a tactile, precision-driven feel during discovery.

Input
Reactive Flow Debounced Filter
FTS5 Virtual Table Optimized Prefix Match
SQLite Data Foundation Multifield Global Index (FTS5 Table)
ALGORITHM: FTS5 Match
STREAM: Kotlin Flow
LATENCY: <1.2ms

Where Paper Meets Pixels

CoolLib isn't just an app; it's a digital sanctuary for your collection. We've translated the weight and warmth of a physical library into a fluid, modern mobile experience.

Visual Storytelling

Browse through your 'Fiction' and 'History' aisles with rich, edge-to-edge book covers that bring your screen to life.

Thoughtful Curation

From 'Recently Viewed' classics to your 'Favourites' shelf, your next read is always exactly where you left it.

Tailored for You

A seamless blend of minimalist elegance and intuitive navigation, designed to keep the focus entirely on the stories.

Kotlin Jetpack Compose Custom UI Artistry
Live demo connected to the production backend stack.

Engineered with passion by Ryan Su © 2026