# adeeltahir-se/personal-blogs architecture

> Architecture diagram of the GitHub repository adeeltahir-se/personal-blogs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adeeltahir-se/personal-blogs
- Repository: https://github.com/adeeltahir-se/personal-blogs

## Overview

##### Project Type and Purpose
- This is a full-stack Personal Blog Application.
- Frontend: React (Vite, JSX, TailwindCSS) serving public Guest and Admin UIs.
- Backend: Node.js/Express providing a REST API, basic file-based data store (JSON files), and authentication.

##### File Structure Analysis
- Top-level: “index.html”, “public/” (static assets), “src/” (React code), build/config files (package.json, vite.config.js, tailwind.config.js, postcss.config.js).
- src/ breaks into two feature areas:
- Admin (Login.jsx, Dashboard.jsx, Add.jsx, Edit.jsx)
- Guest (Home.jsx, Article.jsx)
- backend/: Express server files (server.js, router.js, authentication.js) and JSON files acting as the database (users.json, db.json, log.json).
- Config: eslint.config.js for linting, package.json/package-lock.json for dependencies.

##### Key Insights from README
- Admin user flow: login → CRUD blog posts → view posts.
- Guest user flow: browse published posts.
- No external DB; uses local JSON files.

a. Main Components
- Browser (Guest/Admin UI)
- Frontend App (React + Vite)
- Backend API Server (Express)
- File-based Data Store (db.json, users.json, log.json)
- Authentication Module (authentication.js)
- Router (router.js)
b. Interactions/Data Flow
1. Browser sends HTTP(S) requests to Frontend via Vite dev server or served static build.
2. Frontend makes REST calls (fetch/axios) to Backend API endpoints.
3. Backend → authentication.js validates credentials against users.json.
4. router.js directs requests:
- CRUD on blog posts ↔ db.json
- Logging actions → log.json
5. Responses propagate back to Frontend for UI updates.
c. Architectural Patterns & Principles
- MVC-light: router (Controller) → JSON data (Model) → Express responses (View).
- Single-Page Application (SPA) for front-end, RESTful API for server.
- Separation of concerns: UI, API, Data Storage.
d. Key Technologies
- React (+JSX)
- Vite Dev/Build
- TailwindCSS
- Node.js + Express
- JSON-based file datastore

## Diagram (Mermaid)

```mermaid
graph TB
    %% Browser
    Browser["Browser (Guest/Admin)"]:::external

    %% Frontend Layer
    subgraph "Frontend (UI)" 
        direction TB
        ReactApp["React SPA"]:::ui
        subgraph "Admin Module" 
            direction TB
            Login["Login.jsx"]:::ui
            Dashboard["Dashboard.jsx"]:::ui
            AddPost["Add.jsx"]:::ui
            EditPost["Edit.jsx"]:::ui
        end
        subgraph "Guest Module" 
            direction TB
            Home["Home.jsx"]:::ui
            Article["Article.jsx"]:::ui
        end
        subgraph "Shared Assets & Utils"
            direction TB
            Globals1["index.css"]:::ui
            Globals2["App.css"]:::ui
            Functions["functions.js"]:::ui
            Assets["public/ & src/assets/"]:::ui
        end
        ReactApp --> Login
        ReactApp --> Dashboard
        ReactApp --> AddPost
        ReactApp --> EditPost
        ReactApp --> Home
        ReactApp --> Article
        ReactApp --> Globals1
        ReactApp --> Globals2
        ReactApp --> Functions
        ReactApp --> Assets
    end

    %% Build Tools
    subgraph "Build & Config" 
        direction TB
        ViteConfig["vite.config.js"]:::tool
        HTML["index.html"]:::tool
        TailwindConfig["tailwind.config.js"]:::tool
        PostCSS["postcss.config.js"]:::tool
    end

    %% Backend Layer
    subgraph "Backend (API Server)"
        direction TB
        Server["server.js"]:::api
        Router["router.js"]:::api
        Auth["authentication.js"]:::api
        PackageBackend["package.json"]:::tool
    end

    %% Data Store
    subgraph "Data Store (JSON Files)"
        direction TB
        UsersDB["users.json"]:::data
        PostsDB["db.json"]:::data
        LogsDB["log.json"]:::data
    end

    %% Connections
    Browser -->|"loads UI"| HTML
    HTML -->|"serves React App"| ReactApp
    ReactApp -->|"REST API calls"| Server
    Server -->|"routes requests"| Router
    Server -->|"auth logic"| Auth
    Router -->|"CRUD posts"| PostsDB
    Router -->|"log actions"| LogsDB
    Auth -->|"validate credentials"| UsersDB
    PackageBackend --> Server

    %% Click Events
    click ReactApp "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/App.jsx"
    click ReactApp "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/main.jsx"
    click Globals1 "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/index.css"
    click Globals2 "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/App.css"
    click Login "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/Admin/Login.jsx"
    click Dashboard "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/Admin/Dashboard.jsx"
    click AddPost "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/Admin/Add.jsx"
    click EditPost "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/Admin/Edit.jsx"
    click Home "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/Guest/Home.jsx"
    click Article "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/Guest/Article.jsx"
    click Functions "https://github.com/adeeltahir-se/personal-blogs/blob/main/src/components/functions.js"
    click Assets "https://github.com/adeeltahir-se/personal-blogs/tree/main/public/"
    click Assets "https://github.com/adeeltahir-se/personal-blogs/tree/main/src/assets/"
    click ViteConfig "https://github.com/adeeltahir-se/personal-blogs/blob/main/vite.config.js"
    click HTML "https://github.com/adeeltahir-se/personal-blogs/blob/main/index.html"
    click TailwindConfig "https://github.com/adeeltahir-se/personal-blogs/blob/main/tailwind.config.js"
    click PostCSS "https://github.com/adeeltahir-se/personal-blogs/blob/main/postcss.config.js"
    click Server "https://github.com/adeeltahir-se/personal-blogs/blob/main/backend/server.js"
    click Router "https://github.com/adeeltahir-se/personal-blogs/blob/main/backend/router.js"
    click Auth "https://github.com/adeeltahir-se/personal-blogs/blob/main/backend/authentication.js"
    click UsersDB "https://github.com/adeeltahir-se/personal-blogs/blob/main/backend/users.json"
    click PostsDB "https://github.com/adeeltahir-se/personal-blogs/blob/main/backend/db.json"
    click LogsDB "https://github.com/adeeltahir-se/personal-blogs/blob/main/backend/log.json"
    click PackageBackend "https://github.com/adeeltahir-se/personal-blogs/blob/main/backend/package.json"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef api fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
    classDef tool fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#ffffff,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
