ShipNowKit uses a standard Next.js App Router project structure, optimized for SaaS applications. This document will help you quickly understand the overall layout of the codebase and the responsibilities of each directory.
Basic Repository Structure
ShipNowKit is a single-repository (monorepo) Next.js application that primarily contains the following directories:
Main Directory Overview
app/ - Next.js Application Directory
The app/ directory follows Next.js 16 App Router conventions and contains all routes and page components:
-
[locale]/- Internationalized routes directorypage.tsx- Homepage (marketing landing page)blog/- Blog-related pagesdocs/- Documentation pagesdashboard/- User dashboardsignin/,register/- Sign-in and registration pagespayment/- Payment-related pagespolicies/- Privacy policy and terms pages
-
api/- API routes directoryauth/- Authentication-related APIs (Better Auth proxy)dashboard/- Dashboard management APIspayment/- Payment webhook handlerssearch/- Search functionality API
-
_templates/- Template files directoryT1/- Page components for template T1T2/- Page components for template T2- Each template includes independent page layouts and styles
-
layout.tsx- Root layout component, includes global configuration and theme providers
Routing Conventions: Next.js App Router uses file-system routing. [locale] represents a dynamic route segment for multi-language support. [[...slug]] represents an optional catch-all route, commonly used for nested routes in documentation systems.
components/ - Component Library
Reusable React components organized by functional modules:
-
auth/- Authentication-related componentsSignInButton.tsx- Sign-in buttonSignOutButton.tsx- Sign-out buttonSignedIn.tsx- Signed-in state check component
-
dashboard/- Dashboard componentsapp-sidebar.tsx- Sidebar navigationdata-table.tsx- Data table componentInvoiceDialog.tsx- Invoice dialogsettings/- Settings page related components
-
price/- Pricing and payment componentsPriceBtn.tsx- Price buttonpaddle/- Paddle payment-related componentshooks/- Custom hooks for pricing
-
ui/- Base UI components (based on shadcn/ui)button.tsx,card.tsx,dialog.tsx, and other base components- All components support theme switching (dark/light mode)
-
T1/,T2/- Template-specific components- Each template has independent Hero, Feature, Price, FAQ, and other components
Component Reuse: Components in components/ui/ are globally available base components, while components in components/T1/ and components/T2/ are template-specific and dynamically loaded through template switching scripts.
config/ - Configuration Files
Centralized application configuration management:
-
site.ts- Site metadata configuration- Website name, title, description
- Open Graph and Twitter Card configuration
- Social media account links
- Icon and logo configuration
-
index.ts- Core functionality configurationauthConfig- Authentication-related configuration (sign-in page path, etc.)paymentConfig- Payment-related configuration (payment provider, success page, etc.)
-
languages.ts- Internationalization configuration- List of supported languages
- Language codes, names, flags, and locales
-
types.ts- TypeScript type definitions for configuration
content/ - Content Directory
MDX-format documentation and blog content managed with Fumadocs:
-
docs/- Documentation contentmeta.json- Documentation navigation configuration*.mdx- Documentation files for each section- Supports multiple language versions (
.en.mdx,.zh.mdx)
-
blog/- Blog postsmeta.json- Blog metadata- Articles organized by category
- Also supports multiple languages
db/ - Database Related
Prisma ORM and database service layer:
-
prisma/- Prisma configurationschema.prisma- Database model definitionsvariants/- Schema variants for different databasesmysql.prisma,postgresql.prisma,sqlite.prisma,mongodb.prisma
migrations/- Database migration files
-
services/- Database service layeruser.ts- User-related database operationssubscription.ts- Subscription managementoneTimePayment.ts- One-time paymentsorder.ts- Order managementprice.ts- Price configurationcustomer.ts- Customer informationstats.ts- Statistics dataconfig.ts- System configuration
Multi-Database Support: ShipNowKit can switch between MySQL, PostgreSQL, SQLite, and MongoDB through the scripts/switch-database.js script. The script automatically updates the Prisma schema's provider configuration.
lib/ - Core Logic Library
Core business logic and utility functions for the application:
-
actions/- Server Actionsauth.ts- Authentication-related server operationspayment.ts- Payment-related server operationsuser.ts- User management operationsemail.ts- Email sending operations
-
payment/- Payment integrationsstripe/- Stripe payment integrationclient.ts- Stripe client configurationserver.ts- Server-side payment logicconfig.ts- Stripe configuration
paddle/- Paddle payment integrationserver.ts- Paddle server-side logicconfig.ts- Paddle configuration
utils.ts- Payment utility functions
-
auth/- Authentication core logicindex.ts- Better Auth main configurationconfig-loader.ts- Configuration loaderproxy.ts- Authentication proxy
-
utils/- Utility functionsencryption.ts- Encryption utilitiesutils.ts- General utility functionszod.ts- Zod validation utilities
-
admin.ts- Admin permission checks -
config-manager.ts- Configuration manager -
logger.ts- Logging utilities
messages/ - Internationalization Translation Files
Internationalization using next-intl:
en.json- English translationszh.json- Chinese translations
All user interface text is managed through translation files, making it easy to add support for new languages.
emailTemplate/ - Email Templates
Email templates built with React Email:
-
verification/- Email verification templatesShipNow.tsx- ShipNow-style verification emailregistry.ts- Template registry
-
magicLinks/- Magic Link email templatesNotionLike.tsx- Notion-style Magic Link emailregistry.ts- Template registry
scripts/ - Utility Scripts
Node.js scripts for project maintenance and development:
switch-database.js- Switch database typeswitch-template.js- Switch page templatecreate-test-user.js- Create test usertest-subscription-renewal.js- Test subscription renewalcleanup-stripe-test-data.js- Clean up Stripe test datacustom_stripe_billing_portal.js- Stripe billing portal configuration
public/ - Static Assets
Static files directory:
logo.svg- Website logofavicon.ico- Website iconT1/,T2/- Template-specific image resourcespaddle/- Paddle-related resourcessocial-icons/- Social media icons
Other Important Files
mdx-components.tsx- MDX component configuration for the documentation systemnext.config.mjs- Next.js configuration filetsconfig.json- TypeScript configurationtailwind.config.ts- Tailwind CSS configurationpackage.json- Project dependencies and script configuration
Directory Organization Principles
ShipNowKit's directory organization follows these principles:
- Organized by Functional Modules: Related functionality is grouped in the same directory (e.g.,
components/auth/,lib/payment/) - Convention over Configuration: Follows Next.js and React best practices
- Extensibility: Template system and multi-database support facilitate expansion
- Type Safety: Uses TypeScript to ensure type safety
- Internationalization First: Multi-language support considered from the design stage
Template System: ShipNowKit supports multiple page templates. You can quickly switch templates using scripts/switch-template.js. Template files are located in app/_templates/ and components/T1/, components/T2/ directories.
Quick Start
Follow this guide to set up ShipNowKit environment, install dependencies, and run locally in 5 minutes. Build your SaaS product from scratch with detailed configuration steps.
Update the codebase
Learn how to update your ShipNowKit codebase from the upstream repository to get the latest updates and features. Step-by-step guide for syncing with upstream changes.