# mustafakbaser/blogfolio-app architecture

> Architecture diagram of the GitHub repository mustafakbaser/blogfolio-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mustafakbaser/blogfolio-app
- Repository: https://github.com/mustafakbaser/blogfolio-app

## Overview

##### Project Identification
- BlogFolio is a single-page application (SPA) built with React 18 + TypeScript and styled via Tailwind CSS.
- It’s a front-end template (no back-end server by default) that renders blog posts and a portfolio from static data (`src/data/blogPosts.ts`) with future extensibility for a headless CMS or REST/GraphQL API.

##### Main Architectural Components
A. Browser / Client
- Renders `index.html` and downloads the SPA bundle.
- Interacts with the user and external services (Google Analytics, social share endpoints).
B. Vite Build & Dev Pipeline
- Vite Dev Server (serves modules during development)
- PostCSS + Tailwind CSS (style processing)
- TypeScript compiler (via `tsconfig.json`)
- ESLint, Prettier (linting)
- Final bundle deployed as static assets (Netlify / Vercel / CDN).
C. React App Core
- Entry point: `main.tsx` → `<App />` with Router.
- Routes: defined in pages (`Home`, `BlogPost`, `About`, `Portfolio`, `Contact`, `NotFound`).
D. UI Layer
- Page Components (`src/pages/*`)
- Reusable UI Components (`src/components/*`): cards, header/footer, filters, code blocks, theme toggle, cookie consent, pagination, SEO, social share, etc.
E. Data & State
- Static Data Module: `src/data/blogPosts.ts` (list of posts, categories, authors)
- Core Services: `src/lib/db.ts` + `src/lib/seed.ts` (data seeding logic if backed by a CMS)
- Custom Hooks (`src/hooks/*`): `usePost`, `useSearch`, `useCookieConsent`, `useDarkMode`
- Utils (`src/utils/*`): reading time estimation, markdown link parsing.
F. Types & Environment
- Type Definitions (`src/types/*`)
- Environment variables (`.env`, VITE_API_URL, VITE_GA_TRACKING_ID)

##### Relationships & Data Flow
- User Agent → HTTP GET `index.html` → Vite bundle delivered (Dev) or built assets (Prod).
- `main.tsx` initializes React Router → `<App />` loads the correct `<Page />`.
- `<Page />` uses Hooks to pull data from:
- Static file (`src/data/blogPosts.ts`) or
- Future: External API (Headless CMS) via environment URL.
- Data passed down via props to UI Components.
- User actions (e.g., search, pagination, theme switch) handled in Hooks → Component state.
- Side effects: analytics events to GA, cookie consent popup, social share APIs.

##### Architectural Patterns & Principles
- Component-based architecture (atomic/Re-usable).
- Unidirectional data flow (React props & hooks).
- Separation of concerns:
- Presentation (components) vs. data logic (hooks/lib) vs. utilities.
- Static vs. dynamic: static data layer today, abstracted for future API integration.

