# teo-information/sistema_reflexo architecture

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

- Interactive diagram: https://gitdiagram.com/teo-information/sistema_reflexo
- Repository: https://github.com/teo-information/sistema_reflexo

## Overview

##### Project Type and Purpose
- This is a full-stack clinic management application (“ReflexoPeru”), split into two main parts:
- Frontend (React + Vite + Ant Design + ApexCharts + Axios)
- Backend (Laravel/PHP API with MVC, Services, Sanctum auth, Mail, Queue, Storage)
- Purpose: enable administrative staff and therapists to manage patients, appointments, histories, payments and generate reports/metrics.

##### File Structure Highlights
- Top-level:
– /backend → Laravel API (app/, routes/, config/, database/, public/, resources/, tests/)
– /src → React SPA (components/, features/, pages/, routes/, services/, utils/)
– /docs → Markdown guides (architecture, components, hooks, services, routes, styles)
– index.html, package.json, vite.config.js → React/Vite entry
- Backend layering:
– app/Http/Controllers (API & Auth controllers)
– app/Services (business logic per domain)
– app/Models (Eloquent models)
– database/migrations & seeders (schema + dummy data)
– config/ (auth, database, mail, sanctum, permission)
- Frontend modularity:
– src/components (UI primitives)
– src/features (domain modules: appointments, patients, history, etc.)
– src/services/api (Axios configuration + methods)
– src/routes (React Router + protected routes)
– src/utils, src/context (shared logic & state)

a. Main Components
– User’s Browser (SPA UI)
– Frontend SPA (React App)
- UI Components
- Feature Modules (Appointments, Patients, Reports, Staff, Auth, etc.)
- API Service Layer (Axios + Toastify)
– Backend API (Laravel)
- HTTP Layer (Routes → Controllers)
- Business Layer (Services)
- Data Layer (Models → MySQL/PostgreSQL)
- Auth Module (Sanctum tokens, Password reset, Email verification)
- Mail & Queue subsystem
- File Storage (public & private)
– Database (Relational)
– External Services
- SMTP (Mailtrap/SMTP provider)
- File storage or cloud (if used)

b. Relationships and Data Flows
– Browser → React SPA: HTTP(s)
– React SPA → Backend API: Axios calls to /api endpoints, attaching access token
– Backend Controllers delegate to Services → Models → Database
– Auth flows: SPA → /auth endpoints → Sanctum issues tokens → SPA stores token (localStorage)
– Mail flows: Backend triggers Mailables → SMTP service
– Storage: API serves file URLs from storage/app/public
– SPA receives JSON, updates UI components & charts

c. Architectural Patterns
– Frontend: Feature-based folder structure, separation between reusable components vs feature modules, use of React Context for global state, React Router for route protection
– Backend: MVC + Service-layer pattern, Request validation, Resource transformers, Repository-style Eloquent models, Laravel Sanctum for SPA auth, queued Mail jobs, standardized config files

