# abhishek-ashyap/inkbytr architecture

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

- Interactive diagram: https://gitdiagram.com/abhishek-ashyap/inkbytr
- Repository: https://github.com/abhishek-ashyap/inkbytr

## Overview

##### Project Type and Purpose
- This is a full-stack MERN blogging platform called Inkbytr.
- Frontend: React + Vite + Tailwind + Shadcn/UI with Redux Toolkit for state, React Router for navigation, Axios for API calls.
- Backend: Node.js + Express monolith, MongoDB with Mongoose, JWT-based auth, role-based access control, email via SendGrid, security via Helmet and rate limiting.

##### File Structure
- Top-level “Client” and “Server” folders separate frontend and backend.
- Client/src: React app organized into pages, components, hooks, services, Redux slices, assets.
- Client/public & config files: Vite, ESLint, PostCSS, Tailwind, Vercel.
- Server: app.js/server.js entrypoints, config for environment, models, controllers (authController, postController), routes (auth, posts), middleware (auth, adminAuth, rateLimiter), utils (email, hash), tests.
- env examples and scripts in package.json for both.

##### Key Insights from README
- Secure JWT Authentication with email verification and password reset.
- Full CRUD on posts, nested comments, likes, RBAC (user vs. admin).
- Rate limiting, Helmet for security headers.
- Tech stack explicitly calls out major frameworks and services.

##### Main Components
a. Frontend SPA
- React app (Vite)
- State store (Redux Toolkit slices)
- UI layer (Shadcn/UI + Tailwind)
- Service layer (Axios wrappers: api.js, authService, postService)
b. Backend API
- Express server (app.js, server.js)
- Controllers (authController, postController)
- Routes (auth, posts)
- Middleware chain (Helmet, rateLimiter, authMiddleware, adminAuth)
- Business logic & utilities (email.js, hash.js)
c. Database
- MongoDB cluster (Atlas or local)
- Mongoose models (User, Post)
d. External Services
- SendGrid for transactional emails
- (Optional) Vercel hosting for frontend

##### Relationships & Interactions
- Frontend → Backend: HTTP/HTTPS REST calls to /api/auth, /api/posts with JWT in Authorization header.
- Backend → Database: Mongoose ODM performs CRUD on User and Post collections.
- Backend → SendGrid: Email API calls for verification and password reset.
- Data Flow:
1. User actions in UI dispatch Redux actions → thunk calls service → Axios request.
2. Express middleware validates JWT → controllers handle logic → Mongoose updates DB → response.
3. Frontend receives JSON, updates store, re-renders UI.

##### Architectural Patterns & Design Principles
- Frontend: Container/Presentational split (pages vs. components), Redux slice pattern.
- Backend: MVC-style layering—Routes → Controllers → Models (Mongoose).
- Security layers via middleware chain (Helmet, rate limiting, auth).
- RESTful API conventions.
- Role-based access control enforcement in middleware/controller.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        ReactIndex["main.jsx"]:::frontend
        App["App.jsx"]:::frontend
        Store["Redux Store"]:::frontend
        AuthSlice["authSlice.js"]:::frontend
        PostSlice["postSlice.js"]:::frontend
        UI["UI Components"]:::frontend
        TailwindConfig["tailwind.config.js"]:::frontend
        Presentational["Presentational Components"]:::frontend
        Pages["Pages / Containers"]:::frontend
        Routing["AppRoutes.jsx"]:::frontend
        Services["Service Layer (Axios)"]:::frontend
        UtilsFE["utils.js & useAuth.js"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        ExpressServer["Express Server"]:::api
        Middleware["Middleware Chain"]:::api
        Routes["Routes"]:::api
        Controllers["Controllers"]:::api
        UtilsBE["Utils (email, hash)"]:::api
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Models["Mongoose Models"]:::data
        MongoDB["MongoDB Cluster"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        EmailService["SendGrid Email API"]:::external
        Hosting["Vercel Hosting"]:::external
    end

    %% Connections
    ReactIndex --> App
    App --> Store
    Store --> AuthSlice
    Store --> PostSlice
    App --> UI
    App --> Presentational
    App --> Pages
    Pages --> Routing
    Pages --> Services
    Services --> UtilsFE
    App -->|"HTTP/HTTPS REST"| ExpressServer
    ExpressServer --> Middleware
    Middleware --> Routes
    Routes --> Controllers
    Controllers --> Models
    Controllers --> UtilsBE
    Controllers -->|"Send emails"| EmailService
    Models --> MongoDB
    App -->|"Hosted Static Files"| Hosting

    %% Click Events
    click ReactIndex "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/main.jsx"
    click App "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/App.jsx"
    click Store "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/app/store.js"
    click AuthSlice "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/app/slices/authSlice.js"
    click PostSlice "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/app/slices/postSlice.js"
    click UI "https://github.com/abhishek-ashyap/inkbytr/tree/main/Client/src/components/ui/"
    click TailwindConfig "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/tailwind.config.js"
    click Presentational "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/components/Layout.jsx"
    click Pages "https://github.com/abhishek-ashyap/inkbytr/tree/main/Client/src/pages/"
    click Routing "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/routes/AppRoutes.jsx"
    click Services "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/services/api.js"
    click UtilsFE "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/src/lib/utils.js"
    click ExpressServer "https://github.com/abhishek-ashyap/inkbytr/blob/main/Server/app.js"
    click ExpressServer "https://github.com/abhishek-ashyap/inkbytr/blob/main/Server/server.js"
    click Routes "https://github.com/abhishek-ashyap/inkbytr/blob/main/Server/routes/auth.js"
    click Controllers "https://github.com/abhishek-ashyap/inkbytr/blob/main/Server/controllers/authController.js"
    click Middleware "https://github.com/abhishek-ashyap/inkbytr/blob/main/Server/middleware/authMiddleware.js"
    click Models "https://github.com/abhishek-ashyap/inkbytr/blob/main/Server/models/User.js"
    click UtilsBE "https://github.com/abhishek-ashyap/inkbytr/blob/main/Server/utils/email.js"
    click EmailService "https://github.com/abhishek-ashyap/inkbytr/blob/main/Server/utils/email.js"
    click Hosting "https://github.com/abhishek-ashyap/inkbytr/blob/main/Client/vercel.json"

    %% Styles
    classDef frontend fill:#E0F2FE,stroke:#0284C7,stroke-width:1px
    classDef api fill:#ECFDF5,stroke:#10B981,stroke-width:1px
    classDef data fill:#FFFAEB,stroke:#F59E0B,stroke-width:1px
    classDef external fill:#F5F3FF,stroke:#8B5CF6,stroke-width:1px
```
