Project Structure
Folder organization and file structure guide
Quick guide to Plainform's folder structure and what goes where.
Root Structure
Key Folders
app/ - Next.js App Router
Routes, pages, layouts, and API endpoints.
app/
├── (auth)/ # Auth pages (sign-in, sign-up)
├── (base)/ # Main site pages
├── docs/ # Documentation
├── api/ # API routes
└── layout.tsx # Root layoutRoute groups (auth) and (base) don't appear in URLs.
components/ - React Components
components/
├── ui/ # Base components (Button, Card, Dialog)
├── blog/ # Blog components
├── pricing/ # Pricing components
├── providers/ # Context providers
├── hooks/ # Custom hooks
└── styles/ # Global CSScontent/ - MDX Content
content/
├── docs/ # Documentation pages
│ └── meta.json # Navigation structure
└── blog/ # Blog postsAdd .mdx files and update meta.json for navigation.
lib/ - Utilities & Integrations
lib/
├── utils.ts # General utilities (cn, formatDate)
├── stripe/ # Stripe client
├── prisma/ # Prisma client
├── resend/ # Email client
└── amazon/ # S3 clientEach integration gets its own folder with client and helpers.
prisma/ - Database
prisma/
├── schema.prisma # Database schema
└── migrations/ # Migration historyCommands:
npx prisma migrate dev # Create migration
npx prisma studio # Open GUI
npx prisma generate # Generate typestypes/ - TypeScript Definitions
types/
├── BlogInterfaces.ts
├── StripeInterfaces.ts
└── PricingInterfaces.tsPrefix all interfaces with I: IUser, IBlogPost, IProps.
validationSchemas/ - Zod Schemas
validationSchemas/
├── authSchemas.ts
├── eventSchemas.ts
└── newsletterSchemas.tsRuntime validation for forms and API routes.
locales/ - Internationalization
locales/
└── en.json # English translations{
"homePage": {
"heroSection": {
"title": "Welcome"
}
}
}Usage: import locale from '@/locales/en.json'
config/ - Site Configuration
config/
└── site.ts # Site metadata, linksCentralized config for site name, description, social links.
Development Files
.husky/ - Git Hooks
Pre-commit, commit-msg, and pre-push hooks for code quality.
- pre-commit: Runs linting checks
- commit-msg: Validates commit message format (commitlint)
- pre-push: Runs validation before pushing
.vscode/ - VS Code Settings
Shared editor config and recommended extensions.
.env - Environment Variables
DATABASE_URL="postgresql://..."
CLERK_SECRET_KEY="sk_..."
STRIPE_SECRET_KEY="sk_..."Never commit .env files. Use .env.example as template.
Quick Reference
| Need to... | Go to... |
|---|---|
| Add page | app/(base)/your-page/page.tsx |
| Create component | components/ui/YourComponent.tsx |
| Add API route | app/api/your-endpoint/route.ts |
| Write blog post | content/blog/your-post.mdx |
| Add docs page | content/docs/section/page.mdx |
| Create utility | lib/utils.ts or lib/your-module/ |
| Define types | types/YourInterfaces.ts |
| Add validation | validationSchemas/yourSchemas.ts |
| Update database | prisma/schema.prisma |
Import Aliases
import { Button } from '@/components/ui/Button';
import { prisma } from '@/lib/prisma/prisma';
import { IUser } from '@/types/UserInterfaces';
import locale from '@/locales/en.json';The @/ alias points to project root.
How is this guide ?
Last updated on