# atzin-escandia/mindboard architecture

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

- Interactive diagram: https://gitdiagram.com/atzin-escandia/mindboard
- Repository: https://github.com/atzin-escandia/mindboard

## Overview

##### Project type and purpose
- Mindboard is a Single-Page Application (SPA) built entirely in the browser using React + TypeScript. Its purpose is to display a high-performance, virtualized masonry photo gallery with live search, detail views, and theme toggling. It consumes the Pexels REST API for photo data.

##### File structure
- Top‐level files
- index.html, main.tsx, App.tsx – entry point for the React app
- vite.config.ts, tsconfig*.json, package.json – build/config
- .env.example – environment variables (API key, API URL)
- src/
- pages/ – React Router pages (Home, PhotoDetail)
- components/ – Presentational and container components
– ui/ – shared UI primitives (Button, Input, Header, etc.)
- context/ – React Contexts (FilterContext, ThemeContext)
- hooks/ – custom hooks (useDebounce, useInfiniteScroll, useMasonryColumns, useOnScreen)
- services/ – API clients and data-fetching hooks (apiClient.ts with Axios, usePexels.ts using TanStack Query)
- models/ – TypeScript types for photo objects
- styles/ – global CSS (Tailwind entrypoint)

##### README for additional insights
- Key features:
- Virtualized masonry grid (renders only visible photos)
- Live search integrated with the grid
- Photo detail view with back-navigation to scroll position
- Light/dark theme toggle
- Technology stack: React, React Router DOM, TypeScript, Vite, TanStack Query, Tailwind CSS, Axios

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser and app bootstrap
    Browser["Browser / Client"]:::external
    HTML["index.html"]:::presentation
    Main["main.tsx"]:::presentation
    App["App & Routing Layer (src/App.tsx)"]:::presentation

    Browser --> HTML
    HTML --> Main
    Main --> App
    click HTML "https://github.com/atzin-escandia/mindboard/blob/main/index.html"
    click Main "https://github.com/atzin-escandia/mindboard/blob/main/src/main.tsx"
    click App "https://github.com/atzin-escandia/mindboard/blob/main/src/App.tsx"

    %% Presentation Layer
    subgraph "Presentation Layer" 
        style PresentationLayer fill:none
        HomePage["Home Page\n(src/pages/Home.tsx)"]:::presentation
        PhotoDetail["Photo Detail Page\n(src/pages/PhotoDetail.tsx)"]:::presentation
        SearchInput["Search Input\n(src/components/SearchInput.tsx)"]:::presentation
        MasonryGrid["Masonry Grid\n(src/components/MasonryGrid.tsx)"]:::presentation
        VirtualImg["Virtualized Image\n(src/components/VirtualizedImage.tsx)"]:::presentation
        ThemeToggle["Theme Toggle\n(src/components/ui/ThemeToggle.tsx)"]:::presentation

        subgraph "UI Primitives"
            Button["Button\n(src/components/ui/Button.tsx)"]:::presentation
            Input["Input\n(src/components/ui/Input.tsx)"]:::presentation
            Header["Header\n(src/components/ui/Header.tsx)"]:::presentation
            Loading["Loading\n(src/components/ui/Loading.tsx)"]:::presentation
            SkeletonCard["SkeletonCard\n(src/components/ui/SkeletonCard.tsx)"]:::presentation
            SkeletonMasonry["SkeletonMasonry\n(src/components/SkeletonMasonry.tsx)"]:::presentation
            SkeletonDetail["SkeletonDetailCard\n(src/components/SkeletonDetailCard.tsx)"]:::presentation
        end
    end

    App --> HomePage
    App --> PhotoDetail
    HomePage --> SearchInput
    HomePage --> MasonryGrid
    MasonryGrid --> VirtualImg
    HomePage --> Header
    HomePage --> Input
    HomePage --> Button
    HomePage --> Loading
    HomePage --> SkeletonMasonry

    PhotoDetail --> Header
    PhotoDetail --> SkeletonDetail

    click HomePage "https://github.com/atzin-escandia/mindboard/blob/main/src/pages/Home.tsx"
    click PhotoDetail "https://github.com/atzin-escandia/mindboard/blob/main/src/pages/PhotoDetail.tsx"
    click SearchInput "https://github.com/atzin-escandia/mindboard/blob/main/src/components/SearchInput.tsx"
    click MasonryGrid "https://github.com/atzin-escandia/mindboard/blob/main/src/components/MasonryGrid.tsx"
    click VirtualImg "https://github.com/atzin-escandia/mindboard/blob/main/src/components/VirtualizedImage.tsx"
    click ThemeToggle "https://github.com/atzin-escandia/mindboard/blob/main/src/components/ui/ThemeToggle.tsx"
    click Button "https://github.com/atzin-escandia/mindboard/blob/main/src/components/ui/Button.tsx"
    click Input "https://github.com/atzin-escandia/mindboard/blob/main/src/components/ui/Input.tsx"
    click Header "https://github.com/atzin-escandia/mindboard/blob/main/src/components/ui/Header.tsx"
    click Loading "https://github.com/atzin-escandia/mindboard/blob/main/src/components/ui/Loading.tsx"
    click SkeletonCard "https://github.com/atzin-escandia/mindboard/blob/main/src/components/ui/SkeletonCard.tsx"
    click SkeletonMasonry "https://github.com/atzin-escandia/mindboard/blob/main/src/components/ui/SkeletonMasonry.tsx"
    click SkeletonDetail "https://github.com/atzin-escandia/mindboard/blob/main/src/components/SkeletonDetailCard.tsx"

    %% State Management
    subgraph "State Management" 
        FilterCtx["FilterContext\n(src/context/FilterContext.tsx)"]:::state
        ThemeCtx["ThemeContext\n(src/context/ThemeContext.tsx)"]:::state
    end

    SearchInput -->|updates search term| FilterCtx
    ThemeToggle -->|toggles theme| ThemeCtx
    click FilterCtx "https://github.com/atzin-escandia/mindboard/blob/main/src/context/FilterContext.tsx"
    click ThemeCtx "https://github.com/atzin-escandia/mindboard/blob/main/src/context/ThemeContext.tsx"

    %% Hooks & Virtualization Logic
    subgraph "Hooks & Virtualization" 
        Debounce["useDebounce\n(src/hooks/useDebounce.ts)"]:::state
        InfiniteScroll["useInfiniteScroll\n(src/hooks/useInfiniteScroll.ts)"]:::state
        MasonryCols["useMasonryColumns\n(src/hooks/useMasonryColumns.ts)"]:::state
        OnScreen["useOnScreen\n(src/hooks/useOnScreen.ts)"]:::state
    end

    SearchInput --> Debounce
    MasonryGrid --> InfiniteScroll
    MasonryGrid --> OnScreen
    MasonryGrid --> MasonryCols
    click Debounce "https://github.com/atzin-escandia/mindboard/blob/main/src/hooks/useDebounce.ts"
    click InfiniteScroll "https://github.com/atzin-escandia/mindboard/blob/main/src/hooks/useInfiniteScroll.ts"
    click MasonryCols "https://github.com/atzin-escandia/mindboard/blob/main/src/hooks/useMasonryColumns.ts"
    click OnScreen "https://github.com/atzin-escandia/mindboard/blob/main/src/hooks/useOnScreen.ts"

    %% Data Fetching Layer
    subgraph "Data Fetching Layer"
        APIClient["apiClient (Axios)\n(src/services/apiClient.ts)"]:::data
        UsePexels["usePexels (TanStack Query)\n(src/services/usePexels.ts)"]:::data
        EnvVars["Env Vars\n(.env.example)"]:::data
        click APIClient "https://github.com/atzin-escandia/mindboard/blob/main/src/services/apiClient.ts"
        click UsePexels "https://github.com/atzin-escandia/mindboard/blob/main/src/services/usePexels.ts"
        click EnvVars "https://github.com/atzin-escandia/mindboard/blob/main/.env.example"
    end

    FilterCtx --> UsePexels
    PhotoDetail --> UsePexels
    UsePexels --> APIClient
    APIClient -->|HTTP Request| PexelsAPI
    EnvVars --> APIClient

    %% External Service
    PexelsAPI["Pexels REST API"]:::external

    PexelsAPI -->|response| UsePexels
    UsePexels -->|cache| HomePage
    UsePexels -->|cache| PhotoDetail

    %% Models and Styles
    PhotoType["Photo Types\n(src/models/photoTypes.ts)"]:::data
    Styles["Global Styles\n(src/styles/index.css)"]:::presentation
    click PhotoType "https://github.com/atzin-escandia/mindboard/blob/main/src/models/photoTypes.ts"
    click Styles "https://github.com/atzin-escandia/mindboard/blob/main/src/styles/index.css"

    HomePage --> PhotoType
    PhotoDetail --> PhotoType
    Styles --> HomePage
    Styles --> PhotoDetail

    %% Build & Config
    ViteConfig["vite.config.ts"]:::data
    TSConfig["tsconfig*.json"]:::data
    PackageJSON["package.json"]:::data
    click ViteConfig "https://github.com/atzin-escandia/mindboard/blob/main/vite.config.ts"
    click TSConfig "https://github.com/atzin-escandia/mindboard/blob/main/tsconfig.json"
    click TSConfig "https://github.com/atzin-escandia/mindboard/blob/main/tsconfig.app.json"
    click TSConfig "https://github.com/atzin-escandia/mindboard/blob/main/tsconfig.node.json"
    click PackageJSON "https://github.com/atzin-escandia/mindboard/blob/main/package.json"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1B4F72,color:#000
    classDef state fill:#A9DFBF,stroke:#196F3D,color:#000
    classDef data fill:#F5B041,stroke:#B9770E,color:#000
    classDef external fill:#D7DBDD,stroke:#566573,color:#000
```
