How khachung/goprogramming works
Project Type and Purpose
• This is a monolithic Go server (“gobot”) that implements a Facebook Messenger chatbot.
• Its sole responsibility is to receive Messenger webhooks, run bot logic, and reply via the Facebook Graph API.
File Structure
• Root
• README.md – project description
• gobot/ (Go sources)
• main.go – entry point, HTTP server setup
• bot.go – core bot logic (message routing, business rules)
• message.go – data structures for incoming/outgoing Messenger payloads
README
• Confirms: “gobot” is a Facebook Messenger chatbot monolith.
• No database layer or separate services mentioned; everything lives in one process.
Main Components
a. External Service
– Facebook Messenger Platform (webhook provider & Graph API endpoint)
b. Gobot Server
– HTTP Webhook Listener (net/http)
– Request Parser (message.go types, JSON unmarshal)
– Bot Core Logic (bot.go)
– Response Generator (JSON marshal of reply messages)
– Facebook Graph API Client (outgoing HTTP POST)
c. Configuration & Logging
– Environment/config module (page tokens, verify tokens)
– Logging subsystem (console or file)
d. (Optional) Persistence
– If extended later, e.g., a Redis or SQL component for state
Relationships & Data Flow
• Listener → Request Parser → Bot Logic
• Bot Logic → Response Generator → Graph API Client → Facebook
• Configuration module feeds tokens to Listener & API Client
• Logging captures each step (incoming request, processing, outgoing reply)
Architectural Patterns & Principles
• Monolith with clear module separation
• Single responsibility per Go file: HTTP handling, data modeling, business logic
• Dependency inversion: core logic decoupled from HTTP framework
Technologies & Libraries
• Go standard library: net/http, encoding/json
• Facebook Graph API over HTTPS
• Environment variables for secrets