# hmhhbi/blogcms architecture

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

- Interactive diagram: https://gitdiagram.com/hmhhbi/blogcms
- Repository: https://github.com/hmhhbi/blogcms

## Overview

BlogCMS is a Laravel REST API paired with a Next.js interface. Visitors browse posts and categories; registered users can manage content and comment, while admins have dashboard and moderation features. Laravel routes requests to authentication, post, category, and comment controllers, which use Eloquent models and resources to operate on blog data. The README documents the API-driven frontend and Sanctum authentication; sampled source confirms route dispatch and several controller-to-model/resource calls. Some frontend-to-API links are documented at a high level rather than shown in sampled frontend source.

Main entry points: [`backend/routes/api.php`](https://github.com/hmhhbi/blogcms/blob/main/backend/routes/api.php) (API route dispatch), [`backend/app/Models/Post.php`](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/Post.php) (Post model), [`backend/app/Http/Controllers/Api/PostController.php`](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/PostController.php) (Post operations), [`backend/app/Http/Controllers/Api/CommentController.php`](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/CommentController.php) (Comment moderation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js experience"]
  node_public_pages["Public pages"]
  node_blog_listing["Blog listing<br/>[page.js]"]
  node_post_card["Post cards<br/>[PostCard.js]"]
  node_post_detail["Post detail<br/>[PostContent.js]"]
  node_comment_ui["Comment interface<br/>[CommentSection.js]"]
  node_auth_pages["Login and registration"]
  node_admin_ui["Admin dashboard"]
  node_auth_guard["Route guard<br/>[AuthGuard.js]"]
end

subgraph group_api["Laravel API"]
  node_api_routes["API route dispatch<br/>[api.php]"]
  node_auth_controller["Authentication<br/>[AuthController.php]"]
  node_post_controller["Post operations<br/>[PostController.php]"]
  node_category_controller["Category operations"]
  node_comment_controller["Comment moderation"]
  node_post_resource["Post responses<br/>[PostResource.php]"]
  node_category_resource["Category responses"]
  node_comment_resource["Comment responses"]
end

subgraph group_domain["Blog domain"]
  node_post_model["Post model<br/>[Post.php]"]
  node_category_model["Category model<br/>[Category.php]"]
  node_comment_model["Comment model<br/>[Comment.php]"]
  node_user_model["User model<br/>[User.php]"]
end

subgraph group_integrations["External services"]
  node_database[("MySQL database")]
  node_cloudinary["Cloudinary media"]
end

node_visitor(("Visitor"))
node_member(("Signed-in member"))

node_visitor -->|"browses"| node_public_pages
node_public_pages -->|"includes"| node_blog_listing
node_blog_listing -->|"renders"| node_post_card
node_visitor -->|"signs up"| node_auth_pages
node_member -->|"manages content"| node_admin_ui
node_admin_ui -->|"protects routes"| node_auth_guard
node_member -->|"reads posts"| node_post_detail
node_post_detail -->|"renders"| node_comment_ui
node_public_pages -.->|"requests API data"| node_api_routes
node_auth_pages -.->|"authenticates via API"| node_api_routes
node_admin_ui -.->|"manages via API"| node_api_routes
node_api_routes -->|"routes auth"| node_auth_controller
node_api_routes -->|"routes posts"| node_post_controller
node_api_routes -->|"routes categories"| node_category_controller
node_api_routes -->|"routes comments"| node_comment_controller
node_auth_controller -->|"creates tokens"| node_user_model
node_post_controller -->|"queries and saves"| node_post_model
node_post_controller -->|"formats responses"| node_post_resource
node_category_controller -->|"queries and saves"| node_category_model
node_category_controller -->|"formats responses"| node_category_resource
node_comment_controller -->|"queries and saves"| node_comment_model
node_comment_controller -->|"attaches comments"| node_post_model
node_comment_controller -->|"formats responses"| node_comment_resource
node_post_resource -->|"embeds category"| node_category_resource
node_post_resource -->|"embeds comments"| node_comment_resource
node_post_controller -->|"uploads and deletes"| node_cloudinary
node_post_model -->|"belongs to"| node_category_model
node_post_model -->|"has author"| node_user_model
node_post_model -->|"has comments"| node_comment_model
node_comment_model -->|"belongs to"| node_user_model
node_post_model -.->|"persists records"| node_database
node_category_model -.->|"persists records"| node_database
node_comment_model -.->|"persists records"| node_database
node_user_model -.->|"persists accounts"| node_database

click node_public_pages "https://github.com/hmhhbi/blogcms/tree/main/frontend/src/app/(public)"
click node_blog_listing "https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/(public)/blogs/page.js"
click node_post_card "https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/(public)/components/PostCard.js"
click node_post_detail "https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/(public)/components/PostContent.js"
click node_comment_ui "https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/(public)/components/CommentSection.js"
click node_auth_pages "https://github.com/hmhhbi/blogcms/tree/main/frontend/src/app/(auth)"
click node_admin_ui "https://github.com/hmhhbi/blogcms/tree/main/frontend/src/app/(admin)"
click node_auth_guard "https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/components/AuthGuard.js"
click node_api_routes "https://github.com/hmhhbi/blogcms/blob/main/backend/routes/api.php"
click node_auth_controller "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/AuthController.php"
click node_post_controller "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/PostController.php"
click node_category_controller "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/CategoryController.php"
click node_comment_controller "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/CommentController.php"
click node_post_resource "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Resources/PostResource.php"
click node_category_resource "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Resources/CategoryResource.php"
click node_comment_resource "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Resources/CommentResource.php"
click node_post_model "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/Post.php"
click node_category_model "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/Category.php"
click node_comment_model "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/Comment.php"
click node_user_model "https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/User.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_pages,node_blog_listing,node_post_card,node_post_detail,node_comment_ui,node_auth_pages,node_admin_ui,node_auth_guard toneBlue
class node_api_routes,node_auth_controller,node_post_controller,node_category_controller,node_comment_controller,node_post_resource,node_category_resource,node_comment_resource toneAmber
class node_post_model,node_category_model,node_comment_model,node_user_model toneMint
class node_database,node_cloudinary toneRose
class node_visitor,node_member toneIndigo
```

## Components

### Next.js experience

- [Public pages](https://github.com/hmhhbi/blogcms/tree/main/frontend/src/app/(public)): `frontend/src/app/(public)`
- [Blog listing](https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/(public)/blogs/page.js): `frontend/src/app/(public)/blogs/page.js`
- [Post cards](https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/(public)/components/PostCard.js): `frontend/src/app/(public)/components/PostCard.js`
- [Post detail](https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/(public)/components/PostContent.js): `frontend/src/app/(public)/components/PostContent.js`
- [Comment interface](https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/(public)/components/CommentSection.js): `frontend/src/app/(public)/components/CommentSection.js`
- [Login and registration](https://github.com/hmhhbi/blogcms/tree/main/frontend/src/app/(auth)): `frontend/src/app/(auth)`
- [Admin dashboard](https://github.com/hmhhbi/blogcms/tree/main/frontend/src/app/(admin)): `frontend/src/app/(admin)`
- [Route guard](https://github.com/hmhhbi/blogcms/blob/main/frontend/src/app/components/AuthGuard.js): `frontend/src/app/components/AuthGuard.js`

### Laravel API

- [API route dispatch](https://github.com/hmhhbi/blogcms/blob/main/backend/routes/api.php): `backend/routes/api.php`
- [Authentication](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/AuthController.php): `backend/app/Http/Controllers/Api/AuthController.php`
- [Post operations](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/PostController.php): `backend/app/Http/Controllers/Api/PostController.php`
- [Category operations](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/CategoryController.php): `backend/app/Http/Controllers/Api/CategoryController.php`
- [Comment moderation](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Controllers/Api/CommentController.php): `backend/app/Http/Controllers/Api/CommentController.php`
- [Post responses](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Resources/PostResource.php): `backend/app/Http/Resources/PostResource.php`
- [Category responses](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Resources/CategoryResource.php): `backend/app/Http/Resources/CategoryResource.php`
- [Comment responses](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Http/Resources/CommentResource.php): `backend/app/Http/Resources/CommentResource.php`

### Blog domain

- [Post model](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/Post.php): `backend/app/Models/Post.php`
- [Category model](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/Category.php): `backend/app/Models/Category.php`
- [Comment model](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/Comment.php): `backend/app/Models/Comment.php`
- [User model](https://github.com/hmhhbi/blogcms/blob/main/backend/app/Models/User.php): `backend/app/Models/User.php`

### External services

- **MySQL database**
- **Cloudinary media**

### Other components

- **Visitor**
- **Signed-in member**

## Connections

- Visitor → Public pages: browses (evidence: `README.md`)
- Public pages → Blog listing: includes (evidence: `frontend/src/app/(public)/blogs/page.js`)
- Blog listing → Post cards: renders (evidence: `frontend/src/app/(public)/blogs/page.js`)
- Visitor → Login and registration: signs up (evidence: `README.md`)
- Signed-in member → Admin dashboard: manages content (evidence: `README.md`)
- Admin dashboard → Route guard: protects routes (evidence: `frontend/src/app/(admin)/layout.js`)
- Signed-in member → Post detail: reads posts (evidence: `README.md`)
- Post detail → Comment interface: renders (evidence: `frontend/src/app/(public)/components/PostContent.js`)
- Public pages → API route dispatch: requests API data (evidence: `README.md`)
- Login and registration → API route dispatch: authenticates via API (evidence: `README.md`)
- Admin dashboard → API route dispatch: manages via API (evidence: `README.md`)
- API route dispatch → Authentication: routes auth (evidence: `backend/routes/api.php`)
- API route dispatch → Post operations: routes posts (evidence: `backend/routes/api.php`)
- API route dispatch → Category operations: routes categories (evidence: `backend/routes/api.php`)
- API route dispatch → Comment moderation: routes comments (evidence: `backend/routes/api.php`)
- Authentication → User model: creates tokens (evidence: `backend/app/Http/Controllers/Api/AuthController.php`)
- Post operations → Post model: queries and saves (evidence: `backend/app/Http/Controllers/Api/PostController.php`)
- Post operations → Post responses: formats responses (evidence: `backend/app/Http/Controllers/Api/PostController.php`)
- Category operations → Category model: queries and saves (evidence: `backend/app/Http/Controllers/Api/CategoryController.php`)
- Category operations → Category responses: formats responses (evidence: `backend/app/Http/Controllers/Api/CategoryController.php`)
- Comment moderation → Comment model: queries and saves (evidence: `backend/app/Http/Controllers/Api/CommentController.php`)
- Comment moderation → Post model: attaches comments (evidence: `backend/app/Http/Controllers/Api/CommentController.php`)
- Comment moderation → Comment responses: formats responses (evidence: `backend/app/Http/Controllers/Api/CommentController.php`)
- Post responses → Category responses: embeds category (evidence: `backend/app/Http/Resources/PostResource.php`)
- Post responses → Comment responses: embeds comments (evidence: `backend/app/Http/Resources/PostResource.php`)
- Post operations → Cloudinary media: uploads and deletes (evidence: `backend/app/Http/Controllers/Api/PostController.php`)
- Post model → Category model: belongs to (evidence: `backend/app/Models/Post.php`)
- Post model → User model: has author (evidence: `backend/app/Models/Post.php`)
- Post model → Comment model: has comments (evidence: `backend/app/Models/Post.php`)
- Comment model → User model: belongs to (evidence: `backend/app/Models/Comment.php`)
- Post model → MySQL database: persists records (evidence: `README.md`)
- Category model → MySQL database: persists records (evidence: `README.md`)
- Comment model → MySQL database: persists records (evidence: `README.md`)
- User model → MySQL database: persists accounts (evidence: `README.md`)
