# enes-sen/backend-blog architecture

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

- Interactive diagram: https://gitdiagram.com/enes-sen/backend-blog
- Repository: https://github.com/enes-sen/backend-blog

## Overview

This is a small Express/Mongoose blog API. Clients send post and comment requests through the router; controllers perform CRUD operations through Post and Comment models and return JSON responses. Comments are associated with posts, and the server connects to MongoDB before listening. The excerpts show route dispatch, controller-to-model calls, and connection setup; they do not show the database’s runtime behavior beyond that connection.

Main entry points: [`router/routes.js`](https://github.com/enes-sen/backend-blog/blob/main/router/routes.js) (API routes), [`controllers/comentcontroller.js`](https://github.com/enes-sen/backend-blog/blob/main/controllers/comentcontroller.js) (Comment operations), [`index.js`](https://github.com/enes-sen/backend-blog/blob/main/index.js) (Express server), [`router/commentroutes.js`](https://github.com/enes-sen/backend-blog/blob/main/router/commentroutes.js) (Comment routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API runtime"]
  node_server["Express server<br/>[index.js]"]
  node_routes["API routes<br/>[routes.js]"]
  node_comment_routes["Comment routes<br/>[commentroutes.js]"]
end

subgraph group_domain["Blog operations"]
  node_blog_ops["Post operations<br/>[blogcontroller.js]"]
  node_comment_ops["Comment operations"]
end

subgraph group_persistence["Data persistence"]
  node_post_model["Post model<br/>[post.js]"]
  node_comment_model["Comment model<br/>[comment.js]"]
  node_mongo[("MongoDB")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_routes
node_server -->|"mounts routes"| node_routes
node_routes -->|"dispatches posts"| node_blog_ops
node_routes -->|"mounts comments"| node_comment_routes
node_comment_routes -->|"dispatches comments"| node_comment_ops
node_blog_ops -->|"reads and writes"| node_post_model
node_comment_ops -->|"reads and updates"| node_post_model
node_comment_ops -->|"creates and deletes"| node_comment_model
node_server -->|"connects to"| node_mongo

click node_server "https://github.com/enes-sen/backend-blog/blob/main/index.js"
click node_routes "https://github.com/enes-sen/backend-blog/blob/main/router/routes.js"
click node_comment_routes "https://github.com/enes-sen/backend-blog/blob/main/router/commentroutes.js"
click node_blog_ops "https://github.com/enes-sen/backend-blog/blob/main/controllers/blogcontroller.js"
click node_comment_ops "https://github.com/enes-sen/backend-blog/blob/main/controllers/comentcontroller.js"
click node_post_model "https://github.com/enes-sen/backend-blog/blob/main/models/post.js"
click node_comment_model "https://github.com/enes-sen/backend-blog/blob/main/models/comment.js"

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_server,node_routes,node_comment_routes,node_client toneBlue
class node_blog_ops,node_comment_ops toneAmber
class node_post_model,node_comment_model,node_mongo toneMint
```

## Components

### API runtime

- [Express server](https://github.com/enes-sen/backend-blog/blob/main/index.js): `index.js`
- [API routes](https://github.com/enes-sen/backend-blog/blob/main/router/routes.js): `router/routes.js`
- [Comment routes](https://github.com/enes-sen/backend-blog/blob/main/router/commentroutes.js): `router/commentroutes.js`

### Blog operations

- [Post operations](https://github.com/enes-sen/backend-blog/blob/main/controllers/blogcontroller.js): `controllers/blogcontroller.js`
- [Comment operations](https://github.com/enes-sen/backend-blog/blob/main/controllers/comentcontroller.js): `controllers/comentcontroller.js`

### Data persistence

- [Post model](https://github.com/enes-sen/backend-blog/blob/main/models/post.js): `models/post.js`
- [Comment model](https://github.com/enes-sen/backend-blog/blob/main/models/comment.js): `models/comment.js`
- **MongoDB**

### Other components

- **API client**

## Connections

- API client → API routes: sends requests (evidence: `router/routes.js`)
- Express server → API routes: mounts routes (evidence: `index.js`)
- API routes → Post operations: dispatches posts (evidence: `router/routes.js`)
- API routes → Comment routes: mounts comments (evidence: `router/routes.js`)
- Comment routes → Comment operations: dispatches comments (evidence: `router/commentroutes.js`)
- Post operations → Post model: reads and writes (evidence: `controllers/blogcontroller.js`)
- Comment operations → Post model: reads and updates (evidence: `controllers/comentcontroller.js`)
- Comment operations → Comment model: creates and deletes (evidence: `controllers/comentcontroller.js`)
- Express server → MongoDB: connects to (evidence: `index.js`)
