How btw-so/btw works
Main Components
• Frontend (Writer): This component (located in the “writer” directory) is the main user interface for content creation and editing. It’s a rich client-side application built with modern tools (React, Redux, Sagas, etc.) and has extensive testing and configuration files.
• Backend – Publishing Service (Publisher): The “publisher” folder hosts a Node.js/Express-based server that handles publishing-related routes (index.js, internal.js, sitemap.js), templating with Handlebars (files in the “views” folder), and overall publication logic.
• Background Task Service (Tasks): The “tasks” directory contains another Express-like service that is responsible for handling asynchronous operations like email notifications, OTP processing, note handling, and alerts. It includes services for database operations, queue management, and redis-based notifications.
• Database and External Services: The application requires a PostgreSQL instance (as mentioned by the “btw.sql” file and TASKS_DATABASE_URL environment variable) along with external integrations such as SMTP for email, S3 for media uploads, and possibly Redis (indicated by the tasks/services/redisPublisher file).
Relationships and Interactions
• A client (admin user) interacts with the Writer frontend for content creation and configuration.
• The Writer frontend communicates with the Publisher backend to publish content, render pages (including admin and public pages), and manage dynamic routes.
• The Publisher may also interface with the Tasks service for background jobs—such as sending OTP emails, processing queued updates, or alerting.
• Both publisher and tasks services interact with the PostgreSQL database to persist and read data.
• External services (SMTP, S3, possibly Redis) are integrated to provide email deliveries, file storage, and caching/queueing functionalities.
Architectural Patterns and Key Details
• Each component is isolated into its own service (following a microservice-like separation), which makes it easier to scale or update components independently.
• The development and production deployment utilize Docker (as seen from the Dockerfiles and docker-compose YAML files in the “deploy” folder and within individual service folders).
• There’s clear separation of concerns: the Writer is focused on the frontend user experience, Publisher handles content delivery and server-side logic, and Tasks manages asynchronous processing.
• Technologies include Express (Node.js) on the backend, Handlebars for server-side templating in Publisher, React along with modern JavaScript/TypeScript tooling for Writer, and various tools for testing (Jest, Cypress, etc.).