d. Key Technologies & Frameworks
– Frontend: React, Vite, Ant Design, ApexCharts, React Router v7, Axios, Context API, Toastify
– Backend: Laravel 10, PHP 8.x, Eloquent ORM, Sanctum, Mail, Queue, MySQL/Postgres
– Deployment hints: Vercel for SPA (vercel.json), Apache/.htaccess in backend/public

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["User's Browser"]:::external

    subgraph "Frontend (React App)"
        UIComp["UI Components"]:::frontend
        click UIComp "https://github.com/teo-information/sistema_reflexo/tree/main/src/components/"

        subgraph "Feature Modules"
            AppModule["Appointments"]:::module
            click AppModule "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/appointments/"
            AppComplete["Completed Appointments"]:::module
            click AppComplete "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/appointmentsComplete/"
            Patients["Patients"]:::module
            click Patients "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/patients/"
            History["Patient History"]:::module
            click History "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/history/"
            Payments["Payments"]:::module
            click Payments "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/payments/"
            Reports["Reports"]:::module
            click Reports "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/reports/"
            Staff["Staff/Therapist"]:::module
            click Staff "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/staff/"
            AuthF["Authentication"]:::module
            click AuthF "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/auth/"
            Stats["Statistics"]:::module
            click Stats "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/statistic/"
            Calendar["Calendar"]:::module
            click Calendar "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/calendar/"
            Config["Configuration"]:::module
            click Config "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/configuration/"
            Home["Home/Dashboard"]:::module
            click Home "https://github.com/teo-information/sistema_reflexo/tree/main/src/features/home/"
        end

        subgraph "API Service Layer"
            APIService["API Service Layer"]:::service
            click APIService "https://github.com/teo-information/sistema_reflexo/tree/main/src/services/api/"
            AxiosConf["Axios Config"]:::service
            click AxiosConf "https://github.com/teo-information/sistema_reflexo/blob/main/src/services/api/Axios/baseConfig.js"
            Methods["HTTP Methods"]:::service
            click Methods "https://github.com/teo-information/sistema_reflexo/blob/main/src/services/api/Axios/MethodsGeneral.js"
            Toast["Toastify Service"]:::service
            click Toast "https://github.com/teo-information/sistema_reflexo/tree/main/src/services/toastify/"
        end

        subgraph "Routing & Auth"
            Router["Router Definitions"]:::service
            click Router "https://github.com/teo-information/sistema_reflexo/blob/main/src/routes/Router.jsx"
            Protected["Protected Routes"]:::service
            click Protected "https://github.com/teo-information/sistema_reflexo/blob/main/src/routes/ProtectedRoute.jsx"
            AuthContext["Auth Context"]:::service
            click AuthContext "https://github.com/teo-information/sistema_reflexo/blob/main/src/routes/AuthContext.jsx"
        end

        subgraph "Global Context"
            UserCtx["UserContext"]:::service
            click UserCtx "https://github.com/teo-information/sistema_reflexo/blob/main/src/context/UserContext.jsx"
            CompanyCtx["CompanyContext"]:::service
            click CompanyCtx "https://github.com/teo-information/sistema_reflexo/blob/main/src/context/CompanyContext.jsx"
        end

        Utils["Utilities"]:::service
        click Utils "https://github.com/teo-information/sistema_reflexo/tree/main/src/utils/"
    end

    subgraph "Backend API (Laravel)"
        subgraph "HTTP Layer"
            RoutesAPI["API Routes"]:::api
            click RoutesAPI "https://github.com/teo-information/sistema_reflexo/blob/main/backend/routes/api.php"
            RoutesAuth["Auth Routes"]:::api
            click RoutesAuth "https://github.com/teo-information/sistema_reflexo/blob/main/backend/routes/auth.php"
            ControllersAPI["API Controllers"]:::api
            click ControllersAPI "https://github.com/teo-information/sistema_reflexo/tree/main/backend/app/Http/Controllers/Api/"
            ControllersAuth["Auth Controllers"]:::api
            click ControllersAuth "https://github.com/teo-information/sistema_reflexo/tree/main/backend/app/Http/Controllers/Auth/"
            EmailCtrl["EmailController"]:::api
            click EmailCtrl "https://github.com/teo-information/sistema_reflexo/blob/main/backend/app/Http/Controllers/Email/EmailController.php"
        end

        subgraph "Business Layer"
            Services["Services"]:::business
            click Services "https://github.com/teo-information/sistema_reflexo/tree/main/backend/app/Services/"
        end

        subgraph "Data Layer"
            Models["Models"]:::data
            click Models "https://github.com/teo-information/sistema_reflexo/tree/main/backend/app/Models/"
            Requests["Requests (Validation)"]:::data
            click Requests "https://github.com/teo-information/sistema_reflexo/tree/main/backend/app/Http/Requests/"
            Resources["Resources (Transformers)"]:::data
            click Resources "https://github.com/teo-information/sistema_reflexo/tree/main/backend/app/Http/Resources/"
        end

        subgraph "Auth Module"
            SanctumCfg["Sanctum Config"]:::api
            click SanctumCfg "https://github.com/teo-information/sistema_reflexo/blob/main/backend/config/sanctum.php"
            VerificationMail["VerificationEmail"]:::api
            click VerificationMail "https://github.com/teo-information/sistema_reflexo/blob/main/backend/app/Mail/VerificationEmail.php"
            FirstLogin["FirstLogin Services"]:::business
            click FirstLogin "https://github.com/teo-information/sistema_reflexo/tree/main/backend/app/Services/FirstLogin/"
        end

        subgraph "Mail & Queue"
            MailCfg["Mail Config"]:::api
            click MailCfg "https://github.com/teo-information/sistema_reflexo/blob/main/backend/config/mail.php"
            QueueCfg["Queue Config"]:::api
            click QueueCfg "https://github.com/teo-information/sistema_reflexo/blob/main/backend/config/queue.php"
            EmailTpl["Email Templates"]:::api
            click EmailTpl "https://github.com/teo-information/sistema_reflexo/tree/main/backend/resources/views/emails/"
        end

        subgraph "Storage"
            PublicStorage["Public Storage"]:::api
            click PublicStorage "https://github.com/teo-information/sistema_reflexo/tree/main/backend/storage/app/public/"
            PublicAssets["Public Assets Serve"]:::api
            click PublicAssets "https://github.com/teo-information/sistema_reflexo/tree/main/backend/public/"
        end
    end

    DB["Relational Database"]:::database
    click DB "https://github.com/teo-information/sistema_reflexo/tree/main/backend/database/"

    SMTP["SMTP Service"]:::external
    CloudStorage["File Storage/Cloud"]:::external

    %% Connections
    Browser --> UIComp
    UIComp --> APIService
    AppModule --> APIService
    AppComplete --> APIService
    Patients --> APIService
    History --> APIService
    Payments --> APIService
    Reports --> APIService
    Staff --> APIService
    AuthF --> Router
    Stats --> APIService
    Calendar --> APIService
    Config --> APIService
    Home --> APIService

    APIService --> RoutesAPI
    APIService --> RoutesAuth
    RoutesAPI --> ControllersAPI
    RoutesAuth --> ControllersAuth
    ControllersAPI --> Services
    ControllersAuth --> Services
    Services --> Models
    Models --> DB

    ControllersAPI --> MailCfg
    ControllersAPI --> QueueCfg
    QueueCfg --> SMTP

    ControllersAPI --> PublicAssets
    PublicStorage --> CloudStorage

    %% Styles
    classDef frontend fill:#CFE2F3,stroke:#004E8D,stroke-width:1px;
    classDef module fill:#D9EAD3,stroke:#38761D,stroke-width:1px;
    classDef service fill:#FFF2CC,stroke:#7F6000,stroke-width:1px;
    classDef api fill:#FCE5CD,stroke:#B45F06,stroke-width:1px;
    classDef business fill:#EAD1DC,stroke:#741B47,stroke-width:1px;
    classDef data fill:#D9D2E9,stroke:#3C1361,stroke-width:1px;
    classDef database fill:#CCCCCC,stroke:#666666,stroke-width:1px,stroke-dasharray: 5 5;
    classDef external fill:#F4CCCC,stroke:#CC0000,stroke-width:1px,stroke-dasharray: 2 2;
```
