# m685319/space-events-bot architecture

> Architecture diagram of the GitHub repository m685319/space-events-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m685319/space-events-bot
- Repository: https://github.com/m685319/space-events-bot

## Overview

Space Events Bot is a Telegram interface for space information and daily APOD notifications. Users issue commands or use callbacks; command handling delegates to domain services, which fetch and format APOD, asteroid, launch, or news data for replies. APOD also supports date lookup and a scheduled subscriber broadcast, with subscriptions persisted to the filesystem. The README documents the layered command/action → service → client design; sampled source confirms APOD and asteroid service/client behavior and file-backed subscription persistence. Some command, routing, launch/news, and scheduler wiring is represented from documented capabilities and the tree rather than inspected source.

Main entry points: [`src/main/java/com/spacebot/bot/SpaceTelegramBot.java`](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/SpaceTelegramBot.java) (Bot adapter), [`src/main/java/com/spacebot/scheduler/ApodNotificationScheduler.java`](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/scheduler/ApodNotificationScheduler.java) (Daily APOD scheduler), [`src/main/java/com/spacebot/bot/command`](https://github.com/m685319/space-events-bot/tree/master/src/main/java/com/spacebot/bot/command) (Command handlers), [`src/main/java/com/spacebot/service/impl/ApodServiceImpl.java`](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/ApodServiceImpl.java) (APOD logic/cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telegram["Telegram Interface"]
  node_telegram["Bot adapter"]
  node_commands["Command handlers"]
  node_actions["Callback actions"]
  node_keyboards["Inline keyboards"]
  node_cooldown["Command cooldown"]
end

subgraph group_domain["Space Information"]
  node_apod_cmd["APOD commands<br/>[ApodCommand.java]"]
  node_asteroids_cmd["Asteroid command"]
  node_launches_cmd["Launch command"]
  node_news_cmd["News command<br/>[NewsCommand.java]"]
  node_apod_service["APOD logic/cache"]
  node_asteroids_service["Asteroid formatting"]
  node_launches_service["Launch service"]
  node_news_service["News service"]
end

subgraph group_integrations["External Data"]
  node_apod_client["APOD fetcher<br/>[ApodClient.java]"]
  node_asteroids_client["Asteroid fetcher"]
  node_launches_client["Launch fetcher"]
  node_news_client["News fetcher<br/>[NewsClient.java]"]
end

subgraph group_notifications["APOD Notifications"]
  node_apod_subscriptions["Subscription service"]
  node_subscriber_file[("Subscriber file")]
  node_scheduler["Daily APOD scheduler"]
end

node_user(("Telegram user"))
node_space_apis{{"Space data APIs"}}

node_user -->|"sends updates"| node_telegram
node_telegram -->|"routes commands"| node_commands
node_telegram -->|"routes callbacks"| node_actions
node_telegram -->|"checks cooldown"| node_cooldown
node_commands -->|"builds menus"| node_keyboards
node_apod_cmd -->|"requests APOD"| node_apod_service
node_asteroids_cmd -->|"requests asteroids"| node_asteroids_service
node_launches_cmd -->|"requests launches"| node_launches_service
node_news_cmd -->|"requests news"| node_news_service
node_apod_service -->|"fetches APOD"| node_apod_client
node_asteroids_service -->|"fetches objects"| node_asteroids_client
node_launches_service -->|"fetches launches"| node_launches_client
node_news_service -->|"fetches articles"| node_news_client
node_apod_client -->|"retrieves content"| node_space_apis
node_asteroids_client -->|"queries objects"| node_space_apis
node_launches_client -->|"queries launches"| node_space_apis
node_news_client -->|"retrieves news"| node_space_apis
node_commands -->|"manages subscriptions"| node_apod_subscriptions
node_scheduler -->|"loads subscribers"| node_apod_subscriptions
node_scheduler -->|"requests notification"| node_apod_service
node_apod_subscriptions -->|"reads and writes"| node_subscriber_file
node_scheduler -->|"sends notifications"| node_telegram

click node_telegram "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/SpaceTelegramBot.java"
click node_commands "https://github.com/m685319/space-events-bot/tree/master/src/main/java/com/spacebot/bot/command"
click node_actions "https://github.com/m685319/space-events-bot/tree/master/src/main/java/com/spacebot/bot/action"
click node_keyboards "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/ui/KeyboardFactory.java"
click node_cooldown "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/CommandCooldownServiceImpl.java"
click node_apod_cmd "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/command/ApodCommand.java"
click node_asteroids_cmd "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/command/AsteroidsCommand.java"
click node_launches_cmd "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/command/LaunchesCommand.java"
click node_news_cmd "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/command/NewsCommand.java"
click node_apod_service "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/ApodServiceImpl.java"
click node_asteroids_service "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/AsteroidsServiceImpl.java"
click node_launches_service "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/LaunchesServiceImpl.java"
click node_news_service "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/NewsServiceImpl.java"
click node_apod_client "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/client/ApodClient.java"
click node_asteroids_client "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/client/AsteroidsClient.java"
click node_launches_client "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/client/LaunchesClient.java"
click node_news_client "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/client/NewsClient.java"
click node_apod_subscriptions "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/FileBasedSubscriptionServiceImpl.java"
click node_scheduler "https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/scheduler/ApodNotificationScheduler.java"

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_telegram,node_commands,node_actions,node_keyboards,node_cooldown,node_user toneBlue
class node_apod_cmd,node_asteroids_cmd,node_launches_cmd,node_news_cmd,node_apod_service,node_asteroids_service,node_launches_service,node_news_service toneAmber
class node_apod_client,node_asteroids_client,node_launches_client,node_news_client,node_space_apis toneMint
class node_apod_subscriptions,node_subscriber_file,node_scheduler toneRose
```

## Components

### Telegram Interface

- [Bot adapter](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/SpaceTelegramBot.java): `src/main/java/com/spacebot/bot/SpaceTelegramBot.java`
- [Command handlers](https://github.com/m685319/space-events-bot/tree/master/src/main/java/com/spacebot/bot/command): `src/main/java/com/spacebot/bot/command`
- [Callback actions](https://github.com/m685319/space-events-bot/tree/master/src/main/java/com/spacebot/bot/action): `src/main/java/com/spacebot/bot/action`
- [Inline keyboards](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/ui/KeyboardFactory.java): `src/main/java/com/spacebot/bot/ui/KeyboardFactory.java`
- [Command cooldown](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/CommandCooldownServiceImpl.java): `src/main/java/com/spacebot/service/impl/CommandCooldownServiceImpl.java`

### Space Information

- [APOD commands](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/command/ApodCommand.java): `src/main/java/com/spacebot/bot/command/ApodCommand.java`
- [Asteroid command](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/command/AsteroidsCommand.java): `src/main/java/com/spacebot/bot/command/AsteroidsCommand.java`
- [Launch command](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/command/LaunchesCommand.java): `src/main/java/com/spacebot/bot/command/LaunchesCommand.java`
- [News command](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/bot/command/NewsCommand.java): `src/main/java/com/spacebot/bot/command/NewsCommand.java`
- [APOD logic/cache](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/ApodServiceImpl.java): `src/main/java/com/spacebot/service/impl/ApodServiceImpl.java`
- [Asteroid formatting](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/AsteroidsServiceImpl.java): `src/main/java/com/spacebot/service/impl/AsteroidsServiceImpl.java`
- [Launch service](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/LaunchesServiceImpl.java): `src/main/java/com/spacebot/service/impl/LaunchesServiceImpl.java`
- [News service](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/NewsServiceImpl.java): `src/main/java/com/spacebot/service/impl/NewsServiceImpl.java`

### External Data

- [APOD fetcher](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/client/ApodClient.java): `src/main/java/com/spacebot/client/ApodClient.java`
- [Asteroid fetcher](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/client/AsteroidsClient.java): `src/main/java/com/spacebot/client/AsteroidsClient.java`
- [Launch fetcher](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/client/LaunchesClient.java): `src/main/java/com/spacebot/client/LaunchesClient.java`
- [News fetcher](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/client/NewsClient.java): `src/main/java/com/spacebot/client/NewsClient.java`

### APOD Notifications

- [Subscription service](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/service/impl/FileBasedSubscriptionServiceImpl.java): `src/main/java/com/spacebot/service/impl/FileBasedSubscriptionServiceImpl.java`
- **Subscriber file**
- [Daily APOD scheduler](https://github.com/m685319/space-events-bot/blob/master/src/main/java/com/spacebot/scheduler/ApodNotificationScheduler.java): `src/main/java/com/spacebot/scheduler/ApodNotificationScheduler.java`

### Other components

- **Telegram user**
- **Space data APIs**

## Connections

- Telegram user → Bot adapter: sends updates
- Bot adapter → Command handlers: routes commands
- Bot adapter → Callback actions: routes callbacks
- Bot adapter → Command cooldown: checks cooldown
- Command handlers → Inline keyboards: builds menus
- APOD commands → APOD logic/cache: requests APOD
- Asteroid command → Asteroid formatting: requests asteroids
- Launch command → Launch service: requests launches
- News command → News service: requests news
- APOD logic/cache → APOD fetcher: fetches APOD
- Asteroid formatting → Asteroid fetcher: fetches objects
- Launch service → Launch fetcher: fetches launches
- News service → News fetcher: fetches articles
- APOD fetcher → Space data APIs: retrieves content
- Asteroid fetcher → Space data APIs: queries objects
- Launch fetcher → Space data APIs: queries launches
- News fetcher → Space data APIs: retrieves news
- Command handlers → Subscription service: manages subscriptions
- Daily APOD scheduler → Subscription service: loads subscribers
- Daily APOD scheduler → APOD logic/cache: requests notification
- Subscription service → Subscriber file: reads and writes
- Daily APOD scheduler → Bot adapter: sends notifications
