# annaxu9/anna-xu architecture

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

- Interactive diagram: https://gitdiagram.com/annaxu9/anna-xu
- Repository: https://github.com/annaxu9/anna-xu

## Overview

##### Project Type & Purpose
- This is a Next.js full-stack application created with create-next-app. It contains both frontend components (for rendering pages, UI elements, and client-side logic) and backend endpoints (located in the API routes) for server-side functionality.
- The project appears to present a diverse set of features (e.g., art portfolios, resume building, geography data, vibe check features integrating Spotify and visual elements, etc.) through different pages and modular components.

##### File Structure
- Top-Level Organization:
- The pages directory contains Next.js page components along with API routes (in pages/api) serving as the back end.
- Static assets and media are placed under the public directory.
- Contexts and hooks (e.g., AuthContext.js and useTrackData.js) manage global state and specialized business logic.
- Configuration and style files (tailwind.config.js, postcss.config.js, globals.css) indicate styling and build tooling choices.

##### Main Components to Highlight
a. Frontend Web Application:
- Pages: Located in the pages folder, including various dynamic routes (e.g., /api, /quizzes, /vibe-check) and static pages (e.g., index, about, resume).
- Contexts and Hooks: Global state management (e.g., for authentication) and custom data fetching (e.g., Spotify or track data).

b. API Backend:
- API Routes: Found under pages/api, responsible for tasks like handling login, callbacks, journal entries, and skills data.
- Utility Functions: API route helpers or services (e.g., utils/spotify.js) that provide the business logic behind API endpoints.

c. Data & Static Resources:
- Data Files: JSON files (e.g., quiz1.json in the data folder) that support dynamic content.
- Public Assets: Directories for images, demos, fonts, and other static media utilized by the frontend.

##### Relationships/Interactions
- The frontend (pages and components) interacts with the backend via API routes (the pages/api directory) to retrieve or update data.
- Global contexts and custom hooks help manage data flow between deep-nested components and API responses.
- Utility functions mediate critical operations like database access (dbPool.js) and external integrations (e.g., Spotify API calls).

##### Architectural Patterns & Design Principles
- Modular/Split components: The separation between organized component directories allows for a clear UI component hierarchy.
- Next.js File-Based Routing: Pages and API routes follow Next.js conventions, making the navigation logic and back-end integration transparent.
- SSR & Client-Side rendering: The system takes advantage of Next.js features to determine the best rendering strategy for each page.
- Separation of Concerns: The distinct directories for UI (components), routing (pages), state management (contexts/hooks), and business logic (utils) promote maintainability and scalability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        Pages["Next.js Pages"]:::pagesColor
        Art["Art Components"]:::uiComponents
        Color["Color Widgets"]:::uiComponents
        Geo["Geography Visuals"]:::uiComponents
        Journal["Journal Entries"]:::uiComponents
        NavBar["Navigation Bar"]:::uiComponents
        Resume["Resume Components"]:::uiComponents
        Screen["Screen Components"]:::uiComponents
        Vibe["Vibe-Check Widgets"]:::uiComponents
        Auth["Auth Context"]:::state
        Hook["Custom Hooks"]:::state
    end

    subgraph "Backend"
        API["API Endpoints"]:::backend
        Util["Utility Functions"]:::utils
    end

    subgraph "Data & Static"
        Data["Data Resources"]:::data
        Static["Static Assets"]:::static
    end

    %% Frontend Relationships
    Pages -->|"renders"| Art
    Pages -->|"renders"| Color
    Pages -->|"renders"| Geo
    Pages -->|"renders"| Journal
    Pages -->|"renders"| NavBar
    Pages -->|"renders"| Resume
    Pages -->|"renders"| Screen
    Pages -->|"renders"| Vibe

    Art -->|"uses"| Auth
    Color -->|"uses"| Auth
    Geo -->|"uses"| Auth
    Journal -->|"uses"| Auth
    NavBar -->|"uses"| Auth
    Resume -->|"uses"| Auth
    Screen -->|"uses"| Auth
    Vibe -->|"uses"| Auth

    Art -->|"fetchesData"| Hook
    Color -->|"fetchesData"| Hook
    Geo -->|"fetchesData"| Hook
    Journal -->|"fetchesData"| Hook
    NavBar -->|"fetchesData"| Hook
    Resume -->|"fetchesData"| Hook
    Screen -->|"fetchesData"| Hook
    Vibe -->|"fetchesData"| Hook

    Pages -->|"callsAPI"| API
    Art -->|"triggersAPI"| API
    Color -->|"triggersAPI"| API
    Geo -->|"triggersAPI"| API
    Journal -->|"triggersAPI"| API
    NavBar -->|"triggersAPI"| API
    Resume -->|"triggersAPI"| API
    Screen -->|"triggersAPI"| API
    Vibe -->|"triggersAPI"| API

    Auth -->|"authCalls"| API

    %% Backend Relationships
    API -->|"utilizes"| Util

    %% Data & Static Relationships
    Pages -->|"loads"| Static
    API -->|"serves"| Data

    %% Click Events
    click Pages "https://github.com/annaxu9/anna-xu/tree/main/pages"
    click Art "https://github.com/annaxu9/anna-xu/tree/main/components/Art"
    click Color "https://github.com/annaxu9/anna-xu/tree/main/components/Color"
    click Geo "https://github.com/annaxu9/anna-xu/tree/main/components/Geography"
    click Journal "https://github.com/annaxu9/anna-xu/tree/main/components/Journal"
    click NavBar "https://github.com/annaxu9/anna-xu/tree/main/components/NavBar"
    click Resume "https://github.com/annaxu9/anna-xu/tree/main/components/Resume"
    click Screen "https://github.com/annaxu9/anna-xu/tree/main/components/Screen"
    click Vibe "https://github.com/annaxu9/anna-xu/tree/main/components/Vibe-Check"
    click Auth "https://github.com/annaxu9/anna-xu/blob/main/contexts/AuthContext.js"
    click Hook "https://github.com/annaxu9/anna-xu/blob/main/hooks/useTrackData.js"
    click API "https://github.com/annaxu9/anna-xu/tree/main/pages/api"
    click Util "https://github.com/annaxu9/anna-xu/tree/main/utils"
    click Data "https://github.com/annaxu9/anna-xu/blob/main/data/quiz1.json"
    click Static "https://github.com/annaxu9/anna-xu/tree/main/public"

    %% Styles
    classDef pagesColor fill:#A3E4D7,stroke:#1ABC9C,stroke-width:2px;
    classDef uiComponents fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef state fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
    classDef backend fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef utils fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef static fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
```
