How synapsefi/demo.slackbot works
Project Type and Purpose
• demo.slackbot is a full-stack Slack integration proof-of-concept that combines a lightweight web server (for user registration) with a Slack bot event loop.
• It leverages Synapse’s API for automated savings operations (see disclaimer: not production-grade).
File Structure Analysis
• Top-level:
– Dockerfile, config directory (app.ini, nginx.conf, supervisor.conf), requirements.txt
– app/ folder: the main Python code, static assets, HTML templates
– samples.md (Slack message format examples)
• app/ contains:
– app.py: HTTP server entry point (likely Flask) serving templates/static
– slack_event_loop.py: long-running process subscribing to Slack events
– bot.py + commands.py: core Slack command handlers
– db.py, models.py, schema.sql: local database layer and schema definitions
– core/: wrapper around Synapse API calls and business logic
– templates/register.html + static/register.{css,js}: user registration front end
Architecture Insights from README
• Two runtime modes:
– Non-Docker: run app.py (web) and slack_event_loop.py (bot) separately
– Docker: container bundles web server behind Nginx + Supervisor to manage both processes
• No mention of message queue: the event loop directly invokes command handlers and core logic.
Main Components
a. External Services
• Slack Events API / Webhooks – sends user commands and events
• Synapse API – external banking/savings service
b. Internal Services
• HTTP Server (app.py + Flask framework)
• Slack Event Loop (slack_event_loop.py)
• Bot Logic Layer (commands.py, bot.py)
• Core Business Logic (app/core/)
• Persistence Layer (db.py, models.py, local SQL database)
• Front-end Assets (templates + static files)
c. Infrastructure Components (Docker mode)
• Nginx reverse proxy (nginx.conf)
• Supervisor process manager (supervisor.conf)
• Docker container
Component Relationships and Data Flows
• User → Slack UI → Slack Events API → Slack Event Loop → Bot Logic → Core Logic → Synapse API → Core Logic → Persistence Layer → Slack Event Loop → Slack UI (responses)
• User Web Browser → HTTP Server → Templates/Static → HTTP Server → Database (user registrations)
• Supervisor manages both the HTTP Server and Slack Event Loop processes; Nginx routes incoming HTTP traffic on port 80 to the HTTP Server.
Architectural Patterns & Principles
• Separation of Concerns:
– Web interface vs. bot event loop
– API integration (core/) vs. transport layer (bot.py/commands.py)
• Modular services: easy to swap Slack or Synapse implementations
• Containerization for reproducible deployments