# ayito/popis-alerta architecture

> Architecture diagram of the GitHub repository ayito/popis-alerta, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayito/popis-alerta
- Repository: https://github.com/ayito/popis-alerta

## Overview

#### Purpose and Current Scope
Popis Alerta is an Android app intended to support non-invasive in-home monitoring using a dedicated phone near a critical room. The implemented code is an early technical foundation: a Compose UI, navigation, local access-event persistence, and initial tests. Sensor detection, event history presentation, report sharing, and alerts are explicitly future work.

#### Runtime and Entry Points
The app is a Kotlin Android application built with Gradle, requiring JDK 21 and Android SDK Platform 36. Android launches the activity declared in `app/src/main/AndroidManifest.xml`; `app/src/main/java/org/popisalerta/app/MainActivity.kt` hosts the Compose application. Module and dependency boundaries are defined by `app/build.gradle.kts` and root `build.gradle.kts`.

#### Application Composition and Navigation
`app/src/main/java/org/popisalerta/app/MainActivity.kt` establishes the top-level Compose runtime and theme. `app/src/main/java/org/popisalerta/app/Navigation.kt` defines screen routing, while `app/src/main/java/org/popisalerta/app/NavigationKeys.kt` centralizes route identifiers. This is the principal UI control-flow boundary: activity startup leads into navigation, which selects composable screens.

#### Main Screen State Layer
The currently implemented feature surface is the main screen:
- `app/src/main/java/org/popisalerta/app/ui/main/MainScreen.kt`
- `app/src/main/java/org/popisalerta/app/ui/main/MainScreenViewModel.kt`

The ViewModel owns UI-facing state and coordinates user actions with persistence-oriented dependencies. The screen renders that state through Jetpack Compose rather than XML layouts, separating presentation from state/control logic.

#### Local Access Event Persistence
Access events are modeled and stored locally through a Room-style data stack:
- `app/src/main/java/org/popisalerta/app/data/local/AccessEntity.kt`
- `app/src/main/java/org/popisalerta/app/data/local/AccessDao.kt`
- `app/src/main/java/org/popisalerta/app/data/local/AccessDatabase.kt`

`AccessEntity` is the storage representation, `AccessDao` is the database access boundary, and `AccessDatabase` owns local database configuration. No network service or remote backend is represented in the repository.

#### Repository and Logging Boundary
`app/src/main/java/org/popisalerta/app/data/DataRepository.kt` abstracts data operations above the DAO/database layer. `app/src/main/java/org/popisalerta/app/data/AccessRepositoryProvider.kt` supplies repository access to higher layers. `app/src/main/java/org/popisalerta/app/AppAccessLogger.kt` is the app-level event logging entry point, likely intended to be called by future sensor-monitoring code before data reaches the repository/database.

The expected future flow is: native sensor input → access-event interpretation → `AppAccessLogger`/repository → Room persistence → ViewModel → Compose UI. Sensor integration is not yet present.

#### Important Future Integration Boundaries
Native Android sensors (light, motion, and experimental audio), Android’s native share sheet, and alerting mechanisms are product goals but have no implementation paths in the current tree. Their likely architectural insertion point is upstream of `AppAccessLogger.kt`; persisted records would remain behind `DataRepository.kt`, preserving the UI from direct sensor or storage coupling.

#### UI System and Validation
The visual system is centralized in `app/src/main/java/org/popisalerta/app/theme/Theme.kt` with related color/type definitions. Unit and instrumentation coverage target the major boundaries: logging, ViewModel/UI state, repository behavior, and activity rendering. Tests exist under `app/src/test` and `app/src/androidTest`, indicating both JVM and device/emulator execution paths.

