Build beehiiv

KINDAreplaces $49/mosaves $588/yrback to the verdict

0%0 of 21 items done

Saved on this device only. Tick prerequisites first, then work the phases in order · do not start one until the checks above it pass.

Build a small newsletter publisher with a public archive and a safe send ledger.

estimated effort multi-daythe files for this build are in the project pack

RuntimePython 3.12+ and FlaskStorageSQLite through Python sqlite3InterfaceJinja HTML templates, CSS and vanilla JavaScriptVerificationPython unittest and browser acceptance fixturesFocused librariesmarkdown, bleach

Before step 1

Everything below is assumed from the first step. Tick each one when you actually have it, not when you plan to.

  1. installPython is free; this local prototype requires no hosting subscription.

    Why The local backend, tests and storage use Python.

    Get it Install Python from python.org. Open a terminal in a new empty project folder. On Windows, use py -3 where this guide says python if python is not on PATH; on macOS/Linux use python3 if needed. Create .venv and activate it before installing packages. open ↗

    Verify python --version reports 3.12+ and python -c "import sqlite3" succeeds.

  2. installNo paid service required for this local step.

    Why You need to view the local interface and edit generated project files.

    Get it Use an installed Chrome, Firefox or Edge browser. Open the empty project folder in your editor; open the terminal there, not in this catalog repository.

    Verify You can create a text file in the project folder and open browser developer tools.

  3. have readyNo paid service required for this local step.

    Why This fixture makes the first end-to-end check reproducible.

    Get it Create synthetic sample data before implementation: One confirmed subscriber, one unconfirmed address and one suppressed address; a draft post. Save it under fixtures/ with the expected results in fixtures/README.md; use no real credentials or customer records.

    Verify The fixture files and expected outcomes exist and can be inspected without a vendor account.

  4. decideNo paid service required for this local step.

    Why The full commercial product is larger than this guide.

    Get it The deliverable is a small newsletter publisher with a public archive and a safe send ledger. Read every exclusion below. Indie mode runs locally; any public or shared use requires the product access and deployment gates first.

    Verify You can name the primary workflow and the vendor features this version deliberately leaves out.

  5. Provider-specific relay fees and domain costs; no free tier or delivery guarantee is assumed.

    Why Outbound confirmations or replies need a delivery provider; a fake adapter covers automated tests.

    Get it Obtain SMTP host, port, username and password from your chosen relay dashboard under SMTP settings. Verify the sender/domain using that provider DNS instructions. Use only your own test recipient initially and record the actual plan and rate limit in OPERATIONS.md.

    Verify The supplied smtp_probe.py sends one labelled test message to your own inbox and reports the relay response without logging credentials.

Data model

Create these before the first phase that stores anything. Changing a table later is the expensive kind of change.

- posts(id,slug,title,body,state)
- subscribers(id,email,status,consent_at,token_hash)
- campaigns(id,post_id,state)
- deliveries(id,campaign_id,subscriber_id,state,message_id)
- suppressions(email,reason,at)
- Use stable ids and explicit relationships; add auxiliary tables named by the phases before those phases use them.
- Acceptance fixture: One confirmed subscriber, one unconfirmed address and one suppressed address; a draft post.

Environment variables

These go in a .env file the app reads at startup. The pack's .env.example is this table as a file · copy it, never commit the filled-in version.

VariableNeededExampleWhere the value comes from
DATA_DIRrequired./data/beehiivA new private folder this application creates on first run; never serve it as static files.
SECRET_KEYsecretrequiredreplace-with-a-random-secretGenerate with python -c "import secrets; print(secrets.token_hex(32))" and save only in .env.
APP_MODErequiredindieUse indie for loopback-only personal work. Product mode must refuse to start until owner login and the deployment gates are configured.
SITE_URLrequiredhttp://127.0.0.1:5000The origin used for local forms and links; replace with the chosen HTTPS origin in product mode.
SMTP_HOSTrequiredreplace-with-relay-hostCopy the SMTP hostname from the relay dashboard.
SMTP_PORTrequired587Use a relay supporting STARTTLS on this port; confirm it in its setup instructions.
SMTP_USERsecretrequiredreplace-with-smtp-userCopy the relay username; it may differ from your sign-in email.
SMTP_PASSWORDsecretrequiredreplace-with-smtp-passwordCreate SMTP credentials in the relay dashboard, not your personal mailbox password.
MAIL_FROMrequiredowner@example.comYour relay-verified sender address; replace before real sends.
MAIL_TEST_TOrequiredowner@example.comAn inbox you control for the explicit preflight test.

