# manish-tamang/portfolio architecture

> Architecture diagram of the GitHub repository manish-tamang/portfolio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manish-tamang/portfolio
- Repository: https://github.com/manish-tamang/portfolio

## Overview

##### Main Components
- Frontend Application: Built using Next.js (located primarily in the app/ directory) with TypeScript and styled using Tailwind CSS.
- API Layer: Located under app/api, this layer contains endpoints for analytics, authentication (via NextAuth and possibly Firebase), Spotify (now-playing, top-artists, top-songs), GitHub, guestbook email, custom views, and WakaTime.
- Content Management: Managed via the Sanity CMS integration. Notice the sanity/ directory (with config files, schemaTypes, and a Studio at app/studio) that drives blog content and possibly other dynamic pages.
- External Integrations:
- Firebase: Handling view tracking, authentication, and guestbook messaging.
- Spotify & WakaTime: Real-time music and coding stats.
- Authentication: Involving NextAuth.js (with support from Firebase) to secure parts like the dashboard.
- Component Library & Reusable UI Elements: Found in components/ (including a dedicated UI folder with various interface components) which suggest a design system being used.
- Utilities & Business Logic: Located in the lib/ folder that abstracts common functions (for blog stats, fetchers, queries, etc.).
- Static Assets: These are stored in public/ and are also built into dist/ during the build process.
- Configuration & Deployment: Look at files like next.config.mjs, tsconfig.json, tailwind.config.ts and deployment configuration for Vercel.

##### Establish Relationships and Interactions
- User Interface (UI Layer) interacts directly with the Next.js pages in the app/ directory.
- These pages, as well as the various components, call the API endpoints (found under app/api) to fetch dynamic data or perform actions (analytics, auth, data fetching).
- The API routes are responsible for collating data from external services (e.g., Spotify for now-playing data, WakaTime for coding stats, GitHub data, etc.) and from backend services like Firebase.
- The portfolio also leverages a CMS backend via Sanity for the blog, project data, and other content. The Studio (located at /studio) indicates that content can be managed directly through Sanity’s interface.
- Static files and assets (fonts, images, audio, etc.) reside in the public/ folder and are served to the client.
- Utility libraries (from lib/) support the integration of these various data sources in a consistent manner across the application.
- Additionally, authentication flows handled via NextAuth are integrated into the API endpoints (in app/api/auth) and use Firebase for storing user session or analytics data.

##### Architectural Patterns and Principles
- The project utilizes a “component-based” design pattern (React components) for the frontend.
- An API-first approach is used for fetching dynamic data from external and internal sources.
- Separation of concerns is maintained – distinct folders for pages, API routes, utilities, and CMS configurations.
- Integration of external services is abstracted through dedicated utility modules (e.g., lib/spotify.ts, lib/fetcher.ts) to keep external dependencies decoupled.

##### Relevant Technologies Highlighted
- Next.js (React) for the frontend web application.
- TypeScript, enhancing code quality and maintainability.
- Tailwind CSS for styling.
- Sanity CMS for content management.
- Firebase for authentication, view counting, and guestbook handling.
- NextAuth.js for supporting secure authentication flows.
- External APIs for Spotify and WakaTime integrations.
- Additional libraries like Framer Motion (for animations), Recharts (for charts), and shadcn/ui (for UI primitives).

- Pages (app/)
- Reusable UI Components (components/)
- Styling (Tailwind CSS)
- “Build/Deployment” aspects with Vercel deployment and configuration files.
- From the frontend to the API.
- From the API to external services (including Firebase, Spotify, etc.).
- From the API and CMS back to the frontend.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        NXT("Next.js Frontend"):::frontend
        UI("UI Components"):::frontend
        STA("Static Assets"):::frontend
        CFG("Config & Deployment"):::config
    end

    %% API & Integration Layer
    subgraph "API & Integration Layer"
        API("API Layer"):::api
        UTIL("Utilities"):::utility
    end

    %% External Systems
    subgraph "External Systems"
        SAN("Sanity CMS"):::cms
        FIR("Firebase"):::backend
        SPOT("Spotify"):::integration
        WAKA("WakaTime"):::integration
    end

    %% Data Flow
    NXT -->|"fetchesData"| API
    API -->|"returnsData"| NXT
    API -->|"fetchesContent"| SAN
    API -->|"authAnalytics"| FIR
    API -->|"nowPlaying"| SPOT
    API -->|"codingStats"| WAKA
    API -->|"usesUtilities"| UTIL
    NXT -->|"renders"| UI
    NXT -->|"loadsAssets"| STA
    NXT -->|"configuredBy"| CFG

    %% Click Events
    click NXT "https://github.com/manish-tamang/portfolio/tree/main/app/"
    click API "https://github.com/manish-tamang/portfolio/tree/main/app/api/"
    click UI "https://github.com/manish-tamang/portfolio/tree/main/components/"
    click STA "https://github.com/manish-tamang/portfolio/tree/main/public/"
    click CFG "https://github.com/manish-tamang/portfolio/blob/main/next.config.mjs"
    click SAN "https://github.com/manish-tamang/portfolio/tree/main/sanity/"
    click FIR "https://github.com/manish-tamang/portfolio/blob/main/firebase/config.ts"
    click SPOT "https://github.com/manish-tamang/portfolio/blob/main/lib/spotify.ts"
    click WAKA "https://github.com/manish-tamang/portfolio/tree/main/app/api/wakatime"
    click UTIL "https://github.com/manish-tamang/portfolio/tree/main/lib/"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef api fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef config fill:#E6B0AA,stroke:#922B21,stroke-width:2px;
    classDef cms fill:#F5CBA7,stroke:#AF601A,stroke-width:2px;
    classDef backend fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef integration fill:#A9DFBF,stroke:#117864,stroke-width:2px;
    classDef utility fill:#E8DAEF,stroke:#7D3C98,stroke-width:2px;
```
