Atomic Design Pattern
The NJ Rajat Mahotsav platform implements Atomic Design principles, organizing components into five distinct levels of complexity. This approach ensures scalability, reusability, and maintainability.Import from index files when available for cleaner imports throughout the codebase.
Component Hierarchy
Atoms: Basic Primitives
Atoms are the smallest building blocks that cannot be broken down further while maintaining their purpose.Example: Scroll to Top Button
Location:components/atoms/scroll-to-top.tsx
components/atoms/scroll-to-top.tsx
Other Atom Examples
Theme Provider
components/atoms/theme-provider.tsxWraps next-themes provider for light/dark modeLoading Screen
components/atoms/loading-screen.tsxInitial loading splash with audio consentTypewriter Effect
components/atoms/typewriter.tsxAnimated text typing effectForm Inputs
components/atoms/input.tsx, textarea.tsx, checkbox.tsxBasic form field componentsMolecules: Simple Composites
Molecules combine atoms to create functional UI components with a single, clear purpose.Example: Guru Card
Location:components/molecules/guru-card.tsx
components/molecules/guru-card.tsx
- Uses Cloudflare image optimization
- Hover effects with gradient overlays
- Responsive sizing with Tailwind classes
- Grayscale filter for consistent aesthetic
Other Molecule Examples
- Form Components
- Display Components
- Interactive Components
Date Picker (
components/molecules/registration-date-picker.tsx)Uses react-day-picker with date-fns and chrono-node for natural language parsingPhone Input (components/molecules/phone-input.tsx)International phone number input with country selectorCountry Selector (components/molecules/country-selector.tsx)Dropdown for country selectionOrganisms: Complex Sections
Organisms are sophisticated components that combine molecules and atoms to form complete sections of the interface.Example: Navigation System
Location:components/organisms/navigation.tsx
components/organisms/navigation.tsx
- Dynamic width calculation with ResizeObserver
- Responsive menu item rendering
- Supabase auth integration for admin access
- Tubelight navbar with overflow detection
Other Organism Examples
Seva Submission Form
components/organisms/seva-submission-form.tsxMulti-step form with react-hook-form and zod validationImage Carousel Modal
components/organisms/image-carousel-modal.tsxFull-screen image gallery with swipe gesturesVideo Section
components/organisms/video-section.tsxCustom video player with controlsTimeline
components/organisms/MobileTimeline.tsxInteractive event schedule displayGuru Carousel
components/organisms/guru-carousel.tsxSwipeable carousel of guru cardsSticky Footer
components/organisms/sticky-footer.tsxPersistent footer with social linksTemplates: Page Layouts
Templates define page-level structures. Currently minimal as the project focuses on component composition. Location:components/templates/
Most page layouts are defined directly in the app directory using Next.js 15 conventions.
UI Components (shadcn/ui)
Separated for easy updates and framework independence:- shadcn/ui
- Custom Registries
Style: New YorkMode: React Server Components enabledComponents use Radix UI primitives for accessibility and can be customized through Tailwind classes.
Component Import Patterns
Direct Imports
Index File Imports
When available, prefer index file imports:Best Practices
Follow Atomic Principles
Place components at the appropriate level:
- Atoms: Single-purpose, no internal composition
- Molecules: Combine atoms with clear purpose
- Organisms: Complex features with business logic
Client vs Server Components
Use
"use client" only when needed:- Event handlers
- useState/useEffect
- Browser APIs
Next Steps
State Management
Learn about Context API and custom hooks
Styling System
Explore Tailwind configuration and CSS variables