The build, in order

  1. Local foundation and data contract

    Create the runnable local foundation for a small newsletter publisher with a public archive and a safe send ledger, including the real schema and acceptance fixture.

    1. Run the venv command first, then stop and activate it before running the remaining commands. Use your OS instructions: Windows .venv\Scripts\activate.bat in cmd, or .venv\Scripts\Activate.ps1 in PowerShell; macOS/Linux source .venv/bin/activate. Then install the listed packages. Create app.py exposing app, load .env with python-dotenv, and add a /healthz route. Freeze tested dependency versions to requirements.txt. Create .env manually from .env.example; replace SECRET_KEY before launch.

      Files app.pyrequirements.txt.env.example.gitignore

      terminal
      python -m venv .venv
      python -m pip install Flask Flask-WTF python-dotenv waitress tzdata markdown bleach
      python -m pip freeze > requirements.txt
      python -m flask --app app run --host 127.0.0.1
    2. For database-backed state create schema.sql and db.py using this model: posts(id,slug,title,body,state); subscribers(id,email,status,consent_at,token_hash); campaigns(id,post_id,state); deliveries(id,campaign_id,subscriber_id,state,message_id); suppressions(email,reason,at). Add the auxiliary relationships explicitly used in later phases; use stable ids, foreign keys, parameterized values and transactions. For canonical files use atomic replacement and hashes instead. Implement python manage.py init and python manage.py seed to create only synthetic data: One confirmed subscriber, one unconfirmed address and one suppressed address; a draft post. Re-running init must not erase data.

      Files schema.sqldb.pymanage.pyfixtures/README.md

      terminal
      python manage.py init
      python manage.py seed
    3. Install Flask-WTF CSRF protection for forms and same-origin fetches, validate Host and Origin against SITE_URL, bound inputs and escape output. Deliberately public intake endpoints get bounded validation and rate limits; signed provider webhooks use signature checks instead of browser CSRF tokens. All other admin routes stay local until product authentication exists. When a later phase tests viewer/member permissions, implement the users, hashed passwords, expiring server sessions and role checks in this foundation first; product mode must never use a fabricated identity from request input. Add error, empty, keyboard-focus and retry states now.

      Files app.pytemplates/base.htmltest/test_foundation.py

    4. Create providers/mail.py using smtplib with a timeout, verified TLS/STARTTLS and an EmailMessage. Refuse placeholder credentials and non-test recipients until the owner enables sending. Implement scripts/smtp_probe.py to send one labelled message only to MAIL_TEST_TO, and provide a fake adapter for tests. Store no password or full message body in logs.

      Files providers/mail.pyscripts/smtp_probe.py

      terminal
      python scripts/smtp_probe.py
    done when · tick each as it passes
    watch out
    • The Flask development server is for local development only. Loopback binding alone does not replace CSRF and origin validation.
  2. Publication and consent

    Publication and consent for beehiiv: Build a Markdown post editor with sanitized email/web previews and a public archive containing only published posts.

    1. Build a Markdown post editor with sanitized email/web previews and a public archive containing only published posts.

      Files features/publication_and_consent.pytemplates/publication_and_consent.html

    2. Implement double-opt-in signup with expiring hashed tokens and a suppression list; send confirmation through the configured SMTP adapter.

      Files features/publication_and_consent.py

    3. Use One confirmed subscriber, one unconfirmed address and one suppressed address; a draft post. Check: Only the confirmed fixture becomes eligible for a campaign. Then check: A draft post cannot be fetched from its guessed archive URL. Add a focused regression for the failure case under test/ using a temporary database or folder and fake external services; also perform the visible workflow in a browser.

      Files test/test_publication_and_consent.py

      terminal
      python -m unittest discover -s test
    done when · tick each as it passes
    watch out
    • The archive and email are different outputs; a preview must show both.
  3. Campaign preparation

    Campaign preparation for beehiiv: Freeze the post content and recipient ids when preparing a campaign and show an exact recipient preview before sending.

    1. Freeze the post content and recipient ids when preparing a campaign and show an exact recipient preview before sending.

      Files features/campaign_preparation.pytemplates/campaign_preparation.html

    2. Add a plain-text part, visible unsubscribe link and List-Unsubscribe headers; recheck suppression immediately before each send.

      Files features/campaign_preparation.py

    3. Use One confirmed subscriber, one unconfirmed address and one suppressed address; a draft post. Check: Unsubscribing after preparation but before send excludes the recipient. Then check: The email preview contains a functional unsubscribe action and no script tags. Add a focused regression for the failure case under test/ using a temporary database or folder and fake external services; also perform the visible workflow in a browser.

      Files test/test_campaign_preparation.py

      terminal
      python -m unittest discover -s test
    done when · tick each as it passes
    watch out
    • Do not equate successful SMTP submission with inbox delivery or a legal compliance guarantee.
  4. Send and reconcile

    Send and reconcile for beehiiv: Use a unique campaign/subscriber delivery row, bounded rate and a worker lease; record accepted, failed and unknown outcomes.

    1. Use a unique campaign/subscriber delivery row, bounded rate and a worker lease; record accepted, failed and unknown outcomes.

      Files features/send_and_reconcile.pytemplates/send_and_reconcile.html

    2. Pause on ambiguous connection loss after transmission; offer operator reconciliation rather than blindly resending.

      Files features/send_and_reconcile.py

    3. Use One confirmed subscriber, one unconfirmed address and one suppressed address; a draft post. Check: Restarting skips accepted delivery rows and preserves unknown rows for review. Then check: A failed recipient does not prevent remaining eligible recipients from being processed. Add a focused regression for the failure case under test/ using a temporary database or folder and fake external services; also perform the visible workflow in a browser.

      Files test/test_send_and_reconcile.py

      terminal
      python -m unittest discover -s test
    done when · tick each as it passes
    watch out
    • Referral networks, paid subscriptions and domain reputation are not reproduced by this publisher.
  5. Portable delivery and clean-start proof

    Finish the beehiiv replacement with a documented first-run path and a recoverable export.

    1. Document prerequisites, every configuration variable, data locations and the three domain workflows: Publication and consent; Campaign preparation; Send and reconcile. Include the exclusions, actual costs and source check date 2026-09-05. Commands shown earlier that reference project files are files the builder must implement before running them.

      Files README.md.env.example

    2. Use sqlite3.Connection.backup for the database in DATA_DIR and pause writers while taking the matching attachment snapshot. Keep schema version, hashes and a manifest for beehiiv. Restore into a separate empty directory or isolated deployment, with all outbound actions and schedules disabled. Recreate this proof: One confirmed subscriber, one unconfirmed address and one suppressed address; a draft post. Compare ids/counts and open the result before recording the restore date. Never test a restore over the only live copy.

      Files OPERATIONS.mdscripts/backup.py

    3. Use a new folder and only README instructions to reach the fixture outcome. Install from requirements.txt, initialize storage, run the tests and exercise the UI at 375px and 1280px; use keyboard-only controls and inspect browser errors. Record exactly what passed; do not mark unrun checks complete.

      Files README.mdverification.md

      terminal
      python -m pip install -r requirements.txt
      python -m unittest discover -s test
    done when · tick each as it passes
    watch out
    • Export without an import or restore rehearsal is not verified portability.
what this build does not replace
after v1, if you want it

Need the files? The project pack on the verdict page hands your agent the whole brief · more newsletters.