# saphire23/pf_bases architecture

> Architecture diagram of the GitHub repository saphire23/pf_bases, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saphire23/pf_bases
- Repository: https://github.com/saphire23/pf_bases

## Overview

##### Project Type and Purpose
- This is a full-stack web application for managing “citas” (appointments) and “usuarios” (users).
- Frontend: Angular (RRS) handles UI, routing, authentication and communicates via REST.
- Backend: FastAPI serves JSON APIs, implements business logic in “services” and persistence in “models” (Pydantic + database).
- Database: Relational (via pyodbc/SQLAlchemy or native DB-API) storing Usuario and Cita tables.

##### File-Structure Analysis
- Top-level “Frontend” and “Backend” directories clearly separate client and server.
- Backend/app/main.py spins up the FastAPI app; routers are in Backend/app/routers; services in Backend/app/services; data models in Backend/app/models; DB setup in Backend/app/database.py.
- Frontend/RRS/src/app contains feature modules: auth, citas, dashboard (admin/empresa), home, login, register, shared header/footer.
- Requirements.txt and package.json enumerate dependencies (FastAPI, Pydantic, Angular, etc.).

##### Key Architectural Patterns
- Layered architecture on the backend:
- Routers (API layer) → Services (business logic) → Models/Database (persistence).
- Frontend: Component-based modular design with guards (AuthGuard) and environment-specific config/routes files.
- Stateless REST API, token- or session-based auth (auth.service.ts + auth.guard.ts).

##### Main Components and Interactions
- Browser/UI (Angular app)
↕ HTTPS/JSON
- FastAPI Backend
- API Layer (routers/citas.py, routers/usuarios.py)
- Service Layer (services/*.py)
- Data Access (database.py + models/citas.py, models/usuarios.py)
- Relational Database (e.g., SQL Server/MySQL/Postgres)

- Tables:
[Usuarios]
- id (PK)
- nombre
- email (unique)
- hashed_password
- created_at
[Citas]
- id (PK)
- usuario_id (FK → Usuarios.id)
- fecha_hora
- descripcion
- estado
- Relationship: Usuarios 1 ──< Citas (one user can have many appointments)

+----------------+           +-----------------+
|   Usuarios     |           |     Citas       |
|----------------|           |-----------------|
| PK id          |◄───(1:M)──| FK usuario_id   |
|   nombre       |           |   fecha_hora    |
|   email        |           |   descripcion   |
|   hashed_pw    |           |   estado        |
|   created_at   |           | PK id           |
+----------------+           +-----------------+

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Relational Database"
        direction TB
        Usuarios[(Usuarios)]:::db
        Citas[(Citas)]:::db
    end

    Usuarios -->|1:M| Citas

    click Usuarios "https://github.com/saphire23/pf_bases/blob/main/Backend/app/models/usuarios.py"
    click Citas "https://github.com/saphire23/pf_bases/blob/main/Backend/app/models/citas.py"

    classDef db fill:#f96,stroke:#f60,stroke-width:2px;
    classDef arrowStyle stroke-width:2px;
```