Main entry points: [`app/src/main/java/org/popisalerta/app/data/DataRepository.kt`](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/DataRepository.kt) (Data repository), [`app/src/main/java/org/popisalerta/app/MainActivity.kt`](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/MainActivity.kt) (Main activity), [`app/src/main/java/org/popisalerta/app/Navigation.kt`](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/Navigation.kt) (Navigation), [`app/src/main/AndroidManifest.xml`](https://github.com/ayito/popis-alerta/blob/main/app/src/main/AndroidManifest.xml) (App manifest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Android runtime"]
  node_android{{"Android OS<br/>runtime"}}
  node_manifest["App manifest<br/>Android entry"]
  node_activity["Main activity<br/>Compose host<br/>[MainActivity.kt]"]
end

subgraph group_ui["Compose UI"]
  node_navigation["Navigation<br/>route controller<br/>[Navigation.kt]"]
  node_route_keys["Navigation keys<br/>route definitions<br/>[NavigationKeys.kt]"]
  node_theme["App theme<br/>Compose theme<br/>[Theme.kt]"]
  node_main_screen["Main screen<br/>Compose screen<br/>[MainScreen.kt]"]
  node_viewmodel["Main screen ViewModel<br/>UI state"]
end

subgraph group_data["Local data"]
  node_logger["App access logger<br/>event entry point<br/>[AppAccessLogger.kt]"]
  node_repository_provider["Repository provider<br/>dependency provider"]
  node_repository["Data repository<br/>persistence abstraction<br/>[DataRepository.kt]"]
  node_dao["Access DAO<br/>Room access boundary<br/>[AccessDao.kt]"]
  node_database[("Access database<br/>Room database<br/>[AccessDatabase.kt]")]
  node_entity["Access entity<br/>storage model<br/>[AccessEntity.kt]"]
end

subgraph group_future["Future integrations"]
  node_sensors{{"Native sensor input<br/>planned producer"}}
  node_sharing_alerts["Sharing and alerts<br/>planned outputs"]
end

node_android -->|"launches"| node_manifest
node_manifest -->|"declares"| node_activity
node_activity -->|"applies"| node_theme
node_activity -->|"hosts"| node_navigation
node_navigation -->|"uses"| node_route_keys
node_navigation -->|"routes to"| node_main_screen
node_main_screen -->|"renders state and actions"| node_viewmodel
node_viewmodel -->|"obtains repository"| node_repository_provider
node_repository_provider -->|"supplies"| node_repository
node_logger -->|"records events"| node_repository
node_repository -->|"persists and reads"| node_dao
node_dao -->|"accesses"| node_database
node_database -->|"stores"| node_entity
node_sensors -.->|"future access events"| node_logger
node_repository -.->|"future persisted records"| node_sharing_alerts

click node_manifest "https://github.com/ayito/popis-alerta/blob/main/app/src/main/AndroidManifest.xml"
click node_activity "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/MainActivity.kt"
click node_navigation "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/Navigation.kt"
click node_route_keys "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/NavigationKeys.kt"
click node_theme "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/theme/Theme.kt"
click node_main_screen "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/ui/main/MainScreen.kt"
click node_viewmodel "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/ui/main/MainScreenViewModel.kt"
click node_logger "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/AppAccessLogger.kt"
click node_repository_provider "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/AccessRepositoryProvider.kt"
click node_repository "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/DataRepository.kt"
click node_dao "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/local/AccessDao.kt"
click node_database "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/local/AccessDatabase.kt"
click node_entity "https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/local/AccessEntity.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_android,node_manifest,node_activity toneBlue
class node_navigation,node_route_keys,node_theme,node_main_screen,node_viewmodel toneAmber
class node_logger,node_repository_provider,node_repository,node_dao,node_database,node_entity toneMint
class node_sensors,node_sharing_alerts toneRose
```

## Components

### Android runtime

- **Android OS**: runtime
- [App manifest](https://github.com/ayito/popis-alerta/blob/main/app/src/main/AndroidManifest.xml): Android entry · `app/src/main/AndroidManifest.xml`
- [Main activity](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/MainActivity.kt): Compose host · `app/src/main/java/org/popisalerta/app/MainActivity.kt`

### Compose UI

- [Navigation](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/Navigation.kt): route controller · `app/src/main/java/org/popisalerta/app/Navigation.kt`
- [Navigation keys](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/NavigationKeys.kt): route definitions · `app/src/main/java/org/popisalerta/app/NavigationKeys.kt`
- [App theme](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/theme/Theme.kt): Compose theme · `app/src/main/java/org/popisalerta/app/theme/Theme.kt`
- [Main screen](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/ui/main/MainScreen.kt): Compose screen · `app/src/main/java/org/popisalerta/app/ui/main/MainScreen.kt`
- [Main screen ViewModel](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/ui/main/MainScreenViewModel.kt): UI state · `app/src/main/java/org/popisalerta/app/ui/main/MainScreenViewModel.kt`

### Local data

- [App access logger](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/AppAccessLogger.kt): event entry point · Intended insertion point for access-event producers. · `app/src/main/java/org/popisalerta/app/AppAccessLogger.kt`
- [Repository provider](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/AccessRepositoryProvider.kt): dependency provider · `app/src/main/java/org/popisalerta/app/data/AccessRepositoryProvider.kt`
- [Data repository](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/DataRepository.kt): persistence abstraction · `app/src/main/java/org/popisalerta/app/data/DataRepository.kt`
- [Access DAO](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/local/AccessDao.kt): Room access boundary · `app/src/main/java/org/popisalerta/app/data/local/AccessDao.kt`
- [Access database](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/local/AccessDatabase.kt): Room database · `app/src/main/java/org/popisalerta/app/data/local/AccessDatabase.kt`
- [Access entity](https://github.com/ayito/popis-alerta/blob/main/app/src/main/java/org/popisalerta/app/data/local/AccessEntity.kt): storage model · `app/src/main/java/org/popisalerta/app/data/local/AccessEntity.kt`

### Future integrations

Planned boundaries without current implementation.

- **Native sensor input**: planned producer · Light, motion, and experimental audio detection are not implemented.
- **Sharing and alerts**: planned outputs · Report sharing and alerts are not implemented.

## Connections

- Android OS → App manifest: launches
- App manifest → Main activity: declares
- Main activity → App theme: applies
- Main activity → Navigation: hosts
- Navigation → Navigation keys: uses
- Navigation → Main screen: routes to
- Main screen → Main screen ViewModel: renders state and actions
- Main screen ViewModel → Repository provider: obtains repository
- Repository provider → Data repository: supplies
- App access logger → Data repository: records events
- Data repository → Access DAO: persists and reads
- Access DAO → Access database: accesses
- Access database → Access entity: stores
- Native sensor input → App access logger: future access events
- Data repository → Sharing and alerts: future persisted records
