How zainal21/my-site works
Main Components
• Frontend: This is driven by Next.js. The “pages” directory defines your routes (e.g., home, about, blog, projects, uses, error pages) and API endpoints. Also, note the custom _app.tsx and _document.tsx files, which are central to managing global styles and document structure.
• UI Component Libraries:
• Data Layer: The “data” directory holds static data (experience, projects, links, skills), while “libs” includes helper libraries for blogs, date, fetch functions, and Spotify integration. This layer supports the content displayed on the site.
• State and Context: The “context” directory with ThemeContext.tsx provides a global state (likely for theming) to be shared across components.
• Hooks: Custom hooks like useSpotifyCurrentlyPlaying and useSpotifyPlaylist encapsulate logic for external API interactions.
• API Endpoints: Located under pages/api, including endpoints for Spotify integration (current-playing and playlist) and a generic hello endpoint.
• Layouts: The HomePageLayout under layouts, defining the overall structure of the site’s homepage.
• Static Assets and Configuration: The “public” folder holds images, a resume PDF, and an XML sitemap. Configuration files (next.config.js, tailwind.config.ts, postcss.config.js, tsconfig.json, etc.) define the build and styling systems.
• Next.js Server at the center handily driving both SSR and client interactions.
– Each page (home, about, blog, projects, uses) loads its corresponding React components.
– Highlight the API Routes under “pages/api” as a separate block that the frontend interacts with when fetching external data (such as Spotify playing status).
• Data Management & Integration:
– Show “Hooks” as wrappers that fetch or manage external API data and integrate back into components (e.g., hooks calling Spotify endpoints).
• Global Context:
• External Services:
Architectural Patterns and Design Principles
• Component-Based Architecture: The clear separation into a reusable design system and specific modules underlines the importance of high reusability and maintainability.
• API Layer Abstraction: The use of Next.js API routes to interface with external services (like Spotify) creates a decoupled architecture.
• Separation of Concerns: Dividing the project into UI (components), data (data and libs), state (context), and business logic (pages and hooks).
• SSR/Static Rendering: As a Next.js project, note the mix of server side rendering (SSR) and static pages, which is important for performance and SEO.
• Next.js routing layer and globally available context wrapping the application.
• Branch out to show the page components consuming the design system and module components.
• Interaction flow to the API layer for dynamic content (e.g., Spotify).
• Static assets and configuration influencing the overall system.