# lingion/sleepy architecture

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

- Interactive diagram: https://gitdiagram.com/lingion/sleepy
- Repository: https://github.com/lingion/sleepy

## Overview

Sleepy is an offline-first Android timetable app. The main workflow is to open a timetable view, inspect courses for the selected week, and manage timetable data; users can also import through a school system or file/text preview before committing, then export or display schedules in widgets. The graph includes timetable persistence, import/export, settings, widgets, and reminders as distinct product capabilities. Unsampled subsystem links are omitted or marked unverified; relationships shown are supported by the README or indexed source references.

Main entry points: [`app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt`](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt) (Schedule repository), [`app/src/main/java/com/lingion/sleepy/data/AppDatabase.kt`](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/AppDatabase.kt) (Room database), [`app/src/main/java/com/lingion/sleepy/ui/screen/imports/ImportSheet.kt`](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/imports/ImportSheet.kt) (Import preview), [`app/src/main/java/com/lingion/sleepy/MainActivity.kt`](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/MainActivity.kt) (App entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and schedules"]
  node_activity["App entry<br/>[MainActivity.kt]"]
  node_navigation["Navigation<br/>[SleepyNavHost.kt]"]
  node_schedule["Schedule views"]
  node_course_edit["Course editing<br/>[AddCourseScreen.kt]"]
  node_management["Timetable management<br/>[ManagementPage.kt]"]
  node_dialog_actions["Dialog actions"]
end

subgraph group_import["Import and export"]
  node_import_ui["Import preview<br/>[ImportSheet.kt]"]
  node_jw_login["School login"]
  node_jw_parsers["School parsers"]
  node_schedule_parser["Format parsers<br/>[ScheduleParser.kt]"]
  node_exporter["Schedule export"]
end

subgraph group_data["Schedule data"]
  node_repository["Schedule repository"]
  node_database[("Room database<br/>[AppDatabase.kt]")]
  node_course_model["Course records<br/>[CourseEntity.kt]"]
  node_timetable_model["Timetable records<br/>[TimeTableEntity.kt]"]
  node_period_model["Period tables"]
  node_undo["Undo and redo<br/>[UndoManager.kt]"]
  node_time_utils["Period calculations<br/>[TimeTableUtils.kt]"]
end

subgraph group_widgets["Widgets and reminders"]
  node_widget_updater["Widget updates<br/>[WidgetUpdater.kt]"]
  node_widget_views["Schedule widgets<br/>[TodayWidget.kt]"]
  node_reminder_scheduler["Course reminders"]
  node_live_card["Live course card"]
end

subgraph group_preferences["Settings and calendar"]
  node_prefs[("App preferences<br/>[AppPrefs.kt]")]
  node_calendar["System calendar"]
end

node_user(("Student"))
node_calendar_service(("Android calendar"))
node_school_system(("School system"))
node_device_user(("Device user"))

node_user -->|"opens"| node_activity
node_activity -->|"hosts"| node_navigation
node_navigation -.->|"routes"| node_schedule
node_navigation -->|"routes"| node_management
node_management -->|"opens import"| node_import_ui
node_management -->|"opens editor"| node_course_edit
node_jw_login -->|"requests schedule"| node_school_system
node_jw_login -.->|"parses response"| node_jw_parsers
node_import_ui -->|"parses pasted data"| node_schedule_parser
node_import_ui -.->|"commits confirmed import"| node_repository
node_import_ui -->|"starts school import"| node_jw_login
node_exporter -->|"shares export"| node_device_user
node_schedule -->|"observes schedules"| node_repository
node_repository -->|"reads and writes"| node_database
node_database -->|"stores"| node_course_model
node_database -->|"stores"| node_timetable_model
node_database -->|"stores"| node_period_model
node_repository -->|"captures edits"| node_undo
node_schedule -->|"resolves periods"| node_time_utils
node_repository -->|"notifies changes"| node_widget_updater
node_widget_updater -.->|"refreshes"| node_widget_views
node_repository -->|"reschedules reminders"| node_reminder_scheduler
node_reminder_scheduler -->|"starts service"| node_live_card
node_activity -.->|"reads settings"| node_prefs
node_calendar -.->|"imports and exports events"| node_calendar_service
node_calendar -->|"records imports"| node_database
node_dialog_actions -.->|"confirms actions"| node_user

click node_activity "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/MainActivity.kt"
click node_navigation "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/nav/SleepyNavHost.kt"
click node_schedule "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/schedule/ScheduleViewModel.kt"
click node_course_edit "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/edit/AddCourseScreen.kt"
click node_management "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/manage/ManagementPage.kt"
click node_import_ui "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/imports/ImportSheet.kt"
click node_jw_login "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/imports/JwWebViewLoginScreen.kt"
click node_jw_parsers "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/jw/JwParserRegistry.kt"
click node_schedule_parser "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/parser/ScheduleParser.kt"
click node_exporter "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/parser/ScheduleExporter.kt"
click node_repository "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt"
click node_database "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/AppDatabase.kt"
click node_course_model "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/entity/CourseEntity.kt"
click node_timetable_model "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/entity/TimeTableEntity.kt"
click node_period_model "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/entity/PeriodTableEntity.kt"
click node_undo "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/undo/UndoManager.kt"
click node_time_utils "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/util/TimeTableUtils.kt"
click node_widget_updater "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/widget/WidgetUpdater.kt"
click node_widget_views "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/widget/TodayWidget.kt"
click node_reminder_scheduler "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/widget/notification/CourseNotificationScheduler.kt"
click node_live_card "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/widget/notification/FluidCloudService.kt"
click node_prefs "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/util/AppPrefs.kt"
click node_calendar "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/calendar/SystemCalendarManager.kt"
click node_dialog_actions "https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/component/DialogActionButtons.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_activity,node_navigation,node_schedule,node_course_edit,node_management,node_dialog_actions,node_device_user toneBlue
class node_import_ui,node_jw_login,node_jw_parsers,node_schedule_parser,node_exporter toneAmber
class node_repository,node_database,node_course_model,node_timetable_model,node_period_model,node_undo,node_time_utils toneMint
class node_widget_updater,node_widget_views,node_reminder_scheduler,node_live_card toneRose
class node_prefs,node_calendar,node_user,node_calendar_service,node_school_system toneIndigo
```

## Components

### App and schedules

- [App entry](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/MainActivity.kt): `app/src/main/java/com/lingion/sleepy/MainActivity.kt`
- [Navigation](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/nav/SleepyNavHost.kt): `app/src/main/java/com/lingion/sleepy/ui/nav/SleepyNavHost.kt`
- [Schedule views](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/schedule/ScheduleViewModel.kt): `app/src/main/java/com/lingion/sleepy/ui/screen/schedule/ScheduleViewModel.kt`
- [Course editing](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/edit/AddCourseScreen.kt): `app/src/main/java/com/lingion/sleepy/ui/screen/edit/AddCourseScreen.kt`
- [Timetable management](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/manage/ManagementPage.kt): `app/src/main/java/com/lingion/sleepy/ui/screen/manage/ManagementPage.kt`
- [Dialog actions](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/component/DialogActionButtons.kt): `app/src/main/java/com/lingion/sleepy/ui/component/DialogActionButtons.kt`

### Import and export

- [Import preview](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/imports/ImportSheet.kt): `app/src/main/java/com/lingion/sleepy/ui/screen/imports/ImportSheet.kt`
- [School login](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/ui/screen/imports/JwWebViewLoginScreen.kt): `app/src/main/java/com/lingion/sleepy/ui/screen/imports/JwWebViewLoginScreen.kt`
- [School parsers](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/jw/JwParserRegistry.kt): `app/src/main/java/com/lingion/sleepy/data/jw/JwParserRegistry.kt`
- [Format parsers](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/parser/ScheduleParser.kt): `app/src/main/java/com/lingion/sleepy/data/parser/ScheduleParser.kt`
- [Schedule export](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/parser/ScheduleExporter.kt): `app/src/main/java/com/lingion/sleepy/data/parser/ScheduleExporter.kt`

### Schedule data

- [Schedule repository](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt): `app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt`
- [Room database](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/AppDatabase.kt): `app/src/main/java/com/lingion/sleepy/data/AppDatabase.kt`
- [Course records](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/entity/CourseEntity.kt): `app/src/main/java/com/lingion/sleepy/data/entity/CourseEntity.kt`
- [Timetable records](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/entity/TimeTableEntity.kt): `app/src/main/java/com/lingion/sleepy/data/entity/TimeTableEntity.kt`
- [Period tables](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/entity/PeriodTableEntity.kt): `app/src/main/java/com/lingion/sleepy/data/entity/PeriodTableEntity.kt`
- [Undo and redo](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/undo/UndoManager.kt): `app/src/main/java/com/lingion/sleepy/data/undo/UndoManager.kt`
- [Period calculations](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/util/TimeTableUtils.kt): `app/src/main/java/com/lingion/sleepy/util/TimeTableUtils.kt`

### Widgets and reminders

- [Widget updates](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/widget/WidgetUpdater.kt): `app/src/main/java/com/lingion/sleepy/widget/WidgetUpdater.kt`
- [Schedule widgets](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/widget/TodayWidget.kt): `app/src/main/java/com/lingion/sleepy/widget/TodayWidget.kt`
- [Course reminders](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/widget/notification/CourseNotificationScheduler.kt): `app/src/main/java/com/lingion/sleepy/widget/notification/CourseNotificationScheduler.kt`
- [Live course card](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/widget/notification/FluidCloudService.kt): `app/src/main/java/com/lingion/sleepy/widget/notification/FluidCloudService.kt`

### Settings and calendar

- [App preferences](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/util/AppPrefs.kt): `app/src/main/java/com/lingion/sleepy/util/AppPrefs.kt`
- [System calendar](https://github.com/lingion/sleepy/blob/main/app/src/main/java/com/lingion/sleepy/data/calendar/SystemCalendarManager.kt): `app/src/main/java/com/lingion/sleepy/data/calendar/SystemCalendarManager.kt`

### Other components

- **Student**
- **Android calendar**
- **School system**
- **Device user**

## Connections

- Student → App entry: opens (evidence: `README.md`)
- App entry → Navigation: hosts (evidence: `app/src/main/java/com/lingion/sleepy/MainActivity.kt`)
- Navigation → Schedule views: routes
- Navigation → Timetable management: routes (evidence: `app/src/main/java/com/lingion/sleepy/MainActivity.kt`)
- Timetable management → Import preview: opens import
- Timetable management → Course editing: opens editor (evidence: `app/src/main/java/com/lingion/sleepy/MainActivity.kt`)
- School login → School system: requests schedule (evidence: `README.md`)
- School login → School parsers: parses response
- Import preview → Format parsers: parses pasted data (evidence: `README.md`)
- Import preview → Schedule repository: commits confirmed import
- Import preview → School login: starts school import (evidence: `README.md`)
- Schedule export → Device user: shares export (evidence: `README.md`)
- Schedule views → Schedule repository: observes schedules (evidence: `app/src/main/java/com/lingion/sleepy/ui/screen/schedule/ScheduleViewModel.kt`)
- Schedule repository → Room database: reads and writes (evidence: `app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt`)
- Room database → Course records: stores (evidence: `app/src/main/java/com/lingion/sleepy/data/AppDatabase.kt`)
- Room database → Timetable records: stores (evidence: `app/src/main/java/com/lingion/sleepy/data/AppDatabase.kt`)
- Room database → Period tables: stores (evidence: `app/src/main/java/com/lingion/sleepy/data/AppDatabase.kt`)
- Schedule repository → Undo and redo: captures edits (evidence: `app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt`)
- Schedule views → Period calculations: resolves periods (evidence: `app/src/main/java/com/lingion/sleepy/ui/screen/schedule/ScheduleViewModel.kt`)
- Schedule repository → Widget updates: notifies changes (evidence: `app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt`)
- Widget updates → Schedule widgets: refreshes
- Schedule repository → Course reminders: reschedules reminders (evidence: `app/src/main/java/com/lingion/sleepy/data/repository/ScheduleRepository.kt`)
- Course reminders → Live course card: starts service (evidence: `app/src/main/java/com/lingion/sleepy/widget/notification/FluidCloudService.kt`)
- App entry → App preferences: reads settings (evidence: `app/src/main/java/com/lingion/sleepy/MainActivity.kt`)
- System calendar → Android calendar: imports and exports events
- System calendar → Room database: records imports (evidence: `app/src/main/java/com/lingion/sleepy/data/calendar/SystemCalendarManager.kt`)
- Dialog actions → Student: confirms actions
