# mateusribeirocampos/dragenda architecture

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

- Interactive diagram: https://gitdiagram.com/mateusribeirocampos/dragenda
- Repository: https://github.com/mateusribeirocampos/dragenda

## Overview

##### Backend API (dragenda-api)
- Built with Node.js and Express.
- Contains a clear MVC-inspired separation: controllers (handling HTTP requests), services (business logic), repositories (data access), and middlewares (e.g., rate limiting).
- Manages a SQLite database for storing users, doctors, services, appointments, and admin data.
- Environment configuration is supported via .env files (with a sample provided).

##### Frontend Web (dragenda-web)
- Developed using React 18 and bundled with Vite.
- Contains routing, component libraries, and integration with the backend API for functions like appointment scheduling and login.
- Deployment details on Vercel are noted, with clear separation of components (Navigation, pages, error handling, etc.).

##### Mobile App (dragenda-mobile)
- Developed with React Native (powered by Expo) to ensure mobile-first responsiveness.
- Contains UI components like appointments, doctors, and services, alongside context and routes for handling authentication and navigation.

a. Main Components:
- API Server (Backend) that handles authentication, business logic, and database interactions.
- Database (SQLite) that stores users, doctors, services, appointments, and admin records.
- Web Client (Frontend) deployed on Vercel.
- Mobile Client (React Native) for Android/iOS devices.
- Auxiliary components like Auth Service (JWT-based authentication) and Security Middleware (rate limiter).

b. Relationships and Interactions:
- That the API interacts with the SQLite database.
- Authentication interactions (JWT token exchange and validation) between the API and the clients.
- External services like push notifications or third-party libraries if applicable (e.g., JWT, express-rate-limit).

c. Architectural Patterns and Design Principles:
- Adopt an MVC-inspired layered structure for the backend (controllers, services, repositories).
- Separation of concerns between client-side (React/Vite and React Native via Expo) and server-side.
- If needed, show how middleware (e.g., rate limiting) and utilities (e.g., token management) integrate into the overall processing pipeline.
- Cross-platform compatibility since both a web and mobile client are served.

d. Technologies and Frameworks:
- Backend: Node.js, Express, SQLite, JWT (authentication), additional security middlewares.
- Frontend: React, Vite, react-router-dom, axios.
- Mobile: React Native, Expo, react-navigation.

- For a full-stack application like this, visually separate the frontend (subdivide into mobile and web if space allows) and backend components.
- Data flow: Clients (Web & Mobile) → API → Database.
- Auxiliary services (security, authentication) that cross-cut the API layer.

- Use clear labels for each major component (e.g., "API Server (Node.js/Express)", "Frontend Web (React)", "Mobile App (React Native)", "Database (SQLite)").

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Subgraphs
    subgraph "Frontend Web Client"
        WEB["Frontend Web (React/Vite)"]:::client
        WEBNAV["Web Navigation (Components)"]:::client
        WEBPAGES["Web Pages"]:::client
        VITE["Vite Config"]:::client
        INDEX["Index HTML"]:::client
    end

    subgraph "Mobile App Client"
        MOBILE["Mobile App (React Native/Expo)"]:::client
        MUI["Mobile UI Components"]:::client
        MNAV["Mobile Navigation & Routing"]:::client
        MScreens["Mobile Screens & Views"]:::client
        MAUTH["Mobile Auth Context"]:::client
    end

    %% Backend API Subgraph
    subgraph "API Server (Node.js/Express)"
        API["API Server (Node.js/Express)"]:::backend
        CONT["Controllers"]:::backend
        SERV["Services"]:::backend
        REPO["Repositories"]:::backend
        SEC["Security Middleware (Rate Limiter)"]:::backend
        ENV["Environment Configuration (.env)"]:::backend
    end

    %% Database Node
    DB["Database (SQLite)"]:::db

    %% Connections from Clients to Backend (via Security Middleware)
    WEB -->|"HTTP_Request"| SEC
    MOBILE -->|"HTTP_Request"| SEC

    %% Backend internal flow
    SEC -->|"passes"| CONT
    ENV -->|"configures"| CONT
    CONT -->|"calls"| SERV
    SERV -->|"invokes"| REPO
    REPO -->|"data_access"| DB

    %% Additional connections within Frontend Web Client
    WEB --> WEBNAV
    WEB --> WEBPAGES
    WEB --> VITE
    WEB --> INDEX

    %% Additional connections within Mobile App Client
    MOBILE --> MUI
    MOBILE --> MNAV
    MOBILE --> MScreens
    MOBILE --> MAUTH

    %% Click Events
    click API "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-api"
    click CONT "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-api/src/controllers"
    click SERV "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-api/src/services"
    click REPO "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-api/src/repositories"
    click SEC "https://github.com/mateusribeirocampos/dragenda/blob/main/dragenda-api/src/middlewares/rateLimit.js"
    click ENV "https://github.com/mateusribeirocampos/dragenda/blob/main/dragenda-api/.env.example"
    click DB "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-api/src/database"
    click WEB "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-web"
    click WEBNAV "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-web/src/components/Navigation"
    click WEBPAGES "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-web/src/pages"
    click VITE "https://github.com/mateusribeirocampos/dragenda/blob/main/dragenda-web/vite.config.js"
    click INDEX "https://github.com/mateusribeirocampos/dragenda/blob/main/dragenda-web/index.html"
    click MOBILE "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-mobile"
    click MUI "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-mobile/src/components"
    click MNAV "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-mobile/src/routes"
    click MScreens "https://github.com/mateusribeirocampos/dragenda/tree/main/dragenda-mobile/src/screens"
    click MAUTH "https://github.com/mateusribeirocampos/dragenda/blob/main/dragenda-mobile/src/contexts/auth.js"

    %% Styles
    classDef client fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef db fill:#C3F7C0,stroke:#333,stroke-width:2px;
```
