# patriciomelor/calendarreserv architecture

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

- Interactive diagram: https://gitdiagram.com/patriciomelor/calendarreserv
- Repository: https://github.com/patriciomelor/calendarreserv

## Overview

##### Project Type and Purpose
- This is a full-stack, cross-platform booking application (“AgendApp”) built with Flutter for iOS, Android, Web and Desktop.
- It uses Firebase as its backend (Firestore, Authentication, Cloud Functions, FCM) plus Node.js Cloud Functions for email notifications and business logic.

##### File Structure Analysis
- Top-level “app_agendamiento” folder contains:
– lib/ : Flutter client code (screens, widgets, services, main.dart)
– android/, ios/, web/, macos/, linux/, windows/ : platform-specific Flutter project files & native configs
– functions/ : Node.js Cloud Functions (index.js, package.json)
– firebase.json, .firebaserc : Firebase hosting and project configuration
- Patterns: a single Flutter client UI layer communicating via Firebase SDKs; a serverless backend layer of Cloud Functions; a NoSQL database layer (Firestore).

##### README Insights
- Role-based modules: Super-Admin, Salon-Admin, Professional, Client.
- Core flows: salon CRUD, professional/service management, appointment booking, calendar views, anonymous auth, email notifications.
- Technology stack spelled out (Flutter, Dart, JS, Firebase).

a. Main Components
- Client Apps (Flutter UI) – single codebase deployed on mobile, web, desktop
- Authentication Layer – Firebase Auth (email/password + anonymous)
- Database Layer – Firestore (NoSQL collections: salons, professionals, services, appointments, users)
- Business Logic Layer – Cloud Functions (Node.js) for triggers, email notifications, appointment side-effects
- Notification Services – FCM for in-app push; SMTP or third-party via Cloud Functions for email
- External Services – Email provider (e.g., SendGrid, Gmail SMTP) if applicable
b. Relationships and Data Flows
1. User opens Flutter app → Firebase Auth → receives ID token
2. Authenticated client reads/writes Firestore directly for real-time CRUD
3. On write to appointments collection → Firestore trigger → Cloud Function executes → sends email via SMTP/API → posts to FCM
4. Client subscribes to FCM topic → receives push notification
c. Architectural Patterns and Principles
- Client-Server (thin client + serverless backend)
- Event-driven functions (Cloud Functions as triggers on Firestore writes)
- Role-based access control (enforced via Firebase Security Rules and front-end routing)
- Single codebase UI (DRY principle) across platforms
d. Key Technologies/Frameworks
- Flutter / Dart
- Firebase SDKs (Auth, Firestore, Functions, Messaging)
- Node.js (Cloud Functions)
- Native build tools (Gradle, Xcode, CMake for desktop)

