# juancomparan/diabetesapp architecture

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

- Interactive diagram: https://gitdiagram.com/juancomparan/diabetesapp
- Repository: https://github.com/juancomparan/diabetesapp

## Overview

##### Project Overview and Type
- DiabetesApp is a mobile application focused on providing quick, accessible, and informative content about diabetes, including educational information, diet recommendations, treatments, and diagnostic guidelines.
- The project is structured as a full-stack application with two main parts: a mobile frontend built using React Native (with Expo) and a backend service built using Node.js with Express and SQLite as the database.

##### File Structure
a. Frontend (DiabetesAppFrontEnd):
- Contains mobile app assets, configuration files (app.json, babel.config.js, etc.) and source code primarily found in the "app/src" directory.
- The "app/src" subdirectories include:
- auth: Screens and components related to user authentication, diagnosis, and information pages (like Login, Registro, VerificationCode, ChatBot, etc.).
- components: Reusable UI components (InputComponent, OptionInputComponent, TopBar, TablaDieta) that form the building blocks of the mobile interface.
- home: Screens for general entry points (ForgetPassword, Welcome, etc.).
- Assets such as fonts and images are organized under an assets directory.

b. Backend (DiabetesAppBackEnd):
- Uses Express with the main application logic starting in “src/app.js” and “src/server.js” where the server is initialized.
- Folders include:
- controller: Contains controllers such as authController.js that handle business logic.
- routes: Defines API endpoints (e.g., authRoutes.js).
- middlewares: Houses middleware such as authValidator.js, ensuring security and validation.
- db: Connection logic to SQLite (db.js).
- Additional configuration files include a Dockerfile and .dockerignore, indicating containerization support.

##### Key Architectural Components
a. Mobile Frontend:
- User Interface (React Native screens) organized into authentication, home, and informational content.
- Input components and navigation routing (e.g., using Root Stack for screen transitions).

b. Backend Server:
- Express server handling HTTP requests from the mobile app.
- Routing layer, controllers, and middlewares for processing business logic and validation.
- Database layer interfacing with SQLite.

c. Communication Between Frontend and Backend:
- API calls from React Native app (via endpoints defined in authRoutes.js and others).

d. Containerization:

##### Important Architectural Patterns and Principles
- Separation of Concerns: Clear division between frontend (client-side) and backend (server-side) functionalities.
- API Layer: The mobile app communicates with the backend through RESTful API endpoints.
- Modularity & Reusability: Both frontend and backend are broken into modular components (controllers, routes, middleware for backend; separate screens and UI components for frontend).
- Possibly MVC-esque pattern in the backend where controllers, routes, and database management are distinctly separated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Mobile Frontend" 
        RN["React Native App"]:::frontend
        Auth["Authentication Screens"]:::frontend
        UI["Reusable UI Components"]:::frontend
        Home["Home Screens"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend Service"
        subgraph "Entry Points"
            Server["Server.js"]:::backend
            App["App.js"]:::backend
        end
        AR["API Routes (authRoutes.js)"]:::backend
        MW["Middleware (authValidator.js)"]:::backend
        Ctrl["Controllers (authController.js)"]:::backend
        DB["SQLite DB"]:::db
        subgraph "Deployment"
            DF["Dockerfile"]:::deployment
            DDI[".dockerignore"]:::deployment
        end
    end

    %% Communication between Frontend and Backend
    RN -->|"API_call"| AR

    %% Internal Backend Flow
    Server -->|"init"| AR
    App -->|"init"| AR
    AR -->|"validate"| MW
    MW -->|"process"| Ctrl
    Ctrl -->|"query"| DB
    AR -->|"routes"| Ctrl
    Server -->|"containerized"| DF
    Server -->|"containerized"| DDI

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef db fill:#FFFFE0,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef deployment fill:#FFA500,stroke:#333,stroke-width:2px;

    %% Click Events for Frontend
    click RN "https://github.com/juancomparan/diabetesapp/tree/master/DiabetesAppFrontEnd/app/src"
    click Auth "https://github.com/juancomparan/diabetesapp/tree/master/DiabetesAppFrontEnd/app/src/auth"
    click UI "https://github.com/juancomparan/diabetesapp/tree/master/DiabetesAppFrontEnd/app/src/components"
    click Home "https://github.com/juancomparan/diabetesapp/tree/master/DiabetesAppFrontEnd/app/src/home"

    %% Click Events for Backend
    click Server "https://github.com/juancomparan/diabetesapp/blob/master/DiabetesAppBackEnd/src/server.js"
    click App "https://github.com/juancomparan/diabetesapp/blob/master/DiabetesAppBackEnd/src/app.js"
    click Ctrl "https://github.com/juancomparan/diabetesapp/blob/master/DiabetesAppBackEnd/src/controller/authController.js"
    click AR "https://github.com/juancomparan/diabetesapp/blob/master/DiabetesAppBackEnd/src/routes/authRoutes.js"
    click MW "https://github.com/juancomparan/diabetesapp/blob/master/DiabetesAppBackEnd/src/middlewares/authValidator.js"
    click DB "https://github.com/juancomparan/diabetesapp/blob/master/DiabetesAppBackEnd/src/db/db.js"
    click DF "https://github.com/juancomparan/diabetesapp/tree/master/DiabetesAppBackEnd/Dockerfile"
    click DDI "https://github.com/juancomparan/diabetesapp/blob/master/DiabetesAppBackEnd/.dockerignore"
```
