This guide provides essential information for AI agents working with the chanhdai.com codebase - a Next.js dev portfolio, blog, and component registry website.
Next.js portfolio, blog, and component registry website with:
- Component registry using shadcn/ui system
- Blog with MDX content
- Custom React components
- Framework: Next.js 16 (App Router)
- Styling: Tailwind CSS v4
- UI Components: shadcn/ui + custom components
- Package Manager: pnpm
- Language: TypeScript
- Content: MDX for blog posts
- Deployment: Vercel
src/app/- Next.js App Router pages (routes, layouts, API routes)src/components/- Shared UI componentssrc/registry/- Component registry source (components, hooks, blocks, examples)src/__registry__/- Auto-generated registry files (DO NOT EDIT)src/features/- Feature-based modules (blog, portfolio, sponsors)src/config/- Site and registry configurationsrc/hooks/- Custom React hookssrc/lib/- Utility libraries and helperssrc/styles/- Global styles and CSSsrc/assets/- Static assets (fonts, metadata)src/scripts/- Build and utility scriptssrc/types/- TypeScript type definitionssrc/utils/- Utility functions
src/config/site.ts- Site configuration and navigationsrc/config/registry.ts- Registry configurationsrc/features/portfolio/data/user.ts- User portfolio datasrc/registry/index.ts- Registry entry pointcomponents.json- shadcn/ui configuration
The project features a custom component registry built on top of shadcn/ui:
- Components (
src/registry/registry-components.ts) - UI components - Hooks (
src/registry/registry-hook.ts) - Custom React hooks - Blocks (
src/registry/registry-blocks.ts) - Pre-built blocks and sections - Examples (
src/registry/registry-examples.ts) - Component demos - Lib (
src/registry/registry-lib.ts) - Utility functions
registry:component- Reusable UI components (src/registry/registry-components.ts)registry:hook- Custom React hooks (src/registry/registry-hook.ts)registry:block- Pre-built blocks and sections (src/registry/registry-blocks.ts)registry:example- Component examples/demos (src/registry/registry-examples.ts)registry:lib- Utility libraries (src/registry/registry-lib.ts)
# Build registry internally
pnpm registry:internal:build
# Build shadcn registry
pnpm registry:buildAuto-generated files (DO NOT EDIT):
src/__registry__/index.tsxsrc/__registry__/registry.autogenerated.jsonpublic/r/*.json
# Install dependencies
pnpm install
# Start development server
pnpm dev # Runs on port 1408
# Build for production
pnpm build- TypeScript: Strict mode enabled
- ESLint: Next.js configuration
- Prettier: Code formatting
- File naming: kebab-case for files and component files
When writing code for this project, follow these principles:
- Write type-safe TypeScript code with explicit types when necessary
- Use descriptive variable and function names that make code self-documenting
- Add comments only for complex logic or non-obvious behavior (focus on "why" not "what")
- No emojis in code, comments, or commit messages
- Use JSDoc for public APIs when the signature alone isn't clear
- Follow SOLID principles: keep functions small, focused, and easy to understand
- Create component in
src/registry/[component-name]/ - Add to appropriate registry file (
registry-components.ts, etc.) - Create examples in
src/registry/examples/ - Run registry build commands
- Update documentation
- Location:
src/features/blog/content/ - Format: MDX files
- Supports: Custom components, code blocks, metadata
Portfolio Data Files (src/features/portfolio/data/):
user.ts- Core personal information, bio, contact details, job historyexperiences.ts- Detailed work experience, education, company informationprojects.ts- Portfolio projects with descriptions, links, skills, logostech-stack.ts- Technology stack, programming languages, tools, frameworksawards.ts- Competition awards, prizes, academic achievements, certificatescertifications.ts- Professional certifications, course completions, credentialssocial-links.ts- Social media profiles, professional networks, contact linkstestimonials.ts- Professional recommendations, endorsements from colleagues and clients
See .env.example for required variables:
Core Application:
APP_URL- Application base URL (e.g.,https://acme.com)
Registry Configuration:
REGISTRY_NAMESPACE- Namespace identifier for shadcn CLI (e.g.,@acme)REGISTRY_NAMESPACE_URL- URL pattern for component resolution (e.g.,https://acme.com/r/{name}.json)
External Services:
GITHUB_API_TOKEN- GitHub Personal Access Token for API calls (Get token)NEXT_PUBLIC_DMCA_URL- DMCA Protection badge URL (DMCA ProtectionPro)
Analytics & Tracking:
NEXT_PUBLIC_POSTHOG_KEY- PostHog project API key for analytics (Get key)NEXT_PUBLIC_POSTHOG_HOST- PostHog API host URL (e.g.,https://ph.acme.com)NEXT_PUBLIC_POSTHOG_UI_HOST- PostHog UI host URL (e.g.,https://us.i.posthog.com)
The project uses PostHog for analytics tracking. Events are defined in src/lib/events.ts with Zod schema validation. PostHog is initialized in src/instrumentation-client.ts (production only) with consent management via @c15t/nextjs package.
- Navigation:
MAIN_NAVinsrc/config/site.ts - Theme colors:
META_THEME_COLORS - GitHub repo:
SOURCE_CODE_GITHUB_REPO
- Create component directory:
src/registry/[name]/ - Implement component with proper TypeScript types
- Add to
src/registry/registry-components.ts - Create example in
src/registry/examples/ - Build registry:
pnpm registry:build
Edit src/features/portfolio/data/user.ts with new:
- Personal information
- Job details
- Project descriptions
- Contact information
- Create MDX file in
src/features/blog/content/ - Include frontmatter metadata
- Use custom components for enhanced content
- Use Tailwind CSS v4 syntax
- Follow existing color scheme (zinc-based)
- Support dark/light modes
- Use CSS variables for theme colors
- Components may depend on external packages
NEVER EDIT these files directly:
src/__registry__/index.tsxsrc/__registry__/registry.autogenerated.json- Files in
public/r/
- Components use React.lazy() for code splitting
- Images optimized with Next.js Image component
- MDX content is statically generated
When adapting this codebase, ensure ALL personal information is replaced. See User Portfolio section above for data file locations. Also update src/config/site.ts, blog posts, and asset URLs throughout the codebase.
pnpm build # Production build
pnpm start # Start production server
pnpm preview # Build and preview locally
pnpm lint # Run ESLint
pnpm format:write # Format code with Prettier
pnpm check-types # TypeScript type checking