How zagart47/tasktrackerbot works
Purpose and execution
TaskTrackerBot is a Go Telegram bot that captures a user’s prior group-chat message as a task and sends that user a private reminder after a requested interval. The process starts at cmd/tasktrackerbot/main.go, which assembles configuration, migrations, storage, use cases, and bot transport.
Transport and command boundary
internal/transport/bot.go owns Telegram bot integration and update processing. internal/transport/handler/handler.go and internal/transport/handler/tools.go interpret incoming messages/commands, including the ctrl <duration> workflow. The transport layer should only translate Telegram updates into application operations; Telegram is the external boundary.
Application use cases
internal/usecase/usecase.go defines application-level dependencies/contracts, while internal/usecase/task.go coordinates task capture, persistence, and reminder behavior. This layer enforces the workflow: retain relevant chat-message context, associate it with the requesting user, parse/control the reminder deadline, and trigger task operations without depending directly on Telegram or SQL details.
Domain and service layer
internal/entity/task.go contains the core task representation. internal/service/service.go and internal/service/task.go implement domain-oriented task operations used by use cases. This separates reminder/task rules from delivery and persistence mechanisms.
Persistence and cache
internal/storage/storage.go defines storage-facing abstractions. PostgreSQL is the durable task store, implemented by internal/storage/postgresql/postgresql.go and internal/storage/postgresql/task.go, with schema creation in internal/storage/postgresql/migrations/000001_tasks.up.sql. internal/storage/cache/memcache.go provides an in-memory/cache-oriented storage component, likely supporting transient message/task context; despite the README naming Redis, the repository path identifies this implementation as memcache.
Reminder scheduling
pkg/remind/reminder.go is the reminder mechanism invoked around stored task deadlines. It forms the time-based boundary between task creation and later private Telegram notification; use cases/services provide task data, while transport delivers the notification.
Runtime, configuration, and deployment
config/config.go loads application settings, with defaults/sample values in config/_config.yaml; the bot token is required for Telegram access. pkg/migration/migration.go applies database migrations at startup or deployment. Dockerfile and docker-compose.yml define the containerized runtime, with PostgreSQL and cache infrastructure expected alongside the Go service.
Main entry points: main.go Application bootstrap · usecase/task.go Task workflow · service/task.go Task operations · bot.go Bot update processor
Components 20
Runtime
- Container runtime · Runs the bot with PostgreSQL and cache infrastructure.
Dockerfile - Compose stack
docker-compose.yml - Application bootstrap · Assembles configuration, migrations, storage, use cases, and bot transport.
cmd/tasktrackerbot/main.go - Configuration · Loads bot and application settings.
config/config.go - Migration runner · Applies database migrations during startup or deployment.
pkg/migration/migration.go
Telegram transport
- Telegram API · Receives group updates and sends private reminders.
- Bot update processor · Owns Telegram integration and update processing.
internal/transport/bot.go - Command handler · Interprets messages and the ctrl duration workflow.
internal/transport/handler/handler.go - Handler tools
internal/transport/handler/tools.go
Application
- Use case contracts · Defines application dependencies and contracts.
internal/usecase/usecase.go - Task workflow · Captures prior chat context, associates a user, and controls reminder deadlines.
internal/usecase/task.go - Task · Core task representation.
internal/entity/task.go - Task operations · Applies domain-oriented task and reminder rules.
internal/service/task.go - Service contracts
internal/service/service.go - Reminder scheduler · Bridges stored deadlines to later private notification.
pkg/remind/reminder.go
Persistence
- Storage contracts · Defines storage-facing abstractions.
internal/storage/storage.go - PostgreSQL task store · Durable task persistence implementation.
internal/storage/postgresql/task.go - PostgreSQL connection
internal/storage/postgresql/postgresql.go - Tasks schema
internal/storage/postgresql/migrations/000001_tasks.up.sql - Message context cache · In-memory cache-oriented storage for transient context.
internal/storage/cache/memcache.go
Connections 23
- Compose stack → Container runtime: runs
- Container runtime → Application bootstrap: starts
- Application bootstrap → Configuration: loads
- Application bootstrap → Migration runner: runs
- Migration runner → Tasks schema: applies
- Application bootstrap → Bot update processor: wires
- Application bootstrap → Task workflow: constructs
- Application bootstrap → PostgreSQL connection: connects
- Bot update processor → Telegram API: receives updates / sends messages
- Bot update processor → Command handler: dispatches
- Command handler → Handler tools: uses
- Command handler → Task workflow: invokes
- Task workflow → Use case contracts: depends on
- Task workflow → Task: creates and manages
- Task workflow → Task operations: coordinates
- Task operations → Service contracts: implements
- Task operations → Storage contracts: persists through
- Storage contracts → PostgreSQL task store: implemented by
- Storage contracts → Message context cache: implemented by
- PostgreSQL task store → PostgreSQL connection: uses connection
- PostgreSQL task store → Tasks schema: stores tasks in
- Task operations → Reminder scheduler: schedules deadlines
- Reminder scheduler → Bot update processor: triggers private notification