# pipipopy0/xaxaton architecture

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

- Interactive diagram: https://gitdiagram.com/pipipopy0/xaxaton
- Repository: https://github.com/pipipopy0/xaxaton

## Overview

Planlit is a conversational calendar planner: a user messages the MAX bot, which interprets a request, creates or changes an event, stores it, and later sends a reminder. The bot also supports calendar connections, settings and subscriptions; a separate Flask webhook handles YooKassa payment notifications. The README documents Duckling, AI and PostgreSQL integrations, while sampled source confirms key bot, event, calendar and payment calls. Some feature links rely on README or SOURCE INDEX references because their implementations were not fully excerpted.

Main entry points: [`handlers/router.py`](https://github.com/pipipopy0/xaxaton/blob/main/handlers/router.py) (Message routing), [`main.py`](https://github.com/pipipopy0/xaxaton/blob/main/main.py) (Bot startup), [`handlers/callback.py`](https://github.com/pipipopy0/xaxaton/blob/main/handlers/callback.py) (Menus and callbacks), [`services/event_service.py`](https://github.com/pipipopy0/xaxaton/blob/main/services/event_service.py) (Event lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Bot experience"]
  node_entry["Bot startup<br/>[main.py]"]
  node_routing["Message routing<br/>[router.py]"]
  node_callbacks["Menus and callbacks<br/>[callback.py]"]
  node_commands["Bot commands<br/>[commands.py]"]
  node_keyboards["Interactive keyboards<br/>[keyboards.py]"]
  node_texts["Localized responses<br/>[TEXT.py]"]
  node_form_state["Calendar form state<br/>[calendar_fsm.py]"]
end

subgraph group_planning["Event planning"]
  node_ai["Intent and event AI<br/>[ai_service.py]"]
  node_time_parser["Date-time parsing"]
  node_event_logic["Event lifecycle<br/>[event_service.py]"]
  node_reminders["Event reminders<br/>[remind_user.py]"]
  node_prompt_templates["AI prompt templates"]
end

subgraph group_calendar["Calendar sync"]
  node_calendar_dispatch["Calendar dispatch"]
  node_caldav["Apple CalDAV<br/>[caldav_service.py]"]
  node_ical["iCalendar builder<br/>[ical_builder.py]"]
  node_google_cal["Google Calendar API"]
end

subgraph group_billing["Subscriptions"]
  node_payments["Payment lifecycle<br/>[payment_service.py]"]
  node_webhook["Payment webhook<br/>[flask_service.py]"]
  node_renewal_worker["Renewal worker"]
end

subgraph group_platform["Storage and operations"]
  node_db_access["Database access<br/>[database.py]"]
  node_db_setup["Database schema setup<br/>[work_with_dp.py]"]
  node_access["Plan access rules<br/>[access.py]"]
  node_monitor["Service monitor<br/>[monitor.py]"]
  node_site["Public website<br/>[index.html]"]
end

node_user(("User"))
node_max_api{{"MAX Bot API"}}
node_google_service{{"Google Calendar"}}
node_apple_service{{"Apple Calendar"}}
node_postgres[("PostgreSQL")]
node_yookassa{{"YooKassa"}}

node_user -->|"sends message"| node_max_api
node_max_api -->|"delivers updates"| node_entry
node_entry -->|"registers router"| node_routing
node_entry -->|"registers router"| node_callbacks
node_entry -->|"registers router"| node_commands
node_entry -->|"initializes schema"| node_db_setup
node_entry -->|"schedules"| node_renewal_worker
node_entry -->|"starts task"| node_reminders
node_routing -->|"requests interpretation"| node_ai
node_routing -->|"dispatches event action"| node_event_logic
node_routing -->|"checks access"| node_access
node_routing -->|"uses state"| node_form_state
node_routing -->|"connects calendars"| node_calendar_dispatch
node_routing -->|"gets response text"| node_texts
node_routing -->|"builds menus"| node_keyboards
node_callbacks -->|"uses state"| node_form_state
node_callbacks -->|"starts payment"| node_payments
node_callbacks -->|"checks access"| node_access
node_callbacks -->|"uses calendar OAuth"| node_google_cal
node_callbacks -->|"builds menus"| node_keyboards
node_commands -->|"gets response text"| node_texts
node_ai -.->|"uses prompts"| node_prompt_templates
node_event_logic -->|"parses event time"| node_time_parser
node_event_logic -->|"reads and writes events"| node_db_access
node_event_logic -->|"syncs event changes"| node_calendar_dispatch
node_event_logic -->|"syncs event changes"| node_google_cal
node_reminders -->|"reads reminder data"| node_db_access
node_calendar_dispatch -->|"dispatches CalDAV"| node_caldav
node_calendar_dispatch -->|"dispatches Google"| node_google_cal
node_caldav -->|"builds calendar data"| node_ical
node_caldav -->|"syncs events"| node_apple_service
node_google_cal -->|"calls calendar API"| node_google_service
node_db_setup -->|"creates database"| node_db_access
node_db_access -->|"queries"| node_postgres
node_payments -->|"records payment state"| node_db_access
node_payments -->|"creates payment"| node_yookassa
node_yookassa -->|"sends payment event"| node_webhook
node_webhook -->|"handles webhook"| node_payments
node_renewal_worker -->|"renews subscriptions"| node_payments
node_monitor -.->|"reports status"| node_user

click node_entry "https://github.com/pipipopy0/xaxaton/blob/main/main.py"
click node_routing "https://github.com/pipipopy0/xaxaton/blob/main/handlers/router.py"
click node_callbacks "https://github.com/pipipopy0/xaxaton/blob/main/handlers/callback.py"
click node_commands "https://github.com/pipipopy0/xaxaton/blob/main/handlers/commands.py"
click node_keyboards "https://github.com/pipipopy0/xaxaton/blob/main/handlers/keyboards.py"
click node_texts "https://github.com/pipipopy0/xaxaton/blob/main/handlers/answer_texts/TEXT.py"
click node_form_state "https://github.com/pipipopy0/xaxaton/blob/main/forms/calendar_fsm.py"
click node_ai "https://github.com/pipipopy0/xaxaton/blob/main/services/ai_service.py"
click node_time_parser "https://github.com/pipipopy0/xaxaton/blob/main/services/get_correct_time.py"
click node_event_logic "https://github.com/pipipopy0/xaxaton/blob/main/services/event_service.py"
click node_reminders "https://github.com/pipipopy0/xaxaton/blob/main/services/remind_user.py"
click node_prompt_templates "https://github.com/pipipopy0/xaxaton/tree/main/prompts"
click node_calendar_dispatch "https://github.com/pipipopy0/xaxaton/blob/main/services/calendars/calendar_service.py"
click node_caldav "https://github.com/pipipopy0/xaxaton/blob/main/services/calendars/caldav_service.py"
click node_ical "https://github.com/pipipopy0/xaxaton/blob/main/services/calendars/ical_builder.py"
click node_google_cal "https://github.com/pipipopy0/xaxaton/blob/main/services/google_calendar_service.py"
click node_db_access "https://github.com/pipipopy0/xaxaton/blob/main/services/database/database.py"
click node_db_setup "https://github.com/pipipopy0/xaxaton/blob/main/services/database/work_with_dp.py"
click node_access "https://github.com/pipipopy0/xaxaton/blob/main/services/access.py"
click node_payments "https://github.com/pipipopy0/xaxaton/blob/main/services/payment_service.py"
click node_webhook "https://github.com/pipipopy0/xaxaton/blob/main/services/flask_service.py"
click node_renewal_worker "https://github.com/pipipopy0/xaxaton/blob/main/services/recurrent_payment_worker.py"
click node_monitor "https://github.com/pipipopy0/xaxaton/blob/main/monitor/monitor.py"
click node_site "https://github.com/pipipopy0/xaxaton/blob/main/SITE/index.html"

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_entry,node_routing,node_callbacks,node_commands,node_keyboards,node_texts,node_form_state,node_user toneBlue
class node_ai,node_time_parser,node_event_logic,node_reminders,node_prompt_templates,node_postgres toneAmber
class node_calendar_dispatch,node_caldav,node_ical,node_google_cal,node_max_api toneMint
class node_payments,node_webhook,node_renewal_worker toneRose
class node_db_access,node_db_setup,node_access,node_monitor,node_site,node_google_service,node_apple_service,node_yookassa toneIndigo
```

## Components

### Bot experience

- [Bot startup](https://github.com/pipipopy0/xaxaton/blob/main/main.py): `main.py`
- [Message routing](https://github.com/pipipopy0/xaxaton/blob/main/handlers/router.py): `handlers/router.py`
- [Menus and callbacks](https://github.com/pipipopy0/xaxaton/blob/main/handlers/callback.py): `handlers/callback.py`
- [Bot commands](https://github.com/pipipopy0/xaxaton/blob/main/handlers/commands.py): `handlers/commands.py`
- [Interactive keyboards](https://github.com/pipipopy0/xaxaton/blob/main/handlers/keyboards.py): `handlers/keyboards.py`
- [Localized responses](https://github.com/pipipopy0/xaxaton/blob/main/handlers/answer_texts/TEXT.py): `handlers/answer_texts/TEXT.py`
- [Calendar form state](https://github.com/pipipopy0/xaxaton/blob/main/forms/calendar_fsm.py): `forms/calendar_fsm.py`

### Event planning

- [Intent and event AI](https://github.com/pipipopy0/xaxaton/blob/main/services/ai_service.py): `services/ai_service.py`
- [Date-time parsing](https://github.com/pipipopy0/xaxaton/blob/main/services/get_correct_time.py): `services/get_correct_time.py`
- [Event lifecycle](https://github.com/pipipopy0/xaxaton/blob/main/services/event_service.py): `services/event_service.py`
- [Event reminders](https://github.com/pipipopy0/xaxaton/blob/main/services/remind_user.py): `services/remind_user.py`
- [AI prompt templates](https://github.com/pipipopy0/xaxaton/tree/main/prompts): `prompts`

### Calendar sync

- [Calendar dispatch](https://github.com/pipipopy0/xaxaton/blob/main/services/calendars/calendar_service.py): `services/calendars/calendar_service.py`
- [Apple CalDAV](https://github.com/pipipopy0/xaxaton/blob/main/services/calendars/caldav_service.py): `services/calendars/caldav_service.py`
- [iCalendar builder](https://github.com/pipipopy0/xaxaton/blob/main/services/calendars/ical_builder.py): `services/calendars/ical_builder.py`
- [Google Calendar API](https://github.com/pipipopy0/xaxaton/blob/main/services/google_calendar_service.py): `services/google_calendar_service.py`

### Subscriptions

- [Payment lifecycle](https://github.com/pipipopy0/xaxaton/blob/main/services/payment_service.py): `services/payment_service.py`
- [Payment webhook](https://github.com/pipipopy0/xaxaton/blob/main/services/flask_service.py): `services/flask_service.py`
- [Renewal worker](https://github.com/pipipopy0/xaxaton/blob/main/services/recurrent_payment_worker.py): `services/recurrent_payment_worker.py`

### Storage and operations

- [Database access](https://github.com/pipipopy0/xaxaton/blob/main/services/database/database.py): `services/database/database.py`
- [Database schema setup](https://github.com/pipipopy0/xaxaton/blob/main/services/database/work_with_dp.py): `services/database/work_with_dp.py`
- [Plan access rules](https://github.com/pipipopy0/xaxaton/blob/main/services/access.py): `services/access.py`
- [Service monitor](https://github.com/pipipopy0/xaxaton/blob/main/monitor/monitor.py): `monitor/monitor.py`
- [Public website](https://github.com/pipipopy0/xaxaton/blob/main/SITE/index.html): `SITE/index.html`

### Other components

- **User**
- **MAX Bot API**
- **Google Calendar**
- **Apple Calendar**
- **PostgreSQL**
- **YooKassa**

## Connections

- User → MAX Bot API: sends message (evidence: `README.md`)
- MAX Bot API → Bot startup: delivers updates (evidence: `README.md`)
- Bot startup → Message routing: registers router (evidence: `main.py`)
- Bot startup → Menus and callbacks: registers router (evidence: `main.py`)
- Bot startup → Bot commands: registers router (evidence: `main.py`)
- Bot startup → Database schema setup: initializes schema (evidence: `main.py`)
- Bot startup → Renewal worker: schedules (evidence: `main.py`)
- Bot startup → Event reminders: starts task (evidence: `main.py`)
- Message routing → Intent and event AI: requests interpretation (evidence: `handlers/router.py`)
- Message routing → Event lifecycle: dispatches event action (evidence: `handlers/router.py`)
- Message routing → Plan access rules: checks access (evidence: `handlers/router.py`)
- Message routing → Calendar form state: uses state (evidence: `handlers/router.py`)
- Message routing → Calendar dispatch: connects calendars (evidence: `handlers/router.py`)
- Message routing → Localized responses: gets response text (evidence: `handlers/router.py`)
- Message routing → Interactive keyboards: builds menus (evidence: `handlers/router.py`)
- Menus and callbacks → Calendar form state: uses state (evidence: `handlers/callback.py`)
- Menus and callbacks → Payment lifecycle: starts payment (evidence: `handlers/callback.py`)
- Menus and callbacks → Plan access rules: checks access (evidence: `handlers/callback.py`)
- Menus and callbacks → Google Calendar API: uses calendar OAuth (evidence: `handlers/callback.py`)
- Menus and callbacks → Interactive keyboards: builds menus (evidence: `handlers/callback.py`)
- Bot commands → Localized responses: gets response text (evidence: `handlers/commands.py`)
- Intent and event AI → AI prompt templates: uses prompts
- Event lifecycle → Date-time parsing: parses event time (evidence: `services/event_service.py`)
- Event lifecycle → Database access: reads and writes events (evidence: `services/event_service.py`)
- Event lifecycle → Calendar dispatch: syncs event changes (evidence: `services/event_service.py`)
- Event lifecycle → Google Calendar API: syncs event changes (evidence: `services/event_service.py`)
- Event reminders → Database access: reads reminder data (evidence: `services/remind_user.py`)
- Calendar dispatch → Apple CalDAV: dispatches CalDAV (evidence: `services/calendars/calendar_service.py`)
- Calendar dispatch → Google Calendar API: dispatches Google (evidence: `services/event_service.py`)
- Apple CalDAV → iCalendar builder: builds calendar data (evidence: `services/calendars/caldav_service.py`)
- Apple CalDAV → Apple Calendar: syncs events (evidence: `README.md`)
- Google Calendar API → Google Calendar: calls calendar API (evidence: `services/google_calendar_service.py`)
- Database schema setup → Database access: creates database (evidence: `services/database/work_with_dp.py`)
- Database access → PostgreSQL: queries (evidence: `services/database/database.py`)
- Payment lifecycle → Database access: records payment state (evidence: `services/payment_service.py`)
- Payment lifecycle → YooKassa: creates payment (evidence: `services/payment_service.py`)
- YooKassa → Payment webhook: sends payment event (evidence: `README.md`)
- Payment webhook → Payment lifecycle: handles webhook (evidence: `services/flask_service.py`)
- Renewal worker → Payment lifecycle: renews subscriptions (evidence: `services/recurrent_payment_worker.py`)
- Service monitor → User: reports status
