API service is a dockerized Golang application that serves Guide Bot API and webhook for Telegram Bot API.
Required environment variables:
TELEGRAM_WEB_APP_URL
- URL to Guide UI serviceTELEGRAM_BOT_TOKEN
- Telegram Bot tokenTELEGRAM_PAYMENTS_TOKEN
- Telegram Payments tokenJWT_SECRET
- Secret to sign and verify JWT tokensDB_CONNECTION_STRING
- URL to DBS3_CONNECTION_STRING
- URL to S3
Optional environment variables:
CORS_ALLOWED_ORIGINS
- list of allowed origins that may access the resource
Service is built on three abstractions:
- Providers - isolate interaction with other systems or packages
- provider/auth - provides functionality for token-based authentication, implementations: JWT
- provider/blob - provides I/O operations on immutable binary objects, implementations: S3
- provider/bot - provides interaction with Bot API, implementations: Telegram API
- provider/db - provides interaction with a database, implementations: PostgreSQL
- provider/translation - provides strings translations, implementations: go-i18n
- Repositories - provide CRUD operations for data types, all interfaces are implemented as an aggregate repository object
- repository/object - implements CRUD operations for Object type
- repository/ticket - implements CRUD operations for Ticket type
- repository/config - implements CRUD operations for configuration variables
- Controllers - implement HTTP handlers with business logic, all handlers are implemented in compliance with JSend specification
- controller/bot - implements logic to handle Telegram Bot API updates
- controller/objects - implements logic to interact with Object type
- controller/tickets - implements logic to interact with Ticket type
All entities are constructed and injected in main and then HTTP handlers are served by Fiber.
API service can be started in database migration mode. In this case, it will apply migrations from the implemented DBProvider
and exit. To start the service in migration mode - specify --migrate
execution argument.