# leeddhh/dev-resource architecture

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

- Interactive diagram: https://gitdiagram.com/leeddhh/dev-resource
- Repository: https://github.com/leeddhh/dev-resource

## Overview

##### Main System Components

a. Frontend Layer:
- Next.js Client Application
- Apollo Client
- React Components (organized in layers: screen → parts → common → base)
- Storybook for component documentation
- TailwindCSS for styling

b. Backend Layer:
- Next.js API Routes
- Apollo Server
- GraphQL Schema and Resolvers
- Data Processing Utilities

c. Data Layer:
- JSON-based Data Storage (db.json, db_tags.json, db_origin.json)
- Image Assets Storage
- Tag Management System

##### Component Organization

- Blue: Core Application Components
- Components hierarchy (screen → parts → common → base)
- Hooks layer
- GraphQL operations

- Green: Data Processing Pipeline
- Content collection system
- Screenshot generation
- Image processing
- Tag management

- Orange: Development Tools
- Storybook
- Bundle analyzer
- Build trace analysis
- TypeScript types

- Client-Server communication via GraphQL
- Data processing pipeline flow
- Component hierarchy relationships
- Asset management flow

##### Integration Points

Integration with:
- Apollo Client/Server
- GraphQL schema and resolvers
- Image processing pipeline
- Tag management system

##### Architectural Patterns

Emphasize:
- Component-based architecture
- GraphQL-based data fetching
- Static site generation capabilities
- Client-side state management

**┌─ Client Layer ─────────────────────┐**
- Next.js Pages                    │
- React Components                 │
- Apollo Client                    │
- Hooks & Context                  │
- API Layer ──────────────────────┐ │
- GraphQL Schema                 │ │
- Apollo Server                  │ │
- Resolvers                      │ │
- Data Processing Layer ──────────┤ │
- Content Collection Pipeline    │ │
- Image Processing              │ │
- Tag Management               │ │
- Storage Layer ─────────────────┤ │
- JSON Data Files              │ │
- Image Assets                 │ │
- Tag Database                 │ │
- ┘

- Special markers for critical integration points

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef data fill:#e74c3c,color:white
    classDef tools fill:#f39c12,color:white
    classDef storage fill:#8e44ad,color:white

    %% Frontend Layer
    subgraph Frontend
        NextPages["Next.js Pages"]
        CompHierarchy["Component Hierarchy"]
        ApolloClient["Apollo Client"]
        StoryBook["Storybook"]
        TailwindCSS["TailwindCSS"]
        
        subgraph Components
            Screen["Screen Components"]
            Parts["Parts Components"]
            Common["Common Components"]
            Base["Base Components"]
            
            Screen --> Parts
            Parts --> Common
            Common --> Base
        end
        
        CompHierarchy --> Components
    end
    
    %% Backend Layer
    subgraph Backend
        ApolloServer["Apollo Server"]
        GraphQLSchema["GraphQL Schema"]
        Resolvers["Resolvers"]
        APIUtils["API Utilities"]
    end
    
    %% Data Processing Layer
    subgraph DataProcessing
        ContentCollection["Content Collection"]
        ScreenshotGen["Screenshot Generation"]
        ImageProcessing["Image Processing"]
        TagManagement["Tag Management"]
    end
    
    %% Data Storage Layer
    subgraph Storage
        MainDB["Main Database (db.json)"]
        TagsDB["Tags Database (db_tags.json)"]
        OriginDB["Origin Database (db_origin.json)"]
        TagCountDB["Tag Count Data"]
        ImageAssets["Image Assets"]
        Screenshots["Screenshots"]
    end
    
    %% State Management
    subgraph StateManagement
        CustomHooks["Custom Hooks"]
        LocalStorage["Local Storage"]
        SearchFunc["Search Functionality"]
        BookmarksMgmt["Bookmarks Management"]
    end
    
    %% Development Tools
    subgraph DevTools
        StorybookStories["Storybook Stories"]
        BuildAnalysis["Build Analysis"]
        Types["Types & Interfaces"]
    end
    
    %% Relationships
    ApolloClient <--> ApolloServer
    ApolloServer --> GraphQLSchema
    ApolloServer --> Resolvers
    ContentCollection --> MainDB
    TagManagement --> TagsDB
    ScreenshotGen --> Screenshots
    ImageProcessing --> ImageAssets
    
    %% Click Events
    click NextPages "https://github.com/LeeDDHH/dev-resource/tree/develop/pages"
    click Screen "https://github.com/LeeDDHH/dev-resource/tree/develop/components/screen"
    click Parts "https://github.com/LeeDDHH/dev-resource/tree/develop/components/parts"
    click Common "https://github.com/LeeDDHH/dev-resource/tree/develop/components/common"
    click Base "https://github.com/LeeDDHH/dev-resource/tree/develop/components/base"
    click ApolloClient "https://github.com/LeeDDHH/dev-resource/blob/develop/lib/apollo/apollo-client.ts"
    click StoryBook "https://github.com/LeeDDHH/dev-resource/blob/develop/.storybook"
    click TailwindCSS "https://github.com/LeeDDHH/dev-resource/blob/develop/tailwind.config.js"
    click Resolvers "https://github.com/LeeDDHH/dev-resource/blob/develop/apollo/resolvers.ts"
    click GraphQLSchema "https://github.com/LeeDDHH/dev-resource/blob/develop/apollo/schema.ts"
    click APIUtils "https://github.com/LeeDDHH/dev-resource/blob/develop/lib/api.ts"
    click MainDB "https://github.com/LeeDDHH/dev-resource/blob/develop/data/db.json"
    click TagsDB "https://github.com/LeeDDHH/dev-resource/blob/develop/data/db_tags.json"
    click OriginDB "https://github.com/LeeDDHH/dev-resource/blob/develop/data/db_origin.json"
    click TagCountDB "https://github.com/LeeDDHH/dev-resource/blob/develop/data/db_tagCount.json"
    click ImageAssets "https://github.com/LeeDDHH/dev-resource/tree/develop/public/images"
    click Screenshots "https://github.com/LeeDDHH/dev-resource/tree/develop/screenshots"
    click ContentCollection "https://github.com/LeeDDHH/dev-resource/blob/develop/lib/getArticleData.ts"
    click ScreenshotGen "https://github.com/LeeDDHH/dev-resource/blob/develop/lib/screenshot.ts"
    click ImageProcessing "https://github.com/LeeDDHH/dev-resource/blob/develop/lib/compressPng.mjs"
    click TagManagement "https://github.com/LeeDDHH/dev-resource/blob/develop/lib/getAllUniqueTagsFromDB.ts"
    click CustomHooks "https://github.com/LeeDDHH/dev-resource/tree/develop/hooks"
    click LocalStorage "https://github.com/LeeDDHH/dev-resource/blob/develop/hooks/useLocalStorage.ts"
    click SearchFunc "https://github.com/LeeDDHH/dev-resource/blob/develop/hooks/useSearchList.ts"
    click BookmarksMgmt "https://github.com/LeeDDHH/dev-resource/blob/develop/hooks/useLocalBookmarks.ts"
    click Types "https://github.com/LeeDDHH/dev-resource/tree/develop/types"
    click StorybookStories "https://github.com/LeeDDHH/dev-resource/tree/develop/stories"
    click BuildAnalysis "https://github.com/LeeDDHH/dev-resource/blob/develop/lib/nextjs/trace-to-tree.mjs"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Backend_L["Backend"]:::backend
        Data_L["Data"]:::data
        Tools_L["Tools"]:::tools
        Storage_L["Storage"]:::storage
    end
```
