PTENES
TRACK 6

🌹 Production, Deploy & Security

Production engineering: move from “it ran on my machine” to “it runs on its own in the cloud, securely and generating revenue.” Host code on GitHub, run it on a schedule or in response to events with Trigger.dev, protect secrets and data (env vars, RLS, auditing), make it reliable (logs, try/catch, retries, alerts), and monetize with Stripe.

3
Modules
22
Topics
~3h
Duration
Advanced
Level
Learning path progress 0% · 0 of 22
Production track banner: cloud servers, a security shield, cron, and webhooks in pink — reliable deployment
☁️ the cloud that runs it for you Module 6.1 GitHub & Trigger.dev Module 6.2 Secrets & Security · env vars · RLS Module 6.3 Reliability & Monetization host → protect → build reliability and generate revenue

The path of track 6: the code goes up to the cloud (GitHub + Trigger.dev), gets secured (secrets and RLS), and gains robustness and monetization — the final leap from prototype to product.

Learning path map

Detailed content

Illustration for module 6.1
6.1 ~55 min · 7 topics

🚀 GitHub & Trigger.dev

The two pillars of hosted automation: GitHub as cloud code storage (commit, push, history) and Trigger.dev as the execution engine (no timeout, retries, traces, alerts). Initialize the project, schedule it with cron, and read the dashboard.

Module progress 0% · 0 of 7
What it is:

Cloud code storage: deploy pulls from there (not from your machine), you can access it from anywhere, and you have history to revert to.

Why learn:

It’s a prerequisite for hosting: deploy platforms integrate directly with the repo.

Key concepts:

Repo = project folder; commit = snapshot; push = send to the cloud.

What it is:

GitHub's command-line tool (gh) authenticates and connects the project; .gitignore lists what must never be pushed—the golden rule is .env.

Why learn:

A leaked .env is a leaked secret; .gitignore is the first line of defense.

Key concepts:

gh auth login; .gitignore; secret kept outside the repo.

What it is:

The cloud execution engine: runs tasks without timeouts, with automatic retries, a trace of every step, and failure alerts. Like a reliable assistant, not a sticky note.

Why learn:

It’s what closes the “agentic gap”—it provides visibility when AI is no longer being supervised.

Key concepts:

Runs TypeScript (the AI writes it); official MCP; dev vs. prod.

What it is:

Install the official MCP, copy the Project ID, and run init — which creates trigger.config.ts and the tasks folder; dev starts the local worker.

Why learn:

With the MCP, you manage the project by chatting; without it, you end up in the terminal.

Key concepts:

interactive init; restart after installing MCP; Project ID.

What it is:

A 5-field pattern (minute, hour, day of month, month, day of week) that defines when the task runs. 0 7 * * * = every day at 7 a.m.

Why learn:

It’s what makes automation run without you being there—it scales beyond “show up and trigger it.”

Key concepts:

5 fields; * = any; */5 = every 5.

What it is:

The production window: a list of runs, traces (each row = one step), payload/output, a schedules section, queues and alerts, and two environments (dev and prod).

Why learn:

Now that the AI is no longer monitoring things, the dashboard is where you see what happened.

Key concepts:

Run = execution; trace = step-by-step; test in dev, release in prod.

What it is:

The discipline of building with deployment in mind from the start: the “one initial prompt to rule them all” asks for fixed inputs, structured output, error handling, and logging from the beginning.

Why learn:

In production, AI won’t fix things on its own; anything you didn’t ask for in the prompt doesn’t come for free.

Key concepts:

Deploy from the 1st prompt; commit → push → deploy loop; check the run.

Illustration for module 6.2
6.2 ~60 min · 8 topics

🔐 Secrets & Security

How to keep keys and data safe: environment variables (local vs. cloud), .env.example and reading via process.env, OAuth & refresh tokens, the golden rules for secrets, Row-Level Security to isolate data, security auditing, and why an open app is a financial risk.

Module progress 0% · 0 of 8
What it is:

The secret is stored outside the code and injected only at runtime—so the code never contains the key.

Why learn:

It’s the mechanism that separates “what’s public” (code) from “what’s secret” (keys).

Key concepts:

External secret; injected at runtime; code with no embedded key.

What it is:

Locally, secrets live in .env; in the cloud, they live in the Environment Variables dashboard (Trigger.dev/Vercel), which injects them at runtime. Trigger.dev doesn't read the local .env.

Why learn:

Forgetting to add the key in production is the failure that "only shows up in prod".

