# sithscript/projeto-clinipet architecture

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

- Interactive diagram: https://gitdiagram.com/sithscript/projeto-clinipet
- Repository: https://github.com/sithscript/projeto-clinipet

## Overview

CliniPet’s stated centerpiece is a normalized veterinary-clinic database, with a REST API and browser panel as additions. The main user flow is navigating the panel, selecting a clinic or report screen, and viewing or managing data exposed by the API. The API routes requests through controllers to repositories and the configured database. The README documents SQL schema, seed data, validation queries, views, and analytics, but those database files are absent from the supplied tree; their internals are therefore shown only as documented capabilities. Some controller and repository links rely on the SOURCE INDEX rather than excerpts.

Main entry points: [`frontend/js/main.js`](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/main.js) (Browser entry and navigation), [`src/config/database.ts`](https://github.com/sithscript/projeto-clinipet/blob/main/src/config/database.ts) (Database selection), [`frontend/js/presenters/entity.js`](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/entity.js) (Entity screens), [`src/controller/CrudController.ts`](https://github.com/sithscript/projeto-clinipet/blob/main/src/controller/CrudController.ts) (CRUD controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Database core"]
  node_sqlcore[("Relational schema and SQL")]
  node_dbconfig["Database selection<br/>[database.ts]"]
  node_sqlite[("Embedded SQLite<br/>[sqlite.ts]")]
end

subgraph group_api["REST API"]
  node_server["HTTP server<br/>[server.ts]"]
  node_app["Express app<br/>[app.ts]"]
  node_routes["API routes"]
  node_crudroutes["CRUD routing<br/>[crudRoutes.ts]"]
  node_crud["CRUD controller<br/>[CrudController.ts]"]
end

subgraph group_clinic["Clinic records"]
  node_cliniccontrollers["Clinic controllers"]
  node_models["Domain models"]
  node_validators["Input validation<br/>[validators.ts]"]
  node_repositories["Clinic repositories"]
  node_baserepo["Shared data access<br/>[BaseRepository.ts]"]
  node_petowners["Pet-tutor links"]
end

subgraph group_reports["Reports"]
  node_reportroutes["Report routes<br/>[relatorioRoutes.ts]"]
  node_reportcontroller["Report controller"]
  node_reportsrepo["Analytics queries"]
end

subgraph group_web["Web panel"]
  node_frontend["Browser entry and navigation<br/>[main.js]"]
  node_entities["Entity definitions<br/>[entities.js]"]
  node_model["Frontend data model<br/>[model.js]"]
  node_entitypresenter["Entity screens<br/>[entity.js]"]
  node_prontuario["Pet records<br/>[prontuario.js]"]
  node_dashboard["Dashboard<br/>[dashboard.js]"]
  node_reportspresenter["Report screens<br/>[reports.js]"]
  node_view["UI components<br/>[view.js]"]
end

node_user(("Clinic user"))
node_mysql[("MySQL server")]

node_user -->|"navigates"| node_frontend
node_frontend -->|"dispatches"| node_dashboard
node_frontend -->|"dispatches"| node_entitypresenter
node_frontend -->|"dispatches"| node_reportspresenter
node_frontend -->|"configures screens"| node_entities
node_entitypresenter -->|"uses"| node_prontuario
node_entitypresenter -->|"uses"| node_model
node_reportspresenter -->|"uses"| node_model
node_entitypresenter -->|"renders with"| node_view
node_prontuario -->|"renders with"| node_view
node_reportspresenter -->|"renders with"| node_view
node_frontend -.->|"consumes API"| node_app
node_server -->|"starts"| node_app
node_app -->|"mounts"| node_routes
node_routes -->|"uses"| node_crudroutes
node_crudroutes -->|"dispatches"| node_crud
node_crud -->|"validates with"| node_validators
node_crud -->|"calls"| node_baserepo
node_cliniccontrollers -->|"builds"| node_models
node_cliniccontrollers -->|"calls"| node_repositories
node_repositories -->|"extends"| node_baserepo
node_petowners -->|"queries via"| node_dbconfig
node_baserepo -->|"queries via"| node_dbconfig
node_reportroutes -->|"dispatches"| node_reportcontroller
node_reportcontroller -->|"calls"| node_reportsrepo
node_reportsrepo -->|"queries via"| node_dbconfig
node_dbconfig -->|"opens default"| node_sqlite
node_dbconfig -.->|"selects optionally"| node_mysql
node_sqlite -.->|"initializes from scripts"| node_sqlcore
node_sqlcore -.->|"documents views and analytics"| node_reportsrepo

click node_dbconfig "https://github.com/sithscript/projeto-clinipet/blob/main/src/config/database.ts"
click node_sqlite "https://github.com/sithscript/projeto-clinipet/blob/main/src/config/sqlite.ts"
click node_server "https://github.com/sithscript/projeto-clinipet/blob/main/src/server.ts"
click node_app "https://github.com/sithscript/projeto-clinipet/blob/main/src/app.ts"
click node_routes "https://github.com/sithscript/projeto-clinipet/tree/main/src/routes"
click node_crudroutes "https://github.com/sithscript/projeto-clinipet/blob/main/src/routes/crudRoutes.ts"
click node_crud "https://github.com/sithscript/projeto-clinipet/blob/main/src/controller/CrudController.ts"
click node_reportroutes "https://github.com/sithscript/projeto-clinipet/blob/main/src/routes/relatorioRoutes.ts"
click node_reportcontroller "https://github.com/sithscript/projeto-clinipet/blob/main/src/controller/ReportController.ts"
click node_reportsrepo "https://github.com/sithscript/projeto-clinipet/blob/main/src/repository/ReportRepository.ts"
click node_cliniccontrollers "https://github.com/sithscript/projeto-clinipet/tree/main/src/controller"
click node_models "https://github.com/sithscript/projeto-clinipet/tree/main/src/models"
click node_validators "https://github.com/sithscript/projeto-clinipet/blob/main/src/models/validators.ts"
click node_repositories "https://github.com/sithscript/projeto-clinipet/tree/main/src/repository"
click node_baserepo "https://github.com/sithscript/projeto-clinipet/blob/main/src/repository/BaseRepository.ts"
click node_petowners "https://github.com/sithscript/projeto-clinipet/blob/main/src/repository/PetTutorRepository.ts"
click node_frontend "https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/main.js"
click node_entities "https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/entities.js"
click node_model "https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/model.js"
click node_entitypresenter "https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/entity.js"
click node_prontuario "https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/prontuario.js"
click node_dashboard "https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/dashboard.js"
click node_reportspresenter "https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/reports.js"
click node_view "https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/view.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_sqlcore,node_dbconfig,node_sqlite,node_user toneBlue
class node_server,node_app,node_routes,node_crudroutes,node_crud,node_mysql toneAmber
class node_cliniccontrollers,node_models,node_validators,node_repositories,node_baserepo,node_petowners toneMint
class node_reportroutes,node_reportcontroller,node_reportsrepo toneRose
class node_frontend,node_entities,node_model,node_entitypresenter,node_prontuario,node_dashboard,node_reportspresenter,node_view toneIndigo
```

## Components

### Database core

- **Relational schema and SQL**
- [Database selection](https://github.com/sithscript/projeto-clinipet/blob/main/src/config/database.ts): `src/config/database.ts`
- [Embedded SQLite](https://github.com/sithscript/projeto-clinipet/blob/main/src/config/sqlite.ts): `src/config/sqlite.ts`

### REST API

- [HTTP server](https://github.com/sithscript/projeto-clinipet/blob/main/src/server.ts): `src/server.ts`
- [Express app](https://github.com/sithscript/projeto-clinipet/blob/main/src/app.ts): `src/app.ts`
- [API routes](https://github.com/sithscript/projeto-clinipet/tree/main/src/routes): `src/routes`
- [CRUD routing](https://github.com/sithscript/projeto-clinipet/blob/main/src/routes/crudRoutes.ts): `src/routes/crudRoutes.ts`
- [CRUD controller](https://github.com/sithscript/projeto-clinipet/blob/main/src/controller/CrudController.ts): `src/controller/CrudController.ts`

### Clinic records

- [Clinic controllers](https://github.com/sithscript/projeto-clinipet/tree/main/src/controller): `src/controller`
- [Domain models](https://github.com/sithscript/projeto-clinipet/tree/main/src/models): `src/models`
- [Input validation](https://github.com/sithscript/projeto-clinipet/blob/main/src/models/validators.ts): `src/models/validators.ts`
- [Clinic repositories](https://github.com/sithscript/projeto-clinipet/tree/main/src/repository): `src/repository`
- [Shared data access](https://github.com/sithscript/projeto-clinipet/blob/main/src/repository/BaseRepository.ts): `src/repository/BaseRepository.ts`
- [Pet-tutor links](https://github.com/sithscript/projeto-clinipet/blob/main/src/repository/PetTutorRepository.ts): `src/repository/PetTutorRepository.ts`

### Reports

- [Report routes](https://github.com/sithscript/projeto-clinipet/blob/main/src/routes/relatorioRoutes.ts): `src/routes/relatorioRoutes.ts`
- [Report controller](https://github.com/sithscript/projeto-clinipet/blob/main/src/controller/ReportController.ts): `src/controller/ReportController.ts`
- [Analytics queries](https://github.com/sithscript/projeto-clinipet/blob/main/src/repository/ReportRepository.ts): `src/repository/ReportRepository.ts`

### Web panel

- [Browser entry and navigation](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/main.js): `frontend/js/main.js`
- [Entity definitions](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/entities.js): `frontend/js/entities.js`
- [Frontend data model](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/model.js): `frontend/js/model.js`
- [Entity screens](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/entity.js): `frontend/js/presenters/entity.js`
- [Pet records](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/prontuario.js): `frontend/js/presenters/prontuario.js`
- [Dashboard](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/dashboard.js): `frontend/js/presenters/dashboard.js`
- [Report screens](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/presenters/reports.js): `frontend/js/presenters/reports.js`
- [UI components](https://github.com/sithscript/projeto-clinipet/blob/main/frontend/js/view.js): `frontend/js/view.js`

### Other components

- **Clinic user**
- **MySQL server**

## Connections

- Clinic user → Browser entry and navigation: navigates (evidence: `frontend/js/main.js`)
- Browser entry and navigation → Dashboard: dispatches (evidence: `frontend/js/main.js`)
- Browser entry and navigation → Entity screens: dispatches (evidence: `frontend/js/main.js`)
- Browser entry and navigation → Report screens: dispatches (evidence: `frontend/js/main.js`)
- Browser entry and navigation → Entity definitions: configures screens (evidence: `frontend/js/main.js`)
- Entity screens → Pet records: uses (evidence: `frontend/js/presenters/entity.js`)
- Entity screens → Frontend data model: uses (evidence: `frontend/js/presenters/entity.js`)
- Report screens → Frontend data model: uses (evidence: `frontend/js/presenters/reports.js`)
- Entity screens → UI components: renders with (evidence: `frontend/js/presenters/entity.js`)
- Pet records → UI components: renders with (evidence: `frontend/js/presenters/prontuario.js`)
- Report screens → UI components: renders with (evidence: `frontend/js/presenters/reports.js`)
- Browser entry and navigation → Express app: consumes API
- HTTP server → Express app: starts (evidence: `src/server.ts`)
- Express app → API routes: mounts (evidence: `src/app.ts`)
- API routes → CRUD routing: uses (evidence: `src/routes/petRoutes.ts`)
- CRUD routing → CRUD controller: dispatches (evidence: `src/routes/crudRoutes.ts`)
- CRUD controller → Input validation: validates with (evidence: `src/controller/CrudController.ts`)
- CRUD controller → Shared data access: calls (evidence: `src/controller/CrudController.ts`)
- Clinic controllers → Domain models: builds (evidence: `src/controller/PetController.ts`)
- Clinic controllers → Clinic repositories: calls (evidence: `src/controller/PetController.ts`)
- Clinic repositories → Shared data access: extends (evidence: `src/repository/PetRepository.ts`)
- Pet-tutor links → Database selection: queries via (evidence: `src/repository/PetTutorRepository.ts`)
- Shared data access → Database selection: queries via (evidence: `src/repository/BaseRepository.ts`)
- Report routes → Report controller: dispatches (evidence: `src/routes/relatorioRoutes.ts`)
- Report controller → Analytics queries: calls (evidence: `src/controller/ReportController.ts`)
- Analytics queries → Database selection: queries via (evidence: `src/repository/ReportRepository.ts`)
- Database selection → Embedded SQLite: opens default (evidence: `src/config/database.ts`)
- Database selection → MySQL server: selects optionally (evidence: `src/config/database.ts`)
- Embedded SQLite → Relational schema and SQL: initializes from scripts
- Relational schema and SQL → Analytics queries: documents views and analytics