##### Essential Details to Capture
- Entire component hierarchy (high level; group similar ones).
- Data retrieval abstraction (static vs. API).
- Build & deployment flow.
- External service integrations (analytics, social share).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser / Client
    subgraph "Browser / Client"
        B["Browser / Client\n(index.html)"]:::frontend
    end

    %% Build & Dev Pipeline
    subgraph "Build & Dev Pipeline"
        VITE["Vite Dev Server\nvite.config.ts"]:::build
        TS["TypeScript Compiler\ntsconfig.json\n(tsconfig.app.json,\ntsconfig.node.json)"]:::build
        CSS["PostCSS + Tailwind\npostcss.config.js\ntailwind.config.js\nsrc/index.css"]:::build
        LINT["ESLint + Prettier\neslint.config.js\n.prettierrc"]:::build
        BUNDLE["Bundle → Static Assets"]:::build
    end

    %% React App Core
    subgraph "React App Core"
        MAIN["main.tsx"]:::frontend
        APP["App.tsx"]:::frontend
        ROUTER["React Router"]:::frontend
        subgraph Pages
            HOME["Home.tsx"]:::frontend
            BLOGPOST["BlogPost.tsx"]:::frontend
            ABOUT["About.tsx"]:::frontend
            PORTFOLIO["Portfolio.tsx"]:::frontend
            CONTACT["Contact.tsx"]:::frontend
            NOTFOUND["NotFound.tsx"]:::frontend
        end
    end

    %% UI Layer
    subgraph "UI Layer"
        COMPONENTS["Reusable UI Components\nsrc/components/*"]:::frontend
    end

    %% Data & State
    subgraph "Data & State"
        DATASTORE["Static Data Store\nblogPosts.ts"]:::data
        DB["DB Abstraction\nlib/db.ts\nlib/seed.ts"]:::data
        subgraph Hooks
            USEPOST["usePost.ts"]:::hook
            USESEARCH["useSearch.ts"]:::hook
            USECOOKIE["useCookieConsent.ts"]:::hook
            USEDARK["useDarkMode.ts"]:::hook
        end
        subgraph Utils
            PARSEMD["parseMarkdownLinks.tsx"]:::hook
            READING["readingTime.ts"]:::hook
        end
    end

    %% Types & Environment
    subgraph "Types & Environment"
        TYPES["Type Definitions\nsrc/types/*"]:::data
        VITEENV["vite-env.d.ts\n.env variables"]:::data
    end

    %% External Services
    subgraph "External Services"
        GA["Google Analytics"]:::external
        SOCIAL["Social Share APIs"]:::external
        CMS["Future Headless CMS (API)"]:::external
    end

    %% Relationships
    B -->|"GET index.html"| MAIN
    MAIN -->|"render App"| APP
    APP -->|"init Router"| ROUTER
    ROUTER --> HOME
    ROUTER --> BLOGPOST
    ROUTER --> ABOUT
    ROUTER --> PORTFOLIO
    ROUTER --> CONTACT
    ROUTER --> NOTFOUND

    HOME -->|"props"| COMPONENTS
    BLOGPOST -->|"props"| COMPONENTS
    ABOUT -->|"props"| COMPONENTS
    PORTFOLIO -->|"props"| COMPONENTS
    CONTACT -->|"props"| COMPONENTS
    NOTFOUND -->|"props"| COMPONENTS

    COMPONENTS -->|"use hooks"| USEPOST
    COMPONENTS -->|"use hooks"| USESEARCH
    COMPONENTS -->|"use hooks"| USECOOKIE
    COMPONENTS -->|"use hooks"| USEDARK

    USEPOST -->|"reads"| DATASTORE
    USESEARCH -->|"reads"| DATASTORE
    USEPOST -->|"fallback"| CMS
    USESEARCH -->|"fallback"| CMS

    COMPONENTS -->|"utils"| PARSEMD
    COMPONENTS -->|"utils"| READING

    COMPONENTS -->|"event"| GA
    COMPONENTS -->|"call"| SOCIAL

    TS --> VITE
    CSS --> VITE
    LINT --> VITE
    VITE --> BUNDLE
    BUNDLE -->|"deploy"| B

    %% Click Events
    click B "https://github.com/mustafakbaser/blogfolio-app/blob/main/index.html"
    click VITE "https://github.com/mustafakbaser/blogfolio-app/blob/main/vite.config.ts"
    click TS "https://github.com/mustafakbaser/blogfolio-app/blob/main/tsconfig.json"
    click CSS "https://github.com/mustafakbaser/blogfolio-app/blob/main/postcss.config.js"
    click CSS "https://github.com/mustafakbaser/blogfolio-app/blob/main/tailwind.config.js"
    click CSS "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/index.css"
    click LINT "https://github.com/mustafakbaser/blogfolio-app/blob/main/eslint.config.js"
    click LINT "https://github.com/mustafakbaser/blogfolio-app/blob/main/.prettierrc"
    click MAIN "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/main.tsx"
    click APP "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/App.tsx"
    click HOME "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/pages/Home.tsx"
    click BLOGPOST "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/pages/BlogPost.tsx"
    click ABOUT "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/pages/About.tsx"
    click PORTFOLIO "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/pages/Portfolio.tsx"
    click CONTACT "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/pages/Contact.tsx"
    click NOTFOUND "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/pages/NotFound.tsx"
    click COMPONENTS "https://github.com/mustafakbaser/blogfolio-app/tree/main/src/components"
    click DATASTORE "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/data/blogPosts.ts"
    click DB "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/lib/db.ts"
    click DB "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/lib/seed.ts"
    click USEPOST "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/hooks/usePost.ts"
    click USESEARCH "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/hooks/useSearch.ts"
    click USECOOKIE "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/hooks/useCookieConsent.ts"
    click USEDARK "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/hooks/useDarkMode.ts"
    click PARSEMD "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/utils/parseMarkdownLinks.tsx"
    click READING "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/utils/readingTime.ts"
    click TYPES "https://github.com/mustafakbaser/blogfolio-app/tree/main/src/types"
    click VITEENV "https://github.com/mustafakbaser/blogfolio-app/blob/main/src/vite-env.d.ts"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#42A5F5,stroke-width:1px
    classDef hook fill:#E8F5E9,stroke:#66BB6A,stroke-width:1px
    classDef data fill:#F1F8E9,stroke:#8BC34A,stroke-width:1px
    classDef build fill:#ECEFF1,stroke:#78909C,stroke-width:1px
    classDef external fill:#FFF9C4,stroke:#FFEE58,stroke-width:1px
```
