How wicked-bunny/e-commercetelegrambot works
E-commerceBot is a Telegram shop: customers browse categories and product details, then initiate purchases through the bot; Stripe webhook handling completes successful payments, updates stock, and notifies the customer. The runtime is organized around aiogram handlers and a repository/unit-of-work persistence layer backed by SQLite/SQLAlchemy. The graph includes the documented catalog, ordering, and payment capabilities. Some handler and payment-service internals were not excerpted, so uncertain relationships are omitted or marked dashed.
Main entry points: sql_alchemy_unit_of_work.py Unit of work · main.py App runtime · stripe_webhook.py Stripe webhook · сatalog.py Catalog browsing
Components 22
Telegram bot
- App runtime
main.py - Router registration
handlers/__init__.py - Session middleware
middlewares/session.py - Start and profile
handlers/start.py
Shopping flow
- Catalog browsing
handlers/сatalog.py - Category browsing
handlers/categories.py - Purchase handler
handlers/buy.py - Order handling
handlers/orders.py - Shop keyboards
Keyboards/inline_category_kb.py - Callback data
callbacks.py
Payment processing
- Checkout service
services/stripe_service.py - Stripe webhook
api/stripe_webhook.py
Persistence
- Unit of work
repositories/implementations/sql_alchemy_unit_of_work.py - SQLAlchemy repositories
repositories/implementations/sql_alchemy_repo.py - Item repository
repositories/implementations/sql_alchemy_item_repo.py - User repository
repositories/implementations/sql_alchemy_user_repo.py - Database sessions
database/connection.py - Product model
database/models/items.py - Category model
database/models/category.py - User model
database/models/user.py
Other components
- Customer
- Stripe
Connections 25
- Customer → App runtime: uses bot
- App runtime → Router registration: registers
main.py - App runtime → Session middleware: registers
main.py - App runtime → Database sessions: initializes
main.py - App runtime → Stripe webhook: configures route
main.py - Router registration → Start and profile: registers
handlers/__init__.py - Customer → Catalog browsing: browses
- Customer → Purchase handler: orders
- Catalog browsing → Shop keyboards: uses
handlers/сatalog.py - Category browsing → Shop keyboards: uses
handlers/categories.py - Catalog browsing → Callback data: uses
handlers/сatalog.py - Category browsing → Callback data: uses
handlers/categories.py - Purchase handler → Checkout service: calls
handlers/buy.py - Purchase handler → Unit of work: uses
handlers/buy.py - Stripe → Stripe webhook: sends events
- Stripe webhook → Unit of work: updates stock
api/stripe_webhook.py - Stripe webhook → Customer: sends notification
api/stripe_webhook.py - Session middleware → Unit of work: creates sessions
middlewares/session.py - Unit of work → Item repository: constructs
repositories/implementations/sql_alchemy_unit_of_work.py - Unit of work → SQLAlchemy repositories: constructs
repositories/implementations/sql_alchemy_unit_of_work.py - Unit of work → User repository: constructs
repositories/implementations/sql_alchemy_unit_of_work.py - Unit of work → Database sessions: opens session
repositories/implementations/sql_alchemy_unit_of_work.py - Item repository → Product model: queries
repositories/implementations/sql_alchemy_item_repo.py - User repository → User model: queries
repositories/implementations/sql_alchemy_user_repo.py - SQLAlchemy repositories → Category model: queries