API Reference

Complete reference documentation for Archery Apprentice components.


Quick Navigation

Core Components

  • ViewModels - UI state management (21 ViewModels)
  • Repositories - Data access layer (17 Repositories)
  • Services - Business logic services (19 Services)
  • DAOs - Database access objects (15 DAOs)

Architecture Overview

graph TB
    VM[ViewModels] --> Repo[Repositories]
    Repo --> Service[Services]
    Service --> DAO[DAOs]
    DAO --> DB[(Room Database)]

    style VM fill:#e1f5ff
    style Repo fill:#fff3e0
    style Service fill:#f3e5f5
    style DAO fill:#e8f5e9

Component Responsibilities

ViewModels - Presentation Layer

  • Manage UI state with StateFlow
  • Handle user interactions
  • Coordinate repository calls
  • Transform data for UI display

Repositories - Data Layer Abstraction

  • Abstract data sources
  • Implement business data operations
  • Handle data mapping
  • Provide reactive data streams

Services - Business Logic

  • Encapsulate complex business rules
  • Coordinate multiple repositories
  • Perform calculations and transformations
  • Implement domain-specific logic

DAOs - Database Access

  • Define database queries
  • Provide type-safe database access
  • Handle CRUD operations
  • Implement Room annotations

Finding What You Need

By Feature Area

Scoring:

Equipment:

Tournament:

Statistics:

By Layer

Presentation Layer:

Data Layer:

Business Logic:


Documentation Conventions

Method Signatures

suspend fun methodName(
    param1: Type,
    param2: Type
): Result<ReturnType>

StateFlow Properties

val uiState: StateFlow<UiState>
private val _uiState = MutableStateFlow(UiState.initial())

Repository Pattern

interface Repository {
    suspend fun operation(): Result<Data>
    fun observeData(): Flow<Data>
}

Code Examples

Using a ViewModel

@Composable
fun MyScreen(
    viewModel: MyViewModel = viewModel()
) {
    val uiState by viewModel.uiState.collectAsState()
 
    MyScreenContent(
        state = uiState,
        onAction = viewModel::handleAction
    )
}

Using a Repository

class MyRepository(
    private val dao: MyDao
) {
    suspend fun getData(): Result<Data> = try {
        Result.success(dao.fetchData())
    } catch (e: Exception) {
        Result.failure(e)
    }
 
    fun observeData(): Flow<Data> =
        dao.observeData()
}

Using a Service

class MyService(
    private val repository: MyRepository
) {
    suspend fun performBusinessLogic(): Result<Output> {
        val data = repository.getData()
            .getOrElse { return Result.failure(it) }
 
        // Business logic
        val output = processData(data)
 
        return Result.success(output)
    }
}

Architecture:

Flows:

Testing:


Contributing to API Docs

API documentation follows this template:

# ComponentName
 
## Overview
Brief description of purpose
 
## Location
File path: `path/to/File.kt`
 
## Dependencies
- Dependency 1
- Dependency 2
 
## Public API
### Methods
Method signatures with descriptions
 
### Properties
StateFlow and public properties
 
## Usage Examples
Code examples showing common use cases
 
## Related
Links to related components

Contribute: Help us document remaining components!


Last Updated: 2025-11-01 Coverage: Foundation established, top components documented