How kych0912/saas-starter-ko works
This project is a full-stack SaaS application built with Next.js. It integrates a marketing landing page, user authentication, a user dashboard with various subpages, and payment processing using StepPay. The overall architecture leverages Next.js’s app directory for server components and API routes while integrating middleware (for auth, localization, etc.), a Postgres database with Drizzle ORM, i18n support, and a component-based UI built partly on shadcn/ui.
Main Components
• Client/Browser: Represents the end users accessing the app through different entry points such as the landing page, pricing page, sign-up/sign-in pages, and the dashboard.
• Next.js Frontend:
• Pages & Layouts: Highlight the directories under app/[lng] with routes for dashboard, billing, login, and marketing.
• Locale & i18n System: Represent the i18n folder that contains local translations (KO/EN) and conversion scripts.
• UI Components: Include key reusable UI elements (e.g., buttons, cards, modals, etc.) located in the components/ui folder.
• API Endpoints:
• Authentication API: Detail the NextAuth integration seen under app/api/auth and the supporting auth modules in lib/auth.
• Payment Processing: Include the StepPay checkout and webhook endpoints located in app/api/steppay, along with the corresponding business logic in lib/payments.
• Middleware:
• Global and local middleware for authentication (user, language, and session validation) found in middleware and lib/auth/middleware.ts.
• Backend Services:
• Database: A Postgres database interacting via Drizzle ORM with configuration, migrations, seed, and queries found in the lib/db folder.
• External Services: Include payment gateway StepPay and OAuth integrations for Google and NAVER authentication.
Relationships & Interactions
• The Client makes HTTP requests (via navigation and form submissions) to the Next.js server.
• UI pages and components consume API endpoints for retrieving and updating data (authentication, billing, dashboard operations).
• Authentication flow involves the NextAuth endpoints (handled under app/api/auth) and corresponding session/middleware logic.
• Payment processing flows:
• Users are redirected to a StepPay checkout page (via designated API endpoints) when subscribing or purchasing.
• StepPay sends webhook notifications to the app (app/api/steppay/webhook) that trigger payment state updates.
• The business logic modules in the lib folder (for auth, DB, and payments) interact with the Postgres database using Drizzle ORM.
• Localization on both the server and client is managed via the i18n system that loads JSON resources from the app/i18n/locales folder.
Architectural Patterns & Design Principles
• Full-stack integration: Next.js is used as both the frontend and backend framework.
• Routing architecture: Clear separation of concerns using Next.js’s file-based routing (pages for landing, dashboard, billing, etc.).
• Middleware-driven security/validation: Global and route-specific middleware ensure routes are protected.
• Modular design: Reusable UI components and business logic modules (e.g., payments and authentication) are decoupled into their own directories.
• Internationalization (i18n): Provides multi-language support by maintaining separate locale JSON files and translation hooks.