# makson19/univ_api architecture

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

- Interactive diagram: https://gitdiagram.com/makson19/univ_api
- Repository: https://github.com/makson19/univ_api

## Overview

Univ API manages student records through a single `/alunos` REST workflow: requests enter the Express app, route to student handlers, and return JSON or validation/error responses. Create and update requests are schema-validated; handlers delegate CRUD and paginated listing to the student service, which uses Prisma to query MySQL. The README documents these endpoint capabilities. The graph follows the sampled runtime source; database schema details and any behavior beyond the excerpts are not inferred.

Main entry points: [`src/services/AlunoService.js`](https://github.com/makson19/univ_api/blob/main/src/services/AlunoService.js) (Student service), [`src/routes/alunoRoutes.js`](https://github.com/makson19/univ_api/blob/main/src/routes/alunoRoutes.js) (Student routes), [`src/controllers/AlunoController.js`](https://github.com/makson19/univ_api/blob/main/src/controllers/AlunoController.js) (Student controller), [`src/index.js`](https://github.com/makson19/univ_api/blob/main/src/index.js) (Express app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_app["Express app<br/>[index.js]"]
  node_routes["Student routes<br/>[alunoRoutes.js]"]
  node_validation["Body validation<br/>[validate.js]"]
  node_schemas["Student schemas<br/>[alunoSchema.js]"]
  node_controller["Student controller<br/>[AlunoController.js]"]
end

subgraph group_domain["Student Domain"]
  node_service["Student service<br/>[AlunoService.js]"]
  node_student_errors["Student errors"]
  node_not_found["Not-found error"]
  node_order_error["Order error"]
end

subgraph group_data["Persistence"]
  node_prisma_client["Prisma client<br/>[prisma.js]"]
  node_mysql[("MySQL database")]
  node_data_model["Student data model<br/>[schema.prisma]"]
end

node_client(("API client"))

node_client -->|"sends HTTP"| node_app
node_app -->|"mounts routes"| node_routes
node_routes -->|"validates create/update"| node_validation
node_validation -->|"parses body"| node_schemas
node_routes -->|"dispatches handlers"| node_controller
node_controller -->|"calls operations"| node_service
node_service -->|"queries records"| node_prisma_client
node_prisma_client -->|"reads/writes"| node_mysql
node_service -->|"throws invalid"| node_student_errors
node_service -->|"throws missing"| node_not_found
node_service -->|"throws invalid order"| node_order_error
node_controller -->|"returns HTTP response"| node_client

click node_app "https://github.com/makson19/univ_api/blob/main/src/index.js"
click node_routes "https://github.com/makson19/univ_api/blob/main/src/routes/alunoRoutes.js"
click node_validation "https://github.com/makson19/univ_api/blob/main/src/middlewares/validate.js"
click node_schemas "https://github.com/makson19/univ_api/blob/main/src/schemas/alunoSchema.js"
click node_controller "https://github.com/makson19/univ_api/blob/main/src/controllers/AlunoController.js"
click node_service "https://github.com/makson19/univ_api/blob/main/src/services/AlunoService.js"
click node_student_errors "https://github.com/makson19/univ_api/blob/main/src/errors/AlunoInvalidoError.js"
click node_not_found "https://github.com/makson19/univ_api/blob/main/src/errors/AlunoNaoEncontradoError.js"
click node_order_error "https://github.com/makson19/univ_api/blob/main/src/errors/OrderInvalidoError.js"
click node_prisma_client "https://github.com/makson19/univ_api/blob/main/src/databases/prisma.js"
click node_data_model "https://github.com/makson19/univ_api/blob/main/prisma/schema.prisma"

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_app,node_routes,node_validation,node_schemas,node_controller,node_client toneBlue
class node_service,node_student_errors,node_not_found,node_order_error toneAmber
class node_prisma_client,node_mysql,node_data_model toneMint
```

## Components

### HTTP API

- [Express app](https://github.com/makson19/univ_api/blob/main/src/index.js): `src/index.js`
- [Student routes](https://github.com/makson19/univ_api/blob/main/src/routes/alunoRoutes.js): `src/routes/alunoRoutes.js`
- [Body validation](https://github.com/makson19/univ_api/blob/main/src/middlewares/validate.js): `src/middlewares/validate.js`
- [Student schemas](https://github.com/makson19/univ_api/blob/main/src/schemas/alunoSchema.js): `src/schemas/alunoSchema.js`
- [Student controller](https://github.com/makson19/univ_api/blob/main/src/controllers/AlunoController.js): `src/controllers/AlunoController.js`

### Student Domain

- [Student service](https://github.com/makson19/univ_api/blob/main/src/services/AlunoService.js): `src/services/AlunoService.js`
- [Student errors](https://github.com/makson19/univ_api/blob/main/src/errors/AlunoInvalidoError.js): `src/errors/AlunoInvalidoError.js`
- [Not-found error](https://github.com/makson19/univ_api/blob/main/src/errors/AlunoNaoEncontradoError.js): `src/errors/AlunoNaoEncontradoError.js`
- [Order error](https://github.com/makson19/univ_api/blob/main/src/errors/OrderInvalidoError.js): `src/errors/OrderInvalidoError.js`

### Persistence

- [Prisma client](https://github.com/makson19/univ_api/blob/main/src/databases/prisma.js): `src/databases/prisma.js`
- **MySQL database**
- [Student data model](https://github.com/makson19/univ_api/blob/main/prisma/schema.prisma): `prisma/schema.prisma`

### Other components

- **API client**

## Connections

- API client → Express app: sends HTTP
- Express app → Student routes: mounts routes
- Student routes → Body validation: validates create/update
- Body validation → Student schemas: parses body
- Student routes → Student controller: dispatches handlers
- Student controller → Student service: calls operations
- Student service → Prisma client: queries records
- Prisma client → MySQL database: reads/writes
- Student service → Student errors: throws invalid
- Student service → Not-found error: throws missing
- Student service → Order error: throws invalid order
- Student controller → API client: returns HTTP response
