How jitashi-arora/stockify works
Project type & purpose (what you’re diagramming)
This is a Next.js (App Router) full-stack web application. The file tree indicates:
• UI + routing in app/ using route groups (auth) and (root).
• Authentication implemented via lib/better-auth/* and lib/actions/auth.actions.ts.
• Database access via Mongoose/MongoDB in database/mongoose.ts.
• Market data integration via lib/actions/finnhub.actions.ts (Finnhub API).
• Background/workflow jobs using Inngest: app/api/inngest/route.ts, lib/inngest/*.
• Email delivery via Nodemailer: lib/nodemailer/*.
• Client-facing stock views/widgets: components/TradingViewWidget.tsx, stock routes under app/(root)/stocks/[symbol]/page.tsx.
So the “system design” should show: browser → Next.js app (SSR/RSC + API routes + server actions) → DB + external services (Auth, Finnhub, Inngest, Email, TradingView).
Page renders UI components; client components may call external embeds (TradingView)
• “HTTPS GET /stocks/:symbol”
• “Server Action: fetchQuote(symbol)”
• “Mongo query: findUserById”
• “REST: Finnhub quote endpoint”
Auth flows (must be a clear mini-subdiagram)
• Browser → (auth)/sign-in page
• Sign-in form → Auth server action → Better Auth → DB (user lookup)
• Better Auth → Session/Cookie issued → Browser
• Middleware checks cookie/session → allows/denies access to (root) routes
Inngest flows (event-driven path)
• Inngest Cloud → Next.js API route /api/inngest (webhook/handler)
• Handler → Inngest Functions → side effects:
• DB writes (MongoDB)
• External calls (Finnhub)
• Email sends (Nodemailer → SMTP)
TradingView integration
• Stock detail page → TradingViewWidget.tsx
• Widget → TradingView (external embed) directly from the client (browser → TradingView)
This should be drawn because it’s a distinct dependency that bypasses your server.
Architectural patterns to reflect
• Next.js App Router separation: route groups (auth) vs (root).
• Server Actions / service layer pattern under lib/actions/*.
• Middleware-based access control (auth gating at the edge).
• Integration-heavy architecture: DB + Finnhub + Inngest + SMTP + TradingView embed.
• Event-driven background processing via Inngest (async tasks separate from user requests).
Don’t overthink it: split into *many* components (what “detailed” means here)
• (auth) vs (root) route groups
• middleware
• server actions (auth vs finnhub)
• database connector + database
• inngest route handler vs inngest functions vs inngest cloud
• nodemailer service vs smtp provider
• tradingview widget vs tradingview external