# usmql/ecb-fis-main architecture

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

- Interactive diagram: https://gitdiagram.com/usmql/ecb-fis-main
- Repository: https://github.com/usmql/ecb-fis-main

## Overview

##### Main Components Identification
- App Entry Point: Start with App.js (the central entry point for the application) that sets up navigation and global configuration.
- Screens: Represent the various “pages” or views (HomeScreen, ExerciseScreen, LoginScreen, etc.) grouped inside the screens directory. These screens handle user interactions and navigation.
- UI Components: The components directory includes reusable UI pieces such as DailyExercise, HeaderStyle, ProfileImage, SignOutButton, etc. Indicate these as part of the presentation layer.
- Utility Layer: The utils directory contains helper functions (e.g., firebaseUtils, initUser, obtenerEjercicio) which encapsulate logic that connects to backend services, handles navigation overrides, and other business functionality.
- External Services/Backend: Highlight Firebase integration via firebase-config.js and the .env configuration in the README. This external service is responsible for authentication, data storage, and potentially other backend operations.
- Assets: The assets directory stores static resources (images, fonts, etc.) that the UI components and screens utilize.

##### Relationships and Interactions
- App.js serves as the orchestrator that initializes the application, sets up navigation stacks, and incorporates the screens.
- Screens interact with the reusable UI components to maintain layout consistency.
- Both screens and components make calls to functions in the utils folder, which abstract away the interaction with Firebase and other logic.
- That there is a clear separation between UI/presentation (screens, components) and logic/integration (utils, firebase-config.js).

##### Architectural Patterns and Design Principles
- Component-based architecture: Emphasize modular UI components that keep the design both reusable and maintainable.
- Separation of Concerns: Clearly differentiate between presentation (screens and components), business logic (utils), and external service integration (Firebase configuration and calls).
- Client-First Design: Since this is a React Native app that leverages Expo, highlight the frontend-centric approach with emphasis on user experience and navigation flow.
- Dependency Injection & Config Management: The use of a .env file (implied in the README) demonstrates sensitivity to secure configuration management, keeping sensitive credentials separated.

