# gbaldessari/idwm-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/gbaldessari/idwm-frontend
- Repository: https://github.com/gbaldessari/idwm-frontend

## Overview

##### Project Type and Purpose
- This is a mobile application built (likely with React Native/Expo, as indicated by files such as App.tsx, app.json, babel.config.js) designed to facilitate time marking with geolocation.
- The README emphasizes that it’s used for an academic assignment in web/mobile development, implying a focus on demonstrating robust mobile application design including navigation, state management, and service integrations.

##### Analyzing the File Structure
- Top-level files (App.tsx, app.json, package.json, tsconfig.json) set up the mobile application configuration.
- The src directory is divided into several key parts:
a. Navigators (e.g., adminStack.navigator.tsx, homeStack.navigator.tsx, outsideStack.navigator.tsx) – these define the routing logic and transitions between different screen groups.
b. Screens (split into subdirectories for inside and outside views) – these represent the UI for both authenticated (inside) and unauthenticated or initial (outside) states. There are further subdivisions (admin, home, settings) which likely correspond to user roles or functionalities.
c. Schemas – these files indicate validation for user inputs (login, register, password management) and help enforce data integrity.
d. Services – this includes modules like auth.service.ts and registers.service.ts for business logic and API integration.
e. useStores – custom hooks for state management (for example, token storage, admin checks, etc.).
f. Styles and Utils – these directories manage presentation layers and helper utilities (like date utilities).

##### Key Components to Cover
a. Frontend UI Components:
- Screens: Divided into “inside” (authenticated/dashboard) and “outside” (login, register, password recovery) sections with dedicated screens for admin, home, and settings.
- Navigators: Multiple navigator stacks (admin, home, config, tab, outside) that structure the navigation flow.
b. Business Logic Services:
- Auth and Registers Services: Responsible for tasks like user authentication, registration, time stamping and retrieving registers.
c. Data Validation:
- Schemas: Used to validate user inputs across various screens (login, registration, updating profile/password, etc.).
d. State Management:
- useStores modules: Custom hooks that manage global states such as user tokens, selected registers, mail, and admin status.
e. Supporting Layers:
- Styles: CSS/StyleSheet definitions for visual consistency across screens.
- Utilities: Helper functions (like date utils) that support business logic.

##### Relationships and Interactions
- Each Screen (UI component) calls Services (auth, registers) to perform operations, and these services update or get data managed via the useStores (state management).
- Schemas provide validation when user input is processed on the screens before sending data to the services.
- Utility modules support both the screens and services with common functions (e.g., formatting dates).

##### Architectural Patterns and Technologies
- The project follows a component-based architecture typical of React (or React Native) applications.
- The separation of navigators, screens, and services suggests adherence to a sort of MVC-like or layered approach, where:
- “Models” could be seen in the services and state management layers.
- “Views” reside in the screens.
- “Controllers” are implicit in the way navigators direct traffic between screens.
- The inclusion of custom hooks (useStores) reflects modern state management practices in a React ecosystem.

## Diagram (Mermaid)

```mermaid
graph TD
    %% UI Layer
    subgraph "UI Layer"
        N["Navigators"]
        SO["Screens - Outside"]
        SI["Screens - Inside"]
        ST["Styles"]
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        A["Auth Service"]
        R["Registers Service"]
        SC["Schemas"]
        SM["State Management"]
    end

    %% Supporting Modules
    subgraph "Supporting Modules"
        UT["Utilities"]
    end

    %% Navigation Flow
    N -->|"routes_to"| SO
    N -->|"routes_to"| SI

    %% Screens and Services Interaction
    SO -->|"calls"| A
    SI -->|"calls"| R

    %% Screens and Validation
    SO -->|"validates_with"| SC
    SI -->|"validates_with"| SC

    %% Service and State Management
    A -->|"updates"| SM
    R -->|"updates"| SM

    %% Service and Utilities Interaction
    A -->|"utilizes"| UT
    R -->|"utilizes"| UT

    %% UI Styling
    SO -->|"styled_by"| ST
    SI -->|"styled_by"| ST

    %% Click Events
    click N "https://github.com/gbaldessari/idwm-frontend/tree/master/src/navigators"
    click SO "https://github.com/gbaldessari/idwm-frontend/tree/master/src/screens/outside"
    click SI "https://github.com/gbaldessari/idwm-frontend/tree/master/src/screens/inside"
    click A "https://github.com/gbaldessari/idwm-frontend/blob/master/src/services/auth/auth.service.ts"
    click R "https://github.com/gbaldessari/idwm-frontend/blob/master/src/services/registers/registers.service.ts"
    click SC "https://github.com/gbaldessari/idwm-frontend/tree/master/src/schemas"
    click SM "https://github.com/gbaldessari/idwm-frontend/tree/master/src/useStores"
    click ST "https://github.com/gbaldessari/idwm-frontend/tree/master/src/styles"
    click UT "https://github.com/gbaldessari/idwm-frontend/tree/master/src/utils"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef support fill:#FFDAB9,stroke:#000,stroke-width:2px;

    class N,SO,SI,ST ui;
    class A,R,SC,SM business;
    class UT support;
```
