# baby-frog/froggy-blog-web architecture

> Architecture diagram of the GitHub repository baby-frog/froggy-blog-web, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/baby-frog/froggy-blog-web
- Repository: https://github.com/baby-frog/froggy-blog-web

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) “Froggy Blog” front end, built in React + TypeScript + Vite.
- It provides readers with story browsing and commenting, and authenticated users/admins with content creation, profile editing, and dashboard analytics.

##### High‐level file‐structure analysis
- Top‐level config: .eslintrc, tsconfig, vite.config.ts, tailwind.config.cjs, vercel.json → build & deploy setup.
- public + index.html → static entry point.
- src/
- main.tsx + App.tsx → React root and router initialization.
- pages/ + layouts/ + components/ → presentation layer (page‐level vs reusable).
- apis/ → service layer encapsulating HTTP calls to backend REST endpoints (auth, admin, stories, comments, likes, etc).
- contexts/ + hooks/ → global state & custom hooks.
- constants/, types/, schemas/ → type definitions, validation rules, and endpoint URIs.
- utils/ → HTTP client wrapper, formatting, error handling.
- No backend code here – this client talks to external API(s).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User (Browser)"]:::external
    CDN["CDN / Vercel"]:::external
    User -->|"HTTP GET/POST"| CDN

    subgraph "Froggy Blog SPA"
        subgraph "Entry & Routing"
            EntryHTML["index.html"]:::frontend
            MainTS["src/main.tsx"]:::frontend
            AppTS["src/App.tsx"]:::frontend
            ProtectedRoute["ProtectedRoute (src/routes/ProtectedRoute)"]:::frontend
            AdminRoute["AdminRoute (src/routes/AdminRoute)"]:::frontend
            RejectedRoute["RejectedRoute (src/routes/RejectedRoute)"]:::frontend
            EntryHTML --> MainTS --> AppTS
            AppTS --> ProtectedRoute
            AppTS --> AdminRoute
            AppTS --> RejectedRoute
        end

        subgraph "UI Layer"
            Pages["Pages (src/pages/)"]:::frontend
            Layouts["Layouts (src/layouts/)"]:::frontend
            Components["Reusable Components (src/components/)"]:::frontend
            TailwindCfg["tailwind.config.cjs"]:::config
            GlobalStyles["src/styles/globalStyles.ts"]:::config
            IndexScss["src/styles/index.scss"]:::config
            SCSSModules["SCSS Modules (e.g., TextEditor.scss)"]:::config
            Pages --> Layouts
            Layouts --> Components
            Components --> TailwindCfg
            Components --> GlobalStyles
            Components --> IndexScss
            Components --> SCSSModules
        end

        subgraph "State & Context"
            Contexts["Auth Context (src/contexts/auth.contexts.tsx)"]:::state
            Hooks["Custom Hooks (src/hooks/)"]:::state
            Contexts --> Hooks
        end

        subgraph "Service Layer"
            authAPI["auth.apis.ts"]:::service
            adminAPI["admin.apis.ts"]:::service
            storyAPI["story.apis.ts"]:::service
            commentsAPI["comments.api.ts"]:::service
            likeAPI["like.apis.ts"]:::service
            topicAPI["topic.apis.ts"]:::service
            chartAPI["chart.api.ts"]:::service
            imageAPI["image.apis.ts"]:::service
            HTTPClient["HTTP Client (src/utils/http.ts)"]:::service
            authAPI --> HTTPClient
            adminAPI --> HTTPClient
            storyAPI --> HTTPClient
            commentsAPI --> HTTPClient
            likeAPI --> HTTPClient
            topicAPI --> HTTPClient
            chartAPI --> HTTPClient
            imageAPI --> HTTPClient
        end

        subgraph "Data & Validation"
            Types["Types (src/types/)"]:::service
            Schemas["Schemas (src/schemas/)"]:::service
            Constants1["constants.ts"]:::service
            Constants2["endpoints.ts"]:::service
            Constants3["path.ts"]:::service
            Types --> Schemas
            Schemas --> Constants1
            Schemas --> Constants2
            Schemas --> Constants3
        end

        CDN --> EntryHTML
        AppTS --> Pages
        Pages --> Contexts
        Hooks --> authAPI
    end

    subgraph "External Services"
        ExternalAPI["Backend REST API"]:::external
        OAuth["OAuth Providers"]:::external
        ImageCDN["Image CDN"]:::external
        Analytics["Analytics/Tracking"]:::external
        authAPI --> ExternalAPI
        adminAPI --> ExternalAPI
        storyAPI --> ExternalAPI
        commentsAPI --> ExternalAPI
        likeAPI --> ExternalAPI
        topicAPI --> ExternalAPI
        chartAPI --> ExternalAPI
        imageAPI --> ImageCDN
        Analytics --> ExternalAPI
        OAuth --> ExternalAPI
    end

    click EntryHTML "https://github.com/baby-frog/froggy-blog-web/blob/main/index.html"
    click MainTS "https://github.com/baby-frog/froggy-blog-web/blob/main/src/main.tsx"
    click AppTS "https://github.com/baby-frog/froggy-blog-web/blob/main/src/App.tsx"
    click ProtectedRoute "https://github.com/baby-frog/froggy-blog-web/blob/main/src/routes/ProtectedRoute/ProtectedRoute.tsx"
    click AdminRoute "https://github.com/baby-frog/froggy-blog-web/blob/main/src/routes/AdminRoute/AdminRoute.tsx"
    click RejectedRoute "https://github.com/baby-frog/froggy-blog-web/blob/main/src/routes/RejectedRoute/RejectedRoute.tsx"
    click Pages "https://github.com/baby-frog/froggy-blog-web/tree/main/src/pages/"
    click Layouts "https://github.com/baby-frog/froggy-blog-web/tree/main/src/layouts/"
    click Components "https://github.com/baby-frog/froggy-blog-web/tree/main/src/components/"
    click TailwindCfg "https://github.com/baby-frog/froggy-blog-web/blob/main/tailwind.config.cjs"
    click GlobalStyles "https://github.com/baby-frog/froggy-blog-web/blob/main/src/styles/globalStyles.ts"
    click IndexScss "https://github.com/baby-frog/froggy-blog-web/blob/main/src/styles/index.scss"
    click Contexts "https://github.com/baby-frog/froggy-blog-web/blob/main/src/contexts/auth.contexts.tsx"
    click Hooks "https://github.com/baby-frog/froggy-blog-web/tree/main/src/hooks/"
    click authAPI "https://github.com/baby-frog/froggy-blog-web/blob/main/src/apis/auth.apis.ts"
    click adminAPI "https://github.com/baby-frog/froggy-blog-web/blob/main/src/apis/admin.apis.ts"
    click storyAPI "https://github.com/baby-frog/froggy-blog-web/blob/main/src/apis/story.apis.ts"
    click commentsAPI "https://github.com/baby-frog/froggy-blog-web/blob/main/src/apis/comments.api.ts"
    click likeAPI "https://github.com/baby-frog/froggy-blog-web/blob/main/src/apis/like.apis.ts"
    click topicAPI "https://github.com/baby-frog/froggy-blog-web/blob/main/src/apis/topic.apis.ts"
    click chartAPI "https://github.com/baby-frog/froggy-blog-web/blob/main/src/apis/chart.api.ts"
    click imageAPI "https://github.com/baby-frog/froggy-blog-web/blob/main/src/apis/image.apis.ts"
    click HTTPClient "https://github.com/baby-frog/froggy-blog-web/blob/main/src/utils/http.ts"
    click Types "https://github.com/baby-frog/froggy-blog-web/tree/main/src/types/"
    click Schemas "https://github.com/baby-frog/froggy-blog-web/tree/main/src/schemas/"
    click Constants1 "https://github.com/baby-frog/froggy-blog-web/blob/main/src/constants/constants.ts"
    click Constants2 "https://github.com/baby-frog/froggy-blog-web/blob/main/src/constants/endpoints.ts"
    click Constants3 "https://github.com/baby-frog/froggy-blog-web/blob/main/src/constants/path.ts"

    classDef frontend fill:#E0F7FA,stroke:#00796B,color:#004D40
    classDef state fill:#E8F5E9,stroke:#388E3C,color:#1B5E20
    classDef service fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#263238
    classDef config fill:#F3E5F5,stroke:#8E24AA,color:#4A148C
```
