# yash1hingu/yashblog architecture

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

- Interactive diagram: https://gitdiagram.com/yash1hingu/yashblog
- Repository: https://github.com/yash1hingu/yashblog

## Overview

##### Client Layer Components
- Core Components:
- Use a rectangle labeled "React Application"
- Sub-components:
- Pages (LoginPage, RegisterPage, CreatePost, etc.)
- UI Components (Header, Layout, Posts)
- Context Providers (UserContext, UserProgressContext)
- Hooks (useInput)

##### API Layer Components
- Main API Server (Express.js)
- Authentication Middleware
- Route Handlers:
- User Routes
- Post Routes
- Upload Handler
- JWT Authentication Service

##### Data Layer
- MongoDB Database
- Models:
- User Model
- Post Model
- File Storage (uploads directory)

##### Connection Flows
- API calls between frontend and backend
- Database operations
- Authentication flows
- File upload paths

- Blue: Frontend components
- Green: API services
- Yellow: Database components
- Red: Authentication flows
- Purple: File storage

Specific Implementation Details:

##### Frontend Section
**[React Application]**
- Public Routes
- Landing Page
- Login
- Register
- Protected Routes
- Home
- Create Post
- Edit Post
- User Profile
- Shared Components
- UI Elements
- Context Providers

##### Backend Section
**[Express.js Server]**
- Authentication
- JWT Service
- Middleware
- Routes
- User Routes
- Post Routes
- Upload Routes
- Models
- User
- Post

- RESTful API calls between frontend and backend
- JWT token flow for authentication
- File upload paths
- Database operations

Important Elements to Include:

##### External Services
- Social Media Sharing Integration
- Image Upload Service

##### Security Layer
- JWT Authentication
- Protected Routes
- Password Encryption

##### Key Features
- CRUD Operations for Posts
- User Authentication
- File Upload System
- Social Sharing

##### Technical Stack Indicators
- MongoDB
- Express.js
- React.js
- Node.js
- Tailwind CSS

Remember to:
- Keep components proportional to their importance
- Use clear, consistent labeling
- Primary and secondary data flows
- Error handling paths
- Security boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        RA["React Application"]
        click RA "https://github.com/Yash1Hingu/yashblog/tree/main/client/src/"
        
        subgraph Pages
            LP["Login Page"]
            click LP "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/pages/LoginPage.js"
            RP["Register Page"]
            click RP "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/pages/RegisterPage.js"
            CP["Create Post"]
            click CP "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/pages/CreatePost.js"
            EP["Edit Post"]
            click EP "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/pages/EditPostPage.js"
            UP["User Profile"]
            click UP "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/pages/UserPage.js"
        end

        subgraph UIComponents
            HD["Header"]
            click HD "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/Header.js"
            LY["Layout"]
            click LY "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/Layout.js"
            PC["Post Component"]
            click PC "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/Post.js"
            CD["Card"]
            click CD "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/UI/Card.js"
            PL["Posts List"]
            click PL "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/UI/Posts.js"
        end

        subgraph Context
            UC["User Context"]
            click UC "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/store/user-context.js"
            UPC["User Progress Context"]
            click UPC "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/store/UserProgressContext.js"
        end

        subgraph Hooks
            IH["Input Hook"]
            click IH "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/components/hooks/useInput.js"
        end

        subgraph Utils
            VU["Validation Utils"]
            click VU "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/util/validation.js"
            PU["Path Utils"]
            click PU "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/util/path.js"
            TU["Tags Utils"]
            click TU "https://github.com/Yash1Hingu/yashblog/blob/main/client/src/util/tags.js"
        end
    end

    subgraph API
        ES["Express Server"]
        click ES "https://github.com/Yash1Hingu/yashblog/blob/main/api/index.js"
        
        subgraph Auth
            JWT["JWT Service"]
            AM["Auth Middleware"]
        end

        subgraph Routes
            UR["User Routes"]
            PR["Post Routes"]
            UPR["Upload Routes"]
        end
    end

    subgraph Data
        DB[(MongoDB)]
        
        subgraph Models
            UM["User Model"]
            click UM "https://github.com/Yash1Hingu/yashblog/blob/main/api/models/User.js"
            PM["Post Model"]
            click PM "https://github.com/Yash1Hingu/yashblog/blob/main/api/models/Post.js"
        end

        FS["File Storage"]
        click FS "https://github.com/Yash1Hingu/yashblog/tree/main/api/uploads/"
    end

    %% Connections
    RA --> ES
    ES --> DB
    ES --> FS
    Routes --> Models
    Auth --> Routes

    %% Styling
    classDef frontend fill:#a8d1ff
    classDef api fill:#98ff98
    classDef database fill:#ffeb99
    classDef auth fill:#ff9999
    classDef storage fill:#dda0dd

    class RA,Pages,UIComponents,Context,Hooks,Utils frontend
    class ES,Routes,Auth api
    class DB,Models database
    class JWT,AM auth
    class FS storage

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        A[API]:::api
        D[Database]:::database
        AU[Auth]:::auth
        S[Storage]:::storage
    end
```
