# sowdarjya/inkwell architecture

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

- Interactive diagram: https://gitdiagram.com/sowdarjya/inkwell
- Repository: https://github.com/sowdarjya/inkwell

## Overview

##### Project type and purpose
- InkWell is a full-stack blog platform: React + Redux on the client, Node.js/Express on the server, MongoDB for persistence, and Cloudinary for image storage. Users can sign up/in, create/update/delete posts, view by category, upvote, and manage profiles.

##### File structure
- Top-level “client” directory holds the React app:
- src/components and src/pages implement UI using functional components
- src/services/axios.instance.js and Redux Toolkit slices handle state and API calls
- “server” directory contains the Express app using an MVC-style layout:
- controllers handle business logic (post.controller.js, user.controller.js)
- routes define HTTP endpoints (post.routes.js, user.routes.js)
- models (Mongoose schemas) map to MongoDB collections
- middlewares (auth.middleware.js) enforce JWT authentication
- utils include Cloudinary integration and helpers
- Shared configuration files: eslint, Vite, Tailwind, package.json’s, .gitignore, DB connection script.

##### Key insights from README
- Uses React Router for navigation, Tailwind for styling
- Axios for HTTP requests, Redux Toolkit for state
- Express with JWT for API authentication, Cloudinary for media uploads

##### Main components and interactions
a. Frontend (React)
- UI Pages (Home, PostDetails, Profile, etc.)
- State Store (Redux Toolkit)
- HTTP Layer (Axios instance)
b. Backend (Express API)
- Route layer exposes /api/posts and /api/users endpoints
- Controller layer implements CRUD, upvotes
- Model layer (Mongoose) interacts with MongoDB
- Auth middleware checks JWTs
c. Database (MongoDB Atlas or local)
d. Media service (Cloudinary)
e. External clients (browser, mobile)

##### Architectural patterns and principles
- MVC pattern on server: separation of routing, controller logic, and data models
- Client-side component architecture: pages vs. reusable components
- Centralized state management with Redux
- RESTful API design
- Security and stateless auth via JWT middleware
- Third-party integration for media storage

