# sandeep-poudel/blogappwithmysql architecture

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

- Interactive diagram: https://gitdiagram.com/sandeep-poudel/blogappwithmysql
- Repository: https://github.com/sandeep-poudel/blogappwithmysql

## Overview

##### Main Components
- Frontend Application – Built with React and TypeScript. Contains pages (e.g., Home, About, BlogPage, CreatePage) and reusable components (e.g., NavBar, Footer, Card, AuthorCard).
- Backend Server – A Node.js/Express server with components such as controllers (e.g., blogsController), models (e.g., Blogs), routes (e.g., blogRoutes), configuration files (db.ts) and utility functions.
- MySQL Database – The central data store where blog posts and related data are held.

##### Relationships and Interactions
- That the frontend communicates with the backend through HTTP REST API endpoints.
- The backend relies on its internal modular architecture for routing incoming requests to the appropriate controllers and then performing data queries using the models and database configuration.

##### Architectural Patterns and Design Elements
- Separation of concerns: UI components (frontend) interact via an API layer managed by the backend.
- The backend structure hints at a layered architecture where the routing, controller, model, and utilities handle different aspects of a request.
- Use of reusable components on the frontend to promote consistency.
- That dependency injection (or similar patterns) may be used to keep modules decoupled.

##### Extra Notes
- Don’t overcomplicate—start with broad strokes (the three major tiers) and then include additional details as necessary.
- Component’s role, dependencies, and interactions are clearly visible.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        subgraph "Pages"
            FE_Pages["Frontend Pages (Home,About,BlogPage,CreatePage)"]:::frontend
        end
        subgraph "Components"
            FE_Components["Frontend Components (NavBar,Footer,Card,AuthorCard, etc.)"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend"
        BE_Entry["Backend Entry (server.ts)"]:::backend
        BE_Config["Configurations (db.ts)"]:::backend
        BE_Routes["Routes (blogRoutes.ts)"]:::backend
        BE_Controller["Controllers (blogsController.ts)"]:::backend
        BE_Models["Models (Blogs.ts)"]:::backend
        BE_Utils["Utilities (textCapitalize.ts)"]:::backend
    end

    %% Database Component
    DB(("MySQL Database")):::database

    %% Connections between Frontend and Backend
    FE_Pages -->|"HTTPRequests"| BE_Routes

    %% Internal Backend connections
    BE_Entry -->|"Initializes"| BE_Routes
    BE_Entry -->|"Configures"| BE_Config
    BE_Routes -->|"Dispatches"| BE_Controller
    BE_Controller -->|"Queries"| BE_Models
    BE_Controller -->|"Formats/Validates"| BE_Utils

    %% Backend to Database connections
    BE_Config -->|"DBConnection"| DB
    BE_Models -->|"DataQueries"| DB

    %% Click Events for Component Mapping
    click FE_Pages "https://github.com/sandeep-poudel/blogappwithmysql/tree/main/frontend/src/pages"
    click FE_Components "https://github.com/sandeep-poudel/blogappwithmysql/tree/main/frontend/src/components"
    click BE_Entry "https://github.com/sandeep-poudel/blogappwithmysql/blob/main/backend/src/server.ts"
    click BE_Config "https://github.com/sandeep-poudel/blogappwithmysql/blob/main/backend/src/configs/db.ts"
    click BE_Routes "https://github.com/sandeep-poudel/blogappwithmysql/blob/main/backend/src/routes/blogRoutes.ts"
    click BE_Controller "https://github.com/sandeep-poudel/blogappwithmysql/blob/main/backend/src/controllers/blogsController.ts"
    click BE_Models "https://github.com/sandeep-poudel/blogappwithmysql/blob/main/backend/src/models/Blogs.ts"
    click BE_Utils "https://github.com/sandeep-poudel/blogappwithmysql/blob/main/backend/src/utils/textCapitalize.ts"

    %% Styles
    classDef frontend fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef backend fill:#87CEEB,stroke:#333,stroke-width:2px;
    classDef database fill:#C1FFC1,stroke:#333,stroke-width:2px;
```
