How ninest/husker works
Main Components
• Frontend UI & Routing: The “app” directory is the heart of the Next.js routing. It includes multiple page routes (e.g., for links, contribute, courses, wiki, and even dynamic routes like [wikiSlug]) plus shared layouts and components.
• API Endpoints: Located under “app/api/…”, these endpoints (like the og image generation routes) serve as the backend for generating dynamic content.
• Shared Components & UI Library: The “components” folder covers reusable UI widgets (buttons, dialogs, typography, etc.) and a specific “notion” subfolder that encapsulates Notion-inspired content.
• Domain & Business Logic: The “modules” folder houses key logic relating to content (articles, categories, links), favorites, and Notion integrations.
• Helpers and Utilities: Utility functions in “utils” and hooks in “hooks” are used across the application to support functionalities like styling, formatting dates, and handling interactive states.
• External Integrations: References to the Notion API (as seen in the .env instruction for NOTION_API_KEY) and possible communication with external services (e.g., Discord, mailing list, Reddit links) are part of the ecosystem.
Relationships and Interactions
• Frontend pages (React components under “app”) use the shared UI components (from “components”) for consistent look and feel.
• These pages also consume domain logic from “modules” to fetch and display dynamic content (articles, links, courses, etc.).
• API routes in “app/api” facilitate server-side functions, such as generating dynamic images (OG images) that are used by the UI.
• The hooks layer provides state and behavior logic that connects UI events to business logic.
• The utilities support various calculations and formatting needs across both the UI and backend.
Architectural Patterns & Design Principles
• Component-based Architecture: The reusability and modularity are emphasized by the “components” and “modules” directories.
• Next.js Routing & API Patterns: The “app” directory structure shows a file-system-based routing mechanism with separation between page components and API endpoints.
• Separation of Concerns: Clear division between presentation (layouts, pages, components), domain logic (modules), and configuration (Next config, Tailwind config, etc.).
• Consistent Theming: Use of a “theme-provider” and “globals.css” indicates a central theming and styling approach.
Technologies, Frameworks, and Libraries
• Next.js as the primary framework for both the frontend and server-side routing.
• React for the UI components and hooks.
• Tailwind CSS for styling (as seen in tailwind.config.ts).
• Notion API integration (guided by environmental variables and “modules/notion”).
• A custom UI library under “components/ui” that may wrap third-party libraries or be entirely custom implementations.
• Various utility libraries and hooks to support functionalities like command menus and search.
Elements
• Labels: Clearly name each component (e.g., “Next.js Router (app folder)”, “API Endpoints (app/api)”, “Reusable Components (components)”, “Domain Logic (modules)”, “Utility Functions (utils)”).
• Interactions: Provide directional flows where UI triggers hooks, which in turn interact with the modules, and how the modules can interact with external services (like the Notion API).
• A layer for external systems (Notion API, potential integrations with mailing lists, Discord, and Reddit) towards the periphery.
• Subdivide the UI layer further into sections for the different pages/routes: links, contribute, courses, wiki, etc., showing how they share common layouts and components.
• How internal layers (e.g., hooks and utilities) support the main functionalities across both UI and API.