# bhargav007dobhal/post-flow-blog-website- architecture

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

- Interactive diagram: https://gitdiagram.com/bhargav007dobhal/post-flow-blog-website-
- Repository: https://github.com/bhargav007dobhal/post-flow-blog-website-

## Overview

##### Project type and purpose
- This is a full-stack blog platform (“Post Flow”) with a React SPA frontend and a Node.js/Express RESTful backend.
- Core features: user registration & login (JWT), CRUD operations on posts, comments, image uploads (via Multer), and a MySQL relational database.

##### File structure
- Top-level directories:
- backend/ – Node.js/Express API (controllers/, middleware/, models/, routes/, Uploads/)
- frontend/ – React app (components/, pages/, context/, services/)
- Key config files: .env (DB & JWT secrets), package.json in both layers, tailwind.config.js for styling
- Architectural cues:
- Backend MVC pattern (models/db.js, controllers/*, routes/*)
- Frontend component-based UI + context for auth state + service layer for HTTP (axios)

##### README for additional insights
- Confirms tech stack: MySQL, Node.js, Express, React, Tailwind CSS, JWT auth
- Describes database schema (users, posts, comments, likes)
- Deployment hints: Express serves API and static /uploads folder; React runs on localhost:3000

##### Detailed capture of architectural elements
- Major React page (Home, Profile, CreatePost) as sub-components under UI.
- Context provider wrapping the React tree.
- Data flow for CRUD operations and authentication.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Client (Browser & Frontend)" 
        classDef frontend fill:#e0ffe0,stroke:#333,stroke-width:1px
        Browser["Browser"]:::frontend
        Entry["React Entry Point\n(index.js)"]:::frontend
        AuthCtx["AuthContext"]:::frontend
        APIService["API Service"]:::frontend
        subgraph "UI Components & Pages"
            classDef ui fill:#d0ffd0,stroke:#333,stroke-width:1px
            Navbar["Navbar"]:::ui
            Home["Home Page"]:::ui
            Profile["Profile Page"]:::ui
            CreatePost["CreatePost Page"]:::ui
            PostDetail["PostDetail Page"]:::ui
            Login["Login Page"]:::ui
            Register["Register Page"]:::ui
        end
        TailwindConfig["Tailwind Config"]:::frontend
        StaticPublic["Static Public Assets\n(public/index.html)"]:::frontend
    end

    %% Backend Layer
    subgraph "Server (Backend)"
        classDef backend fill:#e0f0ff,stroke:#333,stroke-width:1px
        Server["Express Server\n(server.js)"]:::backend
        EnvConfig["Env Config\n(.env.example)"]:::backend
        subgraph "Routes"
            AuthRoutes["Auth Routes\n(auth.js)"]:::backend
            PostRoutes["Post Routes\n(posts.js)"]:::backend
        end
        AuthMiddleware["Auth Middleware\n(auth.js)"]:::backend
        subgraph "Controllers"
            AuthController["AuthController\n(authController.js)"]:::backend
            PostController["PostController\n(postController.js)"]:::backend
        end
        DBModel["DB Connection\n(db.js)"]:::backend
        UploadsFolder["Uploads Folder"]:::storage
    end

    %% Database & Storage
    subgraph "Data Storage"
        classDef db fill:#ffe0e0,stroke:#333,stroke-width:1px
        MySQL["MySQL Database"]:::db
    end

    classDef storage fill:#fff0e0,stroke:#333,stroke-width:1px

    %% Connections
    Browser --> Entry
    Entry --> AuthCtx
    Entry --> APIService
    Entry --> Navbar
    NavComp["UI"] --> Home
    AuthCtx --> APIService
    APIService -->|"/api/auth, /api/posts"| AuthRoutes
    APIService -->|"/api/posts"| PostRoutes

    AuthRoutes --> AuthMiddleware
    PostRoutes --> AuthMiddleware
    AuthMiddleware --> AuthController
    AuthMiddleware --> PostController
    AuthController --> DBModel
    PostController --> DBModel
    DBModel --> MySQL

    Entry --> StaticPublic

    %% File Upload Flow
    CreatePost --> APIService
    APIService --> PostRoutes
    PostRoutes --> UploadsFolder
    UploadsFolder -->|static serve| Browser

    %% Click Events
    click Entry "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/index.js"
    click AuthCtx "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/context/AuthContext.js"
    click APIService "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/services/api.js"
    click Navbar "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/components/Navbar.js"
    click Home "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/pages/Home.js"
    click Profile "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/pages/Profile.js"
    click CreatePost "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/pages/CreatePost.js"
    click PostDetail "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/pages/PostDetail.js"
    click Login "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/pages/Login.js"
    click Register "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/src/pages/Register.js"
    click TailwindConfig "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/tailwind.config.js"
    click StaticPublic "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/public/index.html"
    click Server "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/backend/server.js"
    click EnvConfig "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/backend/.env.example"
    click AuthController "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/backend/controllers/authController.js"
    click PostController "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/backend/controllers/postController.js"
    click AuthMiddleware "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/backend/middleware/auth.js"
    click DBModel "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/backend/models/db.js"
    click AuthRoutes "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/backend/routes/auth.js"
    click PostRoutes "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/backend/routes/posts.js"
    click StaticPublic "https://github.com/bhargav007dobhal/post-flow-blog-website-/blob/master/frontend/public/index.html"

    %% Styles
    class Browser,Entry,AuthCtx,APIService,TailwindConfig,StaticPublic frontend
    class Navbar,Home,Profile,CreatePost,PostDetail,Login,Register ui
    class Server,EnvConfig,AuthRoutes,PostRoutes,AuthMiddleware,AuthController,PostController,DBModel backend
    class UploadsFolder storage
    class MySQL db
```
