# hug0rios/biblioteca architecture

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

- Interactive diagram: https://gitdiagram.com/hug0rios/biblioteca
- Repository: https://github.com/hug0rios/biblioteca

## Overview

ArmaZen is a small library-loan application with both a Flask web interface and a terminal interface. Users authenticate, then browse the catalog or view loans; clients can also renew their own loans. Biblioteca loads users, books, and loans from text files and coordinates the domain objects, while Emprestimo enforces loan limits, due dates, fines, and renewal rules. The excerpts show the application routes and core model, but not the templates’ contents; the presentation node therefore represents only the templates directory referenced by the routes.

Main entry points: [`model/Biblioteca.py`](https://github.com/hug0rios/biblioteca/blob/main/model/Biblioteca.py) (Library coordinator), [`app.py`](https://github.com/hug0rios/biblioteca/blob/main/app.py) (Web application), [`main.py`](https://github.com/hug0rios/biblioteca/blob/main/main.py) (Terminal application), [`model/Cliente.py`](https://github.com/hug0rios/biblioteca/blob/main/model/Cliente.py) (Client account)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entrypoints"]
  node_web["Web application<br/>[app.py]"]
  node_terminal["Terminal application<br/>[main.py]"]
end

subgraph group_domain["Library domain"]
  node_library["Library coordinator<br/>[Biblioteca.py]"]
  node_client["Client account<br/>[Cliente.py]"]
  node_librarian["Librarian account<br/>[Bibliotecario.py]"]
  node_user["User base<br/>[Usuario.py]"]
  node_loan["Loan rules<br/>[Emprestimo.py]"]
  node_book["Book record<br/>[Livro.py]"]
end

subgraph group_storage["Text-file storage"]
  node_users_data[("User records<br/>[usuarios.txt]")]
  node_books_data[("Book records<br/>[livros.txt]")]
  node_loans_data[("Loan records<br/>[emprestimos.txt]")]
end

subgraph group_presentation["Web presentation"]
  node_pages["Web pages"]
end

node_reader(("Library user"))

node_reader -->|"uses"| node_web
node_reader -->|"uses"| node_terminal
node_web -->|"loads and routes"| node_library
node_terminal -->|"loads and authenticates"| node_library
node_terminal -->|"dispatches menu"| node_user
node_web -->|"renders"| node_pages
node_library -->|"reads"| node_users_data
node_library -->|"reads"| node_books_data
node_library -->|"reads and writes"| node_loans_data
node_library -->|"creates"| node_client
node_library -->|"creates"| node_librarian
node_library -->|"creates"| node_book
node_library -->|"creates and renews"| node_loan
node_client -->|"inherits"| node_user
node_librarian -->|"inherits"| node_user
node_client -->|"requests library actions"| node_library
node_librarian -->|"requests library actions"| node_library

click node_web "https://github.com/hug0rios/biblioteca/blob/main/app.py"
click node_terminal "https://github.com/hug0rios/biblioteca/blob/main/main.py"
click node_library "https://github.com/hug0rios/biblioteca/blob/main/model/Biblioteca.py"
click node_client "https://github.com/hug0rios/biblioteca/blob/main/model/Cliente.py"
click node_librarian "https://github.com/hug0rios/biblioteca/blob/main/model/Bibliotecario.py"
click node_user "https://github.com/hug0rios/biblioteca/blob/main/model/Usuario.py"
click node_loan "https://github.com/hug0rios/biblioteca/blob/main/model/Emprestimo.py"
click node_book "https://github.com/hug0rios/biblioteca/blob/main/model/Livro.py"
click node_users_data "https://github.com/hug0rios/biblioteca/blob/main/usuarios.txt"
click node_books_data "https://github.com/hug0rios/biblioteca/blob/main/livros.txt"
click node_loans_data "https://github.com/hug0rios/biblioteca/blob/main/emprestimos.txt"
click node_pages "https://github.com/hug0rios/biblioteca/tree/main/templates"

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_web,node_terminal,node_reader toneBlue
class node_library,node_client,node_librarian,node_user,node_loan,node_book toneAmber
class node_users_data,node_books_data,node_loans_data toneMint
class node_pages toneRose
```

## Components

### Application entrypoints

- [Web application](https://github.com/hug0rios/biblioteca/blob/main/app.py): `app.py`
- [Terminal application](https://github.com/hug0rios/biblioteca/blob/main/main.py): `main.py`

### Library domain

- [Library coordinator](https://github.com/hug0rios/biblioteca/blob/main/model/Biblioteca.py): `model/Biblioteca.py`
- [Client account](https://github.com/hug0rios/biblioteca/blob/main/model/Cliente.py): `model/Cliente.py`
- [Librarian account](https://github.com/hug0rios/biblioteca/blob/main/model/Bibliotecario.py): `model/Bibliotecario.py`
- [User base](https://github.com/hug0rios/biblioteca/blob/main/model/Usuario.py): `model/Usuario.py`
- [Loan rules](https://github.com/hug0rios/biblioteca/blob/main/model/Emprestimo.py): `model/Emprestimo.py`
- [Book record](https://github.com/hug0rios/biblioteca/blob/main/model/Livro.py): `model/Livro.py`

### Text-file storage

- [User records](https://github.com/hug0rios/biblioteca/blob/main/usuarios.txt): `usuarios.txt`
- [Book records](https://github.com/hug0rios/biblioteca/blob/main/livros.txt): `livros.txt`
- [Loan records](https://github.com/hug0rios/biblioteca/blob/main/emprestimos.txt): `emprestimos.txt`

### Web presentation

- [Web pages](https://github.com/hug0rios/biblioteca/tree/main/templates): `templates`

### Other components

- **Library user**

## Connections

- Library user → Web application: uses
- Library user → Terminal application: uses
- Web application → Library coordinator: loads and routes (evidence: `app.py`)
- Terminal application → Library coordinator: loads and authenticates (evidence: `main.py`)
- Terminal application → User base: dispatches menu (evidence: `main.py`)
- Web application → Web pages: renders (evidence: `app.py`)
- Library coordinator → User records: reads (evidence: `model/Biblioteca.py`)
- Library coordinator → Book records: reads (evidence: `model/Biblioteca.py`)
- Library coordinator → Loan records: reads and writes (evidence: `model/Biblioteca.py`)
- Library coordinator → Client account: creates (evidence: `model/Biblioteca.py`)
- Library coordinator → Librarian account: creates (evidence: `model/Biblioteca.py`)
- Library coordinator → Book record: creates (evidence: `model/Biblioteca.py`)
- Library coordinator → Loan rules: creates and renews (evidence: `model/Biblioteca.py`)
- Client account → User base: inherits (evidence: `model/Cliente.py`)
- Librarian account → User base: inherits (evidence: `model/Bibliotecario.py`)
- Client account → Library coordinator: requests library actions (evidence: `model/Cliente.py`)
- Librarian account → Library coordinator: requests library actions (evidence: `model/Bibliotecario.py`)
