惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
H
Help Net Security
V
Visual Studio Blog
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
MyScale Blog
MyScale Blog
The Cloudflare Blog
Martin Fowler
Martin Fowler
D
Docker
腾讯CDC
F
Fortinet All Blogs
雷峰网
雷峰网
GbyAI
GbyAI
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
博客园 - 叶小钗

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I forgot a domain was auto-renewing. So I built a dashboa...
Pigeon Codeu · 2026-05-03 · via DEV Community

I do a bunch of small things on the side. I wrote a website for a friend's thesis, took on a couple of commissioned full-stack jobs, and I have one actual side hustle that's trying to make money. None of them live on the same stack. I keep picking whichever provider has the most generous free tier for that specific thing.

The thesis site is on Firebase, the commissioned stuff is on another host, the side hustle is split across three providers. Different free plans, different dashboards, different emails. Last month I noticed a domain auto-renewing for a project I'd completely forgotten about. That was the moment I gave up trying to remember any of this in my head, or trying to keep it up in a Notion that I would never update.

So I built StackMemo. One board for every project, with connectors that hit the providers' APIs so the cost and KPI numbers update on their own.

This post is about a few of the design decisions that turned out to matter and it is written for anyone considering building something similar, or just curious how a small Next.js + Postgres app actually fits together when there are a lot of moving pieces.

The stack

  • Next.js 16 (App Router) + TypeScript + Tailwind v4
  • Postgres on Neon, raw pg (no ORM - I want to see the SQL)
  • NextAuth v5 (credentials, GitHub, Google)
  • Stripe billing for the paid tiers
  • In-process cron via Next.js instrumentation.ts

1. The connector registry

Every provider (GitHub, Stripe, Neon, Cloudflare, Koyeb today) implements the same interface and gets registered once. Adding a new provider is one new file plus one line in the registry.

// lib/connectors/types.ts
export type ConnectorImpl = {
  provider: ConnectorProvider;
  displayName: string;
  iconPath?: string;
  authType: "api_key" | "token" | "oauth";
  credentialsSchema: CredentialsSchema;
  setupGuide?: SetupGuide;
  kpiCatalog: KpiDefinition[];
  listResources(creds: ConnectorCredentials): Promise<ResourceOption[]>;
  sync(args: SyncArgs): Promise<SyncResult>;
};

Enter fullscreen mode Exit fullscreen mode

// lib/connectors/index.ts
const registry: Partial<Record<ConnectorProvider, ConnectorImpl>> = {
  github,
  stripe,
  neon,
  cloudflare,
  koyeb,
};

export function getAllProviderMetadata(): ProviderMetadata[] { ... }

Enter fullscreen mode Exit fullscreen mode

The kpiCatalog is the bit that matters. Each connector declares which metrics it can fetch (github.stars, stripe.mrr, cloudflare.requests_24h...) and the user picks which ones they want active per project. Sync only fetches enabled KPIs, which keeps the API budget tight.

The interface intentionally returns SyncResult { kpis, warnings } instead of throwing on partial failure. Real-world APIs return 403 on plan-restricted endpoints all the time; treating that as a hard failure means a single locked-down KPI breaks the entire sync.

The marketing landing page reads from this same registry, so when I add a new connector, the chip shows up on the homepage marquee automatically, no second list to keep in sync.

2. Edge-safe auth split (Next.js 16 + NextAuth v5)

NextAuth v5 wants you to put your auth config in the Edge runtime so middleware can use it. But the full config wants the Postgres adapter and bcrypt for credentials login, neither of which work in Edge.

The fix is to split into two files:

// lib/auth.config.ts — Edge-safe (no pg, no bcrypt)
export default {
  providers: [GitHub({...}), Google({...})],
  pages: { signIn: "/login" },
  callbacks: { authorized: ({ auth }) => !!auth?.user },
} satisfies NextAuthConfig;

Enter fullscreen mode Exit fullscreen mode

// lib/auth.ts — Node runtime (full version)
export const { handlers, auth, signIn, signOut } = NextAuth({
  ...authConfig,
  adapter: PostgresAdapter(pool),
  providers: [...authConfig.providers, Credentials({...})],
});

Enter fullscreen mode Exit fullscreen mode

Middleware imports the Edge-safe config. Everything else imports the full one. This is the kind of footgun that's obvious in retrospect but eats half a day if you don't know about it.

3. Route groups for marketing vs app chrome

The first version had a single app/layout.tsx with the user header baked in. When I added the marketing landing page, that header showed up at the top of it, wrong vibe (the landing has its own nav). The fix was Next.js route groups:

app/
  layout.tsx              <- html/body/fonts only
  (marketing)/
    layout.tsx            <- marketing nav + footer
    page.tsx              <- /
    pricing/page.tsx      <- /pricing
  (app)/
    layout.tsx            <- app header with auth state
    dashboard/page.tsx    <- /dashboard
    projects/[id]/...

Enter fullscreen mode Exit fullscreen mode

URLs are unchanged and route groups are invisible to the router. Each group gets its own chrome. The marketing pages don't import auth code at all, which means an unauthenticated visitor never hits a database query just to load the landing page.

I also had to update the middleware matcher so it only protects actual app routes -> leaving /, /login, /signup, and the public share URLs (/p/[slug]) reachable without auth.

4. Encrypted credentials at rest

Connectors store API keys. Storing them in plaintext is a non-starter; KMS is overkill for a side project. I went with pgcrypto and a key in env:

// lib/crypto.ts
export function encryptCred(plaintext: string): Buffer {
  // pgp_sym_encrypt(plaintext, CONNECTOR_CRED_KEY)
}
export function decryptCred(ciphertext: Buffer): string { ... }

Enter fullscreen mode Exit fullscreen mode

The key is intentionally separate from AUTH_SECRET, rotating one shouldn't invalidate the other. Generated once with openssl rand -base64 32.

5. In-process cron, no separate worker

The hourly KPI sync runs inside the same Node process as the web server. No separate worker, no managed cron service.

// instrumentation.ts (Next.js calls this once per worker on startup)
export async function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    const { startCron } = await import("@/lib/cron");
    startCron();
  }
}

Enter fullscreen mode Exit fullscreen mode

Trade-off: scaling beyond one Node instance means the cron fires N times. For a side-project tracker that's a non-issue (the work is idempotent overwriting a KPI value with the same number is a no-op). For something with heavier per-tick work I'd extract it.

What I'd want to add

I have five connectors today (GitHub, Stripe, Neon, Cloudflare, Koyeb). Next on the list: Vercel, Plausible, Supabase, Resend, Netlify.

If you've ever lost track of a side-project subscription, what services would you most want a connector for? I'd rather hear suggestions than signups right now.

Live demo + free tier: StackMemo, drop a reaction on this article if you found it useful !