Key concepts:

Two environments (dev and prod); check both; the cloud can’t read the local .env.

What it is:

A .env.example lists keys WITHOUT values (safe to commit); the code reads values via process.env and never writes them directly.

Why learn:

Document which secrets the project needs without exposing any of them.

Key concepts:

.env.example = names only; process.env = reading; nothing hard-coded.

What it is:

OAuth delegates access to a service (e.g., Google) without exposing your password; the refresh token renews access automatically. When the standard flow fails, a terminal script generates the token.

Why learn:

It's how hosted agents access Sheets, Drive, and Gmail without you logging in every time.

Key concepts:

Client ID/secret; refresh token; terminal fallback.

What it is:

The three non-negotiable rules: never paste keys into the AI chat, never commit .env, and rotate/regenerate keys (ideally, use different keys for local and production).

Why learn:

An API key is like access to a credit card: if it leaks, someone can spend on your behalf.

Key concepts:

Key = card; .gitignore; rotate and separate dev/prod.

What it is:

Row-Level Security: rules that live in the database itself (Supabase) and prevent one user from seeing another user’s data—even if there’s a bug in the frontend.

Why learn:

It’s an extra layer: the database protects the data independently of the app.

Key concepts:

Database rule; isolation by user; defense in depth.

What it is:

Ask the AI to act as a security specialist and check: protected routes, no keys exposed in the frontend, secrets only in env vars, and RLS enabled.

Why learn:

Before putting the app into production, an explicit audit catches what slipped through.

Key concepts:

Checklist of 4 points; clean context; fix whatever fails.

What it is:

An app without authentication on the internet can be triggered by anyone with the URL — and each trigger uses your AI key. You pay for other people's usage.

Why learn:

Justifies adding login (Supabase) and usage limits before sharing it.

Key concepts:

Public URL = open door; authentication; usage limits.

Illustration for module 6.3
6.3 ~55 min · 7 topics

🛡️ Reliability & Monetization

What separates “works once” from “reliable and profitable”: the agentic gap revisited, meaningful logging, try/catch in external calls, retries with backoff (vs. logic bugs), failure alerts, the human debugging loop, and monetization with Stripe (product, webhook, subscriptions, freemium).

Module progress 0% · 0 of 7
What it is:

Once it’s live on a schedule or event, the AI is no longer reading errors and fixing them: the task runs, but doesn’t adapt on its own. That’s the agentic gap.

Why learn:

It's why you build in error handling and logging from the 1st prompt — you can't count on self-healing.

Key concepts:

It runs but doesn’t adapt; visibility through the platform; human feedback loop.

What it is:

Specific logs at every relevant step: "the search returned 429 from source 3," not "the task failed." The message needs to be actionable.

Why learn:

A vague log is useless; a log with context is what makes the error diagnosable.

Key concepts:

Specific > generic; context (status, source); each step.

What it is:

Wrap every external API call in try/catch: log the error with context, continue where possible, and only "throw" on critical failures.

Why learn:

It’s what makes the task write a partial line instead of freezing when an API fails.

Key concepts:

try/catch per call; continue; throw only for critical errors.

What it is:

Configure the task to retry (e.g., up to 3 times, with exponential backoff starting at 30s). Retries solve transient API problems—not code bugs.

Why learn:

Knowing the difference helps you avoid endlessly repeating a mistake that will never work.

Key concepts:

Exponential backoff; transient vs. logical; retry limit.

What it is:

Set up failure alerts in the dashboard by email, Slack, or webhook—choosing the environment and type of failure. It takes less than two minutes.

Why learn:

You want to know about the outage before the end user notices.

Key concepts:

Alert channel; per environment; every task must have an alert.

What it is:

AI still debugs, just not automatically: you open the red trace, copy the error, paste it into the AI ("here's the trace that failed; what's wrong?"), apply the fix, and redeploy.

Why learn:

It’s a substitute for self-healing—quick diagnosis, but with a human passing along the error.

Key concepts:

Red trace; copy and paste; redeploy and test.

What it is:

Add payments with Stripe and turn it into a freemium SaaS: a free tier (e.g., 2 uses/day) and a paid tier (e.g., $29/month unlimited) via Stripe Checkout, with a webhook listening for subscription events.

Why learn:

Complete the transition from “just a workflow” to a product that generates revenue and limits your costs.

Key concepts:

4 keys (publishable, secret, price ID, webhook secret); freemium; subscription table.

← Track 5: Projects Course start →