How hackclub/theseus works
Project type and purpose
• This is a monolithic, full-stack Ruby on Rails application that powers “hack club’s shiny new mail system.”
• It provides multiple interfaces:
• An authenticated admin UI (via Rails views/Administrate)
• A public web UI (including a PWA)
• REST JSON APIs for first-party clients (/api/v1/...)
• A public-facing API under /public/api/v1/...
• It also runs background ETL and integration jobs (Airtable, USPS, Zenventory, geocoding), generates PDFs via snail_mail, handles email delivery (ActionMailer), and supports real-time features (ActionCable).
File structure
• Top–level directories:
• app/controllers/... (namespaces: admin, api/v1, public, letter, warehouse, usps webhooks)
• app/models + app/services + app/jobs: classic MVC + service-layer + background jobs
• app/frontend (Vite/webpack‐style entrypoints, JS components, SCSS styles) & app/javascript (Stimulus controllers)
• config/ (Rails, database.yml, cable.yml, queue.yml, credentials, routes)
• bin/, Dockerfile, docker-compose-*.yml, .kamal/ (deployment hooks via Kamal), GoodJob initializer
• lib/snail_mail (PDF template engine)
• This reflects a layered architecture:
• Presentation layer (Rails views, JS)
• Application layer (controllers, services)
• Domain layer (models, policies, concerns)
• Infrastructure layer (database, job queue, mailer, external APIs)
Insights from README
• The README confirms the purpose: an open-source mail system with many moving parts and integrations.
• There’s a note that wiring up seeds, authentication, and Slack integration is pending, so flexible extensibility is key.
Main components & interactions (
a. Clients (browser, PWA service worker, third-party app)
b. Rails Application Server
• HTTP(S) endpoints → controllers (admin, public, API, webhooks)
• Background job producer → GoodJob (in-db queue)
• Real-time channel → ActionCable (websocket)
• Asset server → Vite build outputs, static public/
c. Database (PostgreSQL via ActiveRecord)
d. Background Workers (GoodJob threads/processes)
• Jobs call services:
• Airtable ETL, table_sync
• USPS API (iv_mtr, pricing, indicia), EasyPost
• GeocodingService (USPS facilities)
• Zenventory integration
• AIService (OpenAI)
• Jobs write results back to DB, enqueue further jobs, trigger mailers
e. Mailer Service (ActionMailer + SMTP or Sendgrid, configured in config/environments/*.rb)
f. SnailMail PDF Generator (lib/snail_mail)
g. External services (USPS, Airtable, Zenventory, Geocoding, OpenAI)
h. Storage (ActiveStorage: local or S3 per config/storage.yml)
Architectural patterns & principles
• MVC in Rails (controllers → models → views / JSON builders)
• Service-oriented helpers (app/services/…) for external API encapsulation
• Namespacing for versioned APIs (api/v1, public/api/v1)
• Background processing via GoodJob (job queue + worker pool)
• Concern-based code reuse (app/controllers/concerns, app/models/concerns)
• Frontend asset bundling with Vite + Stimulus for interactivity
• Client devices & PWA
• Rails Web/API Server
• Asset pipeline (Vite)
• ActiveRecord → PostgreSQL
• GoodJob queue & worker pool
• SnailMail PDF service
• ActionMailer SMTP path
• ActionCable websocket channel
• External integrations (USPS, Airtable, Zenventory, Geocoding, OpenAI)
• ActiveStorage (local/S3)