Databayt follows a feature-based, modular architecture designed for scalability, reusability, and maintainability. Our structure supports micro-services and micro-frontend patterns while leveraging Next.js App Router conventions.
Databayt/
├── public/ # Static assets
├── src/ # Source code (Next.js src directory pattern)
│ ├── app/ # Next.js App Router pages and routing
│ ├── components/ # Reusable components
│ ├── lib/ # Shared utilities and configurations
│ └── types/ # Global TypeScript definitions
├── docs/ # Documentation
├── .env.local # Environment variables
├── next.config.js # Next.js configuration
├── package.json # Dependencies
├── tailwind.config.js # Tailwind CSS configuration
└── tsconfig.json # TypeScript configurationsrc/) Structuresrc/app/)Following Next.js App Router conventions for routing and page management:
src/app/
├── globals.css # Global styles
├── layout.tsx # Root layout
├── page.tsx # Home page
├── loading.tsx # Global loading UI
├── error.tsx # Global error UI
├── not-found.tsx # 404 page
├── gallery/ # Feature route: /gallery
│ ├── page.tsx # Gallery main page
│ ├── layout.tsx # Gallery layout
│ ├── loading.tsx # Gallery loading state
│ ├── error.tsx # Gallery error handling
│ └── [slug]/ # Dynamic gallery routes
│ ├── page.tsx # Individual gallery page
│ └── edit/ # Nested route: /gallery/[slug]/edit
│ └── page.tsx # Edit gallery page
└── dashboard/ # Feature route: /dashboard
├── page.tsx # Dashboard main page
├── layout.tsx # Dashboard layout
└── analytics/ # Nested route: /dashboard/analytics
└── page.tsx # Analytics pagesrc/components/)Three-layer component architecture for maximum reusability:
src/components/
├── ui/ # shadcn/ui components (installed via CLI)
│ ├── button.tsx
│ ├── input.tsx
│ ├── card.tsx
│ └── ...
├── atoms/ # Atomic reusable components (shadcn pattern)
│ ├── logo.tsx
│ ├── badge.tsx
│ ├── avatar.tsx
│ └── spinner.tsx
├── templates/ # Layout and template components (shadcn pattern)
│ ├── header.tsx
│ ├── footer.tsx
│ ├── sidebar.tsx
│ └── navigation.tsx
└── gallery/ # Feature-specific components (matches /gallery route)
├── constants.ts # Gallery constants and configurations
├── types.ts # Gallery TypeScript type definitions
├── validation.ts # Gallery form validation schemas
├── actions.ts # Gallery server actions and API calls
├── use-gallery.tsx # Gallery custom React hooks
├── form.tsx # Gallery form components
├── card.tsx # Gallery card component
├── table.tsx # Gallery table/list component
├── content.tsx # Gallery content display component
├── featured.tsx # Gallery featured items component
├── all.tsx # Gallery "show all" component
└── detail.tsx # Gallery detail/single item componentEvery URL route has a corresponding feature directory in both src/app/ and src/components/.
For route /gallery:
src/app/gallery/ – Contains Next.js page components and routing logicsrc/components/gallery/ – Contains feature-specific UI components and logic| File | Purpose | Example Content |
|---|---|---|
constants.ts | Feature constants, configs, static data | API endpoints, default values, enums |
types.ts | TypeScript type definitions | Interfaces, types, API response schemas |
validation.ts | Form validation schemas | Zod schemas, validation rules |
actions.ts | Server actions and API calls | Data fetching, mutations, server logic |
use-[feature].tsx | Custom React hooks | State management, data fetching hooks |
form.tsx | Form components | Create/edit forms, form handling |
card.tsx | Card/item components | List items, preview cards |
table.tsx | Table/list components | Data tables, lists with pagination |
content.tsx | Content display components | Rich content, formatted text |
featured.tsx | Featured/highlight components | Hero sections, featured items |
all.tsx | "Show all" list components | Complete lists, archive pages |
detail.tsx | Detail/single item components | Single item views, detail pages |
For a new feature route /products:
Create route structure:
src/app/products/
├── page.tsx # Products listing page
├── layout.tsx # Products layout
└── [id]/
└── page.tsx # Individual product pageCreate component structure:
src/components/products/
├── constants.ts # Product constants
├── types.ts # Product type definitions
├── validation.ts # Product validation schemas
├── actions.ts # Product API actions
├── use-products.tsx # Product hooks
├── form.tsx # Product form
├── card.tsx # Product card
├── table.tsx # Products table
├── content.tsx # Product content display
├── featured.tsx # Featured products
├── all.tsx # All products list
└── detail.tsx # Product detail viewsrc/components/ui/)npx shadcn-ui@latest add [component]src/components/atoms/)src/components/templates/)src/components/[feature]/)src/lib/)src/lib/
├── utils.ts # General utility functions (shadcn utils)
├── cn.ts # className utility (shadcn)
├── validations/ # Shared validation schemas
├── hooks/ # Shared custom hooks
├── constants/ # Global constants
├── api/ # API client configurations
└── auth/ # Authentication utilitiessrc/types/)src/types/
├── global.ts # Global type definitions
├── api.ts # API response types
├── auth.ts # Authentication types
└── database.ts # Database schema typeskebab-case.tsx (e.g., user-profile.tsx)use-feature-name.tsx (e.g., use-gallery.tsx)kebab-case.ts (e.g., gallery-types.ts)page.tsxlayout.tsxloading.tsxerror.tsxnot-found.tsxconstants.ts or config.tsactions.tsvalidation.tsutils.tsConfigure TypeScript paths in tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@/components/*": ["./src/components/*"],
"@/lib/*": ["./src/lib/*"],
"@/types/*": ["./src/types/*"]
}
}
}// Feature components
import { GalleryCard } from '@/components/gallery/card'
import { useGallery } from '@/components/gallery/use-gallery'
// Shared components
import { Button } from '@/components/ui/button'
import { Logo } from '@/components/atoms/logo'
import { Header } from '@/components/templates/header'
// Utilities
import { cn } from '@/lib/utils'
import type { GalleryItem } from '@/types/gallery'lib/ and components/atoms|templates/src/app/ firstsrc/components/When adding a new feature:
src/app/[feature]/src/components/[feature]/This structure ensures our codebase remains organized, scalable, and contributor-friendly while supporting our mission of building reusable automation components for businesses worldwide.
On This Page
Directory StructureOverviewCore PrinciplesProject Root StructureSource Directory (src/) StructureApp Directory (src/app/)Components Directory (src/components/)Feature Directory PatternStandard Feature FilesFeature Implementation ExampleComponent Layer DefinitionsUI Layer (src/components/ui/)Atoms Layer (src/components/atoms/)Templates Layer (src/components/templates/)Feature Layer (src/components/[feature]/)Shared UtilitiesLib Directory (src/lib/)Types Directory (src/types/)File Naming ConventionsComponentsPages (App Router)UtilitiesImport PatternsAbsolute ImportsImport ExamplesBest PracticesComponent OrganizationFile StructureDevelopment WorkflowMicro-Frontend ConsiderationsFeature IndependenceReusabilityScalabilityContributing Guidelines