# muhammmadrizo/backendwithsql architecture

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

- Interactive diagram: https://gitdiagram.com/muhammmadrizo/backendwithsql
- Repository: https://github.com/muhammmadrizo/backendwithsql

## Overview

This is a small Express API for CRUD operations on users, teachers, students, and courses. An HTTP client sends requests to the server, which mounts resource routers; each router dispatches to its controller, and controllers query PostgreSQL through a shared pool. The source excerpts establish the route and database relationships. The README is empty, and the SQL schema was not sampled, so schema details and additional capabilities are not represented.

Main entry points: [`src/server.js`](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/server.js) (Express server), [`src/config/db.js`](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/config/db.js) (PostgreSQL pool), [`src/routers/users.js`](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/users.js) (User routes), [`src/routers/teachers.js`](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/teachers.js) (Teacher routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Express server<br/>[server.js]"]
  node_user_routes["User routes<br/>[users.js]"]
  node_teacher_routes["Teacher routes<br/>[teachers.js]"]
  node_student_routes["Student routes<br/>[students.js]"]
  node_course_routes["Course routes<br/>[courses.js]"]
end

subgraph group_resources["Resource Operations"]
  node_user_ops["User operations<br/>[users.js]"]
  node_teacher_ops["Teacher operations<br/>[teachers.js]"]
  node_student_ops["Student operations<br/>[students.js]"]
  node_course_ops["Course operations<br/>[courses.js]"]
end

subgraph group_persistence["Persistence"]
  node_pool["PostgreSQL pool<br/>[db.js]"]
  node_postgres[("PostgreSQL database")]
end

node_client(("HTTP client"))

node_client -.->|"sends requests"| node_server
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_teacher_routes
node_server -->|"mounts"| node_student_routes
node_server -->|"mounts"| node_course_routes
node_user_routes -->|"dispatches"| node_user_ops
node_teacher_routes -->|"dispatches"| node_teacher_ops
node_student_routes -->|"dispatches"| node_student_ops
node_course_routes -->|"dispatches"| node_course_ops
node_user_ops -->|"queries"| node_pool
node_teacher_ops -->|"queries"| node_pool
node_student_ops -->|"queries"| node_pool
node_course_ops -->|"queries"| node_pool
node_pool -->|"connects to"| node_postgres

click node_server "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/server.js"
click node_user_routes "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/users.js"
click node_teacher_routes "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/teachers.js"
click node_student_routes "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/students.js"
click node_course_routes "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/courses.js"
click node_user_ops "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/controllers/users.js"
click node_teacher_ops "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/controllers/teachers.js"
click node_student_ops "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/controllers/students.js"
click node_course_ops "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/controllers/courses.js"
click node_pool "https://github.com/muhammmadrizo/backendwithsql/blob/main/src/config/db.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_user_routes,node_teacher_routes,node_student_routes,node_course_routes,node_client toneBlue
class node_user_ops,node_teacher_ops,node_student_ops,node_course_ops toneAmber
class node_pool,node_postgres toneMint
```

## Components

### HTTP API

- [Express server](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/server.js): `src/server.js`
- [User routes](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/users.js): `src/routers/users.js`
- [Teacher routes](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/teachers.js): `src/routers/teachers.js`
- [Student routes](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/students.js): `src/routers/students.js`
- [Course routes](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/routers/courses.js): `src/routers/courses.js`

### Resource Operations

- [User operations](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/controllers/users.js): `src/controllers/users.js`
- [Teacher operations](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/controllers/teachers.js): `src/controllers/teachers.js`
- [Student operations](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/controllers/students.js): `src/controllers/students.js`
- [Course operations](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/controllers/courses.js): `src/controllers/courses.js`

### Persistence

- [PostgreSQL pool](https://github.com/muhammmadrizo/backendwithsql/blob/main/src/config/db.js): `src/config/db.js`
- **PostgreSQL database**

### Other components

- **HTTP client**

## Connections

- HTTP client → Express server: sends requests
- Express server → User routes: mounts (evidence: `src/server.js`)
- Express server → Teacher routes: mounts (evidence: `src/server.js`)
- Express server → Student routes: mounts (evidence: `src/server.js`)
- Express server → Course routes: mounts (evidence: `src/server.js`)
- User routes → User operations: dispatches (evidence: `src/routers/users.js`)
- Teacher routes → Teacher operations: dispatches (evidence: `src/routers/teachers.js`)
- Student routes → Student operations: dispatches (evidence: `src/routers/students.js`)
- Course routes → Course operations: dispatches (evidence: `src/routers/courses.js`)
- User operations → PostgreSQL pool: queries (evidence: `src/controllers/users.js`)
- Teacher operations → PostgreSQL pool: queries (evidence: `src/controllers/teachers.js`)
- Student operations → PostgreSQL pool: queries (evidence: `src/controllers/students.js`)
- Course operations → PostgreSQL pool: queries (evidence: `src/controllers/courses.js`)
- PostgreSQL pool → PostgreSQL database: connects to (evidence: `src/config/db.js`)