##### Essential elements
- Clear labels on components (Frontend, API Gateway, Controllers, Models, DB, Cloudinary)
- Notes on authentication flow: login → receive JWT → attach to header
- Redux store interaction with UI components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (React + Redux)" 
        direction TB
        subgraph "Pages" 
            direction TB
            Home["Home.jsx"] 
            PostDetails["PostDetails.jsx"]
            CreatePost["CreatePost.jsx"]
            UpdatePost["UpdatePost.jsx"]
            Profile["Profile.jsx"]
            SignIn["SignIn.jsx"]
            SignUp["SignUp.jsx"]
        end
        subgraph "Components"
            direction TB
            Header["Header.jsx"]
            Footer["Footer.jsx"]
            Modal["Modal.jsx"]
            PostPreview["Post.jsx"]
            UserDetails["UserDetails.jsx"]
            UserPosts["UserPosts.jsx"]
        end
        subgraph "State & HTTP"
            direction TB
            Store["Store (Redux Toolkit)"]
            UserSlice["userSlice.js"]
            AxiosInstance["axios.instance.js"]
        end
        App["App.jsx"]
        Main["main.jsx"]
        CSS["index.css"]
    end

    %% Backend Layer
    subgraph "Backend (Node/Express + JWT)"
        direction TB
        Entry["index.js"]
        DBConn["db.js"]
        subgraph "Routes"
            direction TB
            PostRoutes["post.routes.js"]
            UserRoutes["user.routes.js"]
        end
        subgraph "Controllers"
            direction TB
            PostController["post.controller.js"]
            UserController["user.controller.js"]
        end
        subgraph "Models"
            direction TB
            PostModel["post.model.js"]
            UserModel["user.model.js"]
        end
        AuthMiddleware["auth.middleware.js"]
        subgraph "Utils"
            direction TB
            CloudinaryUtil["cloudinary.js"]
            Helpers["utils.js"]
        end
    end

    %% Database and External Service
    Database[(MongoDB)]
    Cloudinary((Cloudinary))

    %% Client Device
    Browser["Browser/Mobile"]

    %% Connections
    Browser -->|views| Home
    Browser -->|views| PostDetails
    Home -->|renders| Header
    Home -->|renders| Footer
    Home -->|renders| PostPreview
    Profile -->|renders| UserDetails
    Profile -->|renders| UserPosts

    Home -->|dispatches actions| Store
    SignIn -->|dispatches actions| Store
    SignUp -->|dispatches actions| Store

    Store -->|calls| AxiosInstance
    AxiosInstance -->|HTTPS requests| PostRoutes
    AxiosInstance -->|HTTPS requests| UserRoutes

    PostRoutes -->|calls| AuthMiddleware
    UserRoutes -->|calls| AuthMiddleware

    PostRoutes -->|invokes| PostController
    UserRoutes -->|invokes| UserController

    PostController -->|CRUD| PostModel
    UserController -->|CRUD| UserModel

    PostController -->|connects| Database
    UserController -->|connects| Database

    PostController -->|uploads images| CloudinaryUtil
    CloudinaryUtil -->|media storage| Cloudinary

    Entry -->|initializes| DBConn
    Entry -->|uses| PostRoutes
    Entry -->|uses| UserRoutes
    Entry -->|uses| AuthMiddleware

    %% Click Events - Frontend Pages
    click Home "https://github.com/sowdarjya/inkwell/blob/main/client/src/pages/Home.jsx"
    click PostDetails "https://github.com/sowdarjya/inkwell/blob/main/client/src/pages/PostDetails.jsx"
    click CreatePost "https://github.com/sowdarjya/inkwell/blob/main/client/src/pages/CreatePost.jsx"
    click UpdatePost "https://github.com/sowdarjya/inkwell/blob/main/client/src/pages/UpdatePost.jsx"
    click Profile "https://github.com/sowdarjya/inkwell/blob/main/client/src/pages/Profile.jsx"
    click SignIn "https://github.com/sowdarjya/inkwell/blob/main/client/src/pages/SignIn.jsx"
    click SignUp "https://github.com/sowdarjya/inkwell/blob/main/client/src/pages/SignUp.jsx"

    %% Click Events - Frontend Components
    click Header "https://github.com/sowdarjya/inkwell/blob/main/client/src/components/Header.jsx"
    click Footer "https://github.com/sowdarjya/inkwell/blob/main/client/src/components/Footer.jsx"
    click Modal "https://github.com/sowdarjya/inkwell/blob/main/client/src/components/Modal.jsx"
    click PostPreview "https://github.com/sowdarjya/inkwell/blob/main/client/src/components/Post.jsx"
    click UserDetails "https://github.com/sowdarjya/inkwell/blob/main/client/src/components/UserDetails.jsx"
    click UserPosts "https://github.com/sowdarjya/inkwell/blob/main/client/src/components/UserPosts.jsx"

    %% Click Events - Frontend State & HTTP
    click Store "https://github.com/sowdarjya/inkwell/blob/main/client/src/store/store.js"
    click UserSlice "https://github.com/sowdarjya/inkwell/blob/main/client/src/slices/userSlice.js"
    click AxiosInstance "https://github.com/sowdarjya/inkwell/blob/main/client/src/services/axios.instance.js"

    click App "https://github.com/sowdarjya/inkwell/blob/main/client/src/App.jsx"
    click Main "https://github.com/sowdarjya/inkwell/blob/main/client/src/main.jsx"
    click CSS "https://github.com/sowdarjya/inkwell/blob/main/client/src/index.css"

    %% Click Events - Backend
    click Entry "https://github.com/sowdarjya/inkwell/blob/main/server/src/index.js"
    click DBConn "https://github.com/sowdarjya/inkwell/blob/main/server/src/db/db.js"
    click PostController "https://github.com/sowdarjya/inkwell/blob/main/server/src/controllers/post.controller.js"
    click UserController "https://github.com/sowdarjya/inkwell/blob/main/server/src/controllers/user.controller.js"
    click PostRoutes "https://github.com/sowdarjya/inkwell/blob/main/server/src/routes/post.routes.js"
    click UserRoutes "https://github.com/sowdarjya/inkwell/blob/main/server/src/routes/user.routes.js"
    click PostModel "https://github.com/sowdarjya/inkwell/blob/main/server/src/models/post.model.js"
    click UserModel "https://github.com/sowdarjya/inkwell/blob/main/server/src/models/user.model.js"
    click AuthMiddleware "https://github.com/sowdarjya/inkwell/blob/main/server/src/middlewares/auth.middleware.js"
    click CloudinaryUtil "https://github.com/sowdarjya/inkwell/blob/main/server/src/utils/cloudinary.js"
    click Helpers "https://github.com/sowdarjya/inkwell/blob/main/server/src/utils/utils.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#DFFFE0,stroke:#228B22,color:#228B22
    classDef database fill:#FFE8B0,stroke:#FF8C00,color:#FF8C00
    classDef cloud fill:#E8D0FF,stroke:#800080,color:#800080

    class Frontend frontend
    class Home,PostDetails,CreatePost,UpdatePost,Profile,SignIn,SignUp,Header,Footer,Modal,PostPreview,UserDetails,UserPosts,Store,UserSlice,AxiosInstance,App,Main,CSS frontend
    class Entry,DBConn,PostRoutes,UserRoutes,PostController,UserController,PostModel,UserModel,AuthMiddleware,CloudinaryUtil,Helpers backend
    class Database database
    class Cloudinary cloud
```