##### Relevant Technologies and Frameworks
- React Native with Expo (App initialization, navigation, and overall app lifecycle).
- Firebase for backend services (authentication, data storage, etc.).
- JavaScript (with ES6 features) as the programming language tying everything together.
- Node.js environment for dependency management using npm.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        App["App.js (Entry Point)"]:::ui
        subgraph "Screens"
            HomeScreen["HomeScreen"]:::ui
            ExerciseScreen["ExerciseScreen"]:::ui
            LoginScreen["LoginScreen"]:::ui
            ProfileScreen["ProfileScreen"]:::ui
            LoadingScreen["LoadingScreen"]:::ui
            RecPasswordScreen["RecPasswordScreen"]:::ui
            StatsScreen["StatsScreen"]:::ui
            UploadScreen["UploadScreen"]:::ui
        end
        subgraph "UI Components"
            DailyExercise["DailyExercise"]:::ui
            GoBackButton["GoBackButton"]:::ui
            HeaderStyle["HeaderStyle"]:::ui
            ProfileHomeButton["ProfileHomeButton"]:::ui
            ProfileImage["ProfileImage"]:::ui
            Saludo["Saludo"]:::ui
            SignOutButton["SignOutButton"]:::ui
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        subgraph "Utility Functions"
            backAction["backAction.js"]:::logic
            firebaseUtils["firebaseUtils.js"]:::logic
            initUser["initUser.js"]:::logic
            obtenerEjercicio["obtenerEjercicio.js"]:::logic
            seleccionarImagen["seleccionarImagen.js"]:::logic
            statsGlobales["statsGlobales.js"]:::logic
        end
    end

    %% External Service Layer
    subgraph "External Service Layer"
        FirebaseBackend["Firebase Backend"]:::external
        firebase_config["firebase-config.js"]:::external
    end

    %% Static Assets
    subgraph "Static Assets"
        assets["assets"]:::assets
    end

    %% Relationships from App Entry Point to Screens
    App -->|"navigates_to"| HomeScreen
    App -->|"navigates_to"| ExerciseScreen
    App -->|"navigates_to"| LoginScreen
    App -->|"navigates_to"| ProfileScreen
    App -->|"navigates_to"| LoadingScreen
    App -->|"navigates_to"| RecPasswordScreen
    App -->|"navigates_to"| StatsScreen
    App -->|"navigates_to"| UploadScreen

    %% Screens using UI Components
    HomeScreen -->|"uses"| HeaderStyle
    LoginScreen -->|"uses"| SignOutButton
    ExerciseScreen -->|"uses"| DailyExercise

    %% UI Components utilizing Assets
    HeaderStyle -->|"displays_asset"| assets

    %% UI interactions calling Utility Functions
    LoginScreen -->|"calls"| firebaseUtils
    ProfileScreen -->|"calls"| initUser
    ExerciseScreen -->|"calls"| obtenerEjercicio
    UploadScreen -->|"calls"| seleccionarImagen
    StatsScreen -->|"calls"| statsGlobales
    GoBackButton -->|"handles"| backAction

    %% Utility Functions interacting with External Service (Firebase)
    firebaseUtils -->|"interacts_with"| FirebaseBackend
    firebaseUtils -->|"configured_by"| firebase_config
    FirebaseBackend -->|"responds_to"| firebaseUtils

    %% Click Events
    click App "https://github.com/usmql/ecb-fis-main/blob/dev/App.js"
    click HomeScreen "https://github.com/usmql/ecb-fis-main/blob/dev/screens/HomeScreen.js"
    click ExerciseScreen "https://github.com/usmql/ecb-fis-main/blob/dev/screens/ExerciseScreen.js"
    click LoginScreen "https://github.com/usmql/ecb-fis-main/blob/dev/screens/LoginScreen.js"
    click ProfileScreen "https://github.com/usmql/ecb-fis-main/blob/dev/screens/ProfileScreen.js"
    click LoadingScreen "https://github.com/usmql/ecb-fis-main/blob/dev/screens/LoadingScreen.js"
    click RecPasswordScreen "https://github.com/usmql/ecb-fis-main/blob/dev/screens/RecPasswordScreen.js"
    click StatsScreen "https://github.com/usmql/ecb-fis-main/blob/dev/screens/StatsScreen.js"
    click UploadScreen "https://github.com/usmql/ecb-fis-main/blob/dev/screens/UploadScreen.js"
    
    click DailyExercise "https://github.com/usmql/ecb-fis-main/blob/dev/components/DailyExercise.js"
    click GoBackButton "https://github.com/usmql/ecb-fis-main/blob/dev/components/GoBackButton.js"
    click HeaderStyle "https://github.com/usmql/ecb-fis-main/blob/dev/components/HeaderStyle.js"
    click ProfileHomeButton "https://github.com/usmql/ecb-fis-main/blob/dev/components/ProfileHomeButton.js"
    click ProfileImage "https://github.com/usmql/ecb-fis-main/blob/dev/components/ProfileImage.js"
    click Saludo "https://github.com/usmql/ecb-fis-main/blob/dev/components/Saludo.js"
    click SignOutButton "https://github.com/usmql/ecb-fis-main/blob/dev/components/SignOutButton.js"
    
    click backAction "https://github.com/usmql/ecb-fis-main/blob/dev/utils/backAction.js"
    click firebaseUtils "https://github.com/usmql/ecb-fis-main/blob/dev/utils/firebaseUtils.js"
    click initUser "https://github.com/usmql/ecb-fis-main/blob/dev/utils/initUser.js"
    click obtenerEjercicio "https://github.com/usmql/ecb-fis-main/blob/dev/utils/obtenerEjercicio.js"
    click seleccionarImagen "https://github.com/usmql/ecb-fis-main/blob/dev/utils/seleccionarImagen.js"
    click statsGlobales "https://github.com/usmql/ecb-fis-main/blob/dev/utils/statsGlobales.js"
    
    click firebase_config "https://github.com/usmql/ecb-fis-main/blob/dev/firebase-config.js"
    click assets "https://github.com/usmql/ecb-fis-main/tree/dev/assets"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#0056b3,stroke-width:2px;
    classDef logic fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef assets fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
