# t-cordoba/turnos-cuidado-mama architecture

> Architecture diagram of the GitHub repository t-cordoba/turnos-cuidado-mama, 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/t-cordoba/turnos-cuidado-mama
- Repository: https://github.com/t-cordoba/turnos-cuidado-mama

## Overview

##### Project type and purpose
- This is a monolithic full-stack web application built with Python and Flask.
- Purpose: allow family members to view a calendar on their phones, reserve and cancel day/night care shifts for their grandmother—no logins required.

##### File structure
- Entry point: run.py (invokes Flask app, likely via Gunicorn in production).
- config.py: reads environment variables (e.g., DATABASE_URL for NeonDB).
- Procfile: declares web process for PaaS (Heroku or similar).
- app/
- __init__.py: creates Flask app instance
- db.py: sets up SQLAlchemy engine/connection to PostgreSQL
- models.py: defines ORM models (shifts, users?)
- routes.py: defines HTTP endpoints (list calendar, reserve, cancel)
- static/: CSS, JS served as client assets
- templates/: Jinja2 HTML views (index.html, error.html)
- requirements.txt: Flask, SQLAlchemy, psycopg2-binary, etc.

##### README for additional insights
- Database: PostgreSQL hosted on NeonDB
- Mobile-optimized UI
- No authentication layer—simple CRUD over HTTP
- Intended for personal/family use, deployed as a small PaaS app

##### Main components & their interactions
a. Client (Mobile Web Browser)
- Sends HTTP GET/POST to reserve or cancel shifts
- Renders HTML + CSS + JavaScript
b. Web Server / App Layer (Flask Monolith)
- WSGI entrypoint (run.py + Gunicorn via Procfile)
- routes.py: controllers handling requests
- models.py & db.py: business logic and data access via SQLAlchemy
c. Data Layer (PostgreSQL on NeonDB)
- Persists shift data
d. Hosting Infrastructure
- PaaS (Heroku/Neon) with environment-driven config

Flow:
Client → (HTTP) → Flask routes → SQLAlchemy → PostgreSQL
Flask → renders Jinja2 templates + serves static files → Client

##### Architectural patterns & design principles
- MVC-style separation:
- Model = models.py + db.py
- View = Jinja2 templates + static assets
- Controller = routes.py
- Monolith: single deployable unit
- Twelve-factor principles: config via env vars, Procfile, dependencies in requirements.txt

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        Browser["Mobile Web Browser"]:::frontend
    end

    %% Frontend Assets
    subgraph "Frontend Resources"
        Style["style.css"]:::frontend
        Scripts["scripts.js"]:::frontend
        IndexTemplate["index.html"]:::frontend
        ErrorTemplate["error.html"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        ProcfileNode["Procfile"]:::infra
        RunPy["run.py"]:::infra
        Config["config.py"]:::backend
        Init["__init__.py"]:::backend
        DBConn["db.py"]:::backend
        Models["models.py"]:::backend
        Routes["routes.py"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        Postgres["PostgreSQL Database"]:::database
    end

    %% Infrastructure
    subgraph "Infrastructure"
        Heroku["Heroku PaaS"]:::infra
        NeonDB["NeonDB Service"]:::infra
        Requirements["requirements.txt"]:::infra
        README["README.md"]:::infra
    end

    %% Client to App
    Browser -->|"HTTP GET/POST"| Routes
    Browser -->|"loads CSS/JS"| Style
    Browser -->|"loads CSS/JS"| Scripts

    %% Templates
    Routes -->|"renders"| IndexTemplate
    Routes -->|"renders on error"| ErrorTemplate

    %% App startup
    ProcfileNode -->|"runs via Gunicorn"| RunPy
    RunPy -->|"imports"| Init
    Init -->|"loads config"| Config
    Config -->|"reads env vars"| Heroku

    %% App internals
    Init -->|"sets up DB"| DBConn
    DBConn -->|"defines engine/session"| Models
    Routes -->|"uses ORM"| Models
    Routes -->|"queries/inserts"| DBConn
    Routes -->|"SQLAlchemy ORM / SQL"| Postgres

    %% Infra connections
    NeonDB -->|"provides PostgreSQL"| Postgres
    Heroku -->|"deploys app"| ProcfileNode

    %% Project files
    ProcfileNode --- Requirements
    ProcfileNode --- README

    %% Click Events
    click RunPy "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/run.py"
    click ProcfileNode "https://github.com/t-cordoba/turnos-cuidado-mama/tree/main/Procfile"
    click Config "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/config.py"
    click Init "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/app/__init__.py"
    click DBConn "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/app/db.py"
    click Models "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/app/models.py"
    click Routes "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/app/routes.py"
    click Style "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/app/static/style.css"
    click Scripts "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/app/static/scripts.js"
    click IndexTemplate "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/app/templates/index.html"
    click ErrorTemplate "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/app/templates/error.html"
    click Requirements "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/requirements.txt"
    click README "https://github.com/t-cordoba/turnos-cuidado-mama/blob/main/README.md"

    %% Styles
    classDef frontend fill:#1f77b4,stroke:#333,stroke-width:1px,color:white;
    classDef backend fill:#2ca02c,stroke:#333,stroke-width:1px,color:white;
    classDef database fill:#ff7f0e,stroke:#333,stroke-width:1px,color:white;
    classDef infra fill:#7f7f7f,stroke:#333,stroke-width:1px,color:white;
```