##### Details to Capture
- Role-based modules: indicate which screens or services are used by each role.
- Configuration files (firebase.json, .firebaserc) as part of deployment pipeline.
- Platform-specific build pipelines (Gradle, Xcode, CMake) can be noted on the outer perimeter if relevant.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Flutter Client App" 
        direction TB
        UI["Flutter UI"]:::frontend
        subgraph "Entry & Config"
            Main["main.dart"]:::frontend
            FirebaseOpts["firebase_options.dart"]:::frontend
        end
        subgraph "Screens"
            direction TB
            AuthGate["Auth Gate"]:::frontend
            Login["Login Screen"]:::frontend
            Register["Register Screen"]:::frontend
            LoginOrRegister["LoginOrRegister Screen"]:::frontend

            SuperAdminDash["Super-Admin Dashboard"]:::frontend
            AdminDash["Salon-Admin Dashboard"]:::frontend
            ProfAgenda["Professional Agenda"]:::frontend
            SalonAgenda["Salon Agenda"]:::frontend
            ClientHome["Client Home Screen"]:::frontend

            PublicBooking["Public Booking Page"]:::frontend
            BookingCalendar["Booking Calendar"]:::frontend
            BookingSuccess["Booking Success"]:::frontend
            AppointmentDetails["Appointment Details"]:::frontend

            CreateSalon["Create Salon Screen"]:::frontend
            SalonSettings["Salon Settings"]:::frontend
            Services["Services Screen"]:::frontend
            Professionals["Professionals Screen"]:::frontend
            SelectProfessional["Select Professional Screen"]:::frontend
            SelectSalon["Select Salon Screen"]:::frontend
            SelectService["Select Service Screen"]:::frontend
        end
        subgraph "Shared Widgets"
            Widgets["Widgets"]:::frontend
        end
        subgraph "Client Services"
            FCMService["FCM Service"]:::frontend
            NotificationSvc["Notification Service"]:::frontend
        end
    end

    %% Auth Layer
    Auth["Firebase Auth"]:::auth

    %% Database Layer
    Firestore["Firestore Database"]:::database

    %% Business Logic Layer
    subgraph "Cloud Functions"
        direction TB
        Functions["index.js"]:::functions
        Npm["package.json"]:::functions
    end

    %% External Services
    EmailProvider["Email Provider (SMTP/SendGrid)"]:::external
    FCMExt["Firebase Cloud Messaging"]:::external

    %% Platform-specific
    subgraph "Platform Projects"
        direction TB
        Android["Android"]:::platform
        iOS["iOS"]:::platform
        WebPlat["Web"]:::platform
        macOS["macOS"]:::platform
        Linux["Linux"]:::platform
        Windows["Windows"]:::platform
    end

    %% Config Files
    FirebaseJson["firebase.json"]:::config
    Firebaserc[".firebaserc"]:::config

    %% Flows
    UI -->|"1. Auth Request"| Auth
    Auth -->|"2. ID Token"| UI
    UI -->|"3. CRUD Reads/Writes"| Firestore
    Firestore -->|"4. Appointment Write Trigger"| Functions
    Functions -->|"5a. Send Email"| EmailProvider
    Functions -->|"5b. Push Notification"| FCMExt
    FCMExt -->|"6. Deliver Push"| UI

    %% Platform
    UI --> Android
    UI --> iOS
    UI --> WebPlat
    UI --> macOS
    UI --> Linux
    UI --> Windows

    %% Config connections
    FirebaseJson -.-> Functions
    Firebaserc -.-> Functions
    FirebaseOpts -.-> Auth
    FirebaseOpts -.-> Firestore

    %% Click Events
    click Main "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/main.dart"
    click FirebaseOpts "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/firebase_options.dart"
    click AuthGate "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/auth_gate.dart"
    click Login "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/login_screen.dart"
    click Register "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/register_screen.dart"
    click LoginOrRegister "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/login_or_register_screen.dart"
    click SuperAdminDash "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/super_admin_dashboard_screen.dart"
    click AdminDash "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/admin_dashboard_screen.dart"
    click ProfAgenda "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/professional_agenda_screen.dart"
    click SalonAgenda "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/salon_agenda_screen.dart"
    click ClientHome "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/customer_home_screen.dart"
    click PublicBooking "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/public_booking_page.dart"
    click BookingCalendar "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/booking_calendar_screen.dart"
    click BookingSuccess "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/booking_success_screen.dart"
    click AppointmentDetails "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/appointment_details_screen.dart"
    click CreateSalon "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/create_salon_screen.dart"
    click SalonSettings "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/salon_settings_screen.dart"
    click Services "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/services_screen.dart"
    click Professionals "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/professionals_screen.dart"
    click SelectProfessional "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/select_professional_screen.dart"
    click SelectSalon "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/select_salon_screen.dart"
    click SelectService "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/screens/select_service_screen.dart"
    click Widgets "https://github.com/patriciomelor/calendarreserv/tree/main/app_agendamiento/lib/widgets/"
    click FCMService "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/services/fcm_service.dart"
    click NotificationSvc "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/lib/services/notification_service.dart"
    click Functions "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/functions/index.js"
    click Npm "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/functions/package.json"
    click FirebaseJson "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/firebase.json"
    click Firebaserc "https://github.com/patriciomelor/calendarreserv/blob/main/app_agendamiento/.firebaserc"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef auth fill:#F0E6FF,stroke:#7C3AED,color:#7C3AED
    classDef database fill:#FFF4E5,stroke:#F59E0B,color:#B45309,stroke-width:2px
    classDef functions fill:#D1FAE5,stroke:#10B981,color:#065F46
    classDef external fill:#E5E7EB,stroke:#6B7280,color:#374151
    classDef platform fill:#E0F2FE,stroke:#0284C7,color:#0369A1
    classDef config fill:#F3F4F6,stroke:#9CA3AF,color:#4B5563,stroke-dasharray: 2 2
```
