# netrix4/adogtame architecture

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

- Interactive diagram: https://gitdiagram.com/netrix4/adogtame
- Repository: https://github.com/netrix4/adogtame

## Overview

##### Project type and purpose
- This is a **mobile full-stack application** built with Expo (React Native + TypeScript) acting as the **frontend**, while **Supabase** provides database, authentication and storage services as the **backend**.
- Its purpose is to connect potential adopters with at-risk dogs and cats via a mobile UI, handle user authentication, fetch/filter animal data, and record user favorites.

##### File structure
- Top-level files & folders:
- App.tsx / index.ts: application entry points
- Screens/: each “screen” in the navigation stack (Login, Register, Dashboard, Home, Profile, etc.)
- Components/: reusable UI building blocks (AnimalCard, AuthGate, CustomTabBar, etc.)
- hooks/: custom React hooks (useAuth for session management, useFiltroAnimales for data filtering)
- lib/supabase.ts: Supabase client instantiation
- app.json, package.json, tsconfig.json, requirements.txt: config & dependency manifests
- No custom backend code—Supabase is consumed as an external service via its JavaScript SDK.

##### Extract key architecture details from README
- Requires Expo SDK 52, Supabase JS client, Lodash.
- The app starts with `npx expo start`, runs on the user’s device/emulator, and communicates directly with Supabase over HTTPS.

##### Main components and their interactions
a. **Mobile App (Expo Client)**
- Entry (App.tsx) → sets up navigation and context providers.
- Screens (Screens/) render full‐screen views.
- Components (Components/) render UI pieces within each screen.
b. **State & Data Layer (hooks/ & lib/)**
- useAuth.ts: manages signup, login, session tokens via supabase.auth.
- useFiltroAnimales.ts: fetches and filters animal records via supabase.from('animals').
- lib/supabase.ts: initializes the Supabase client with URL and anon key.
c. **External Service (Supabase)**
- Authentication: sign up, login, password reset
- Database: tables for users, animals, favorites
- Storage (optional): images for animals
d. **Supporting Tools**
- Expo bundler & Metro server
- Third-party libraries (lodash, @supabase/supabase-js)

##### Architectural patterns & design principles
- **Separation of concerns**: UI (Screens/Components) vs data logic (hooks) vs service client (lib/supabase).
- **Hooks for side effects**: data fetching and auth logic is encapsulated in custom hooks for reusability.
- **Component composition**: atomic UI components (AnimalCard, LoginInputs) are combined in Screens.

##### Essential details
- Navigation flow if helpful (e.g., Login → Home → Profile).
- How favorites are written back to Supabase (useFiltroAnimales or another hook).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile App Container
    subgraph "Mobile App (Expo)"
        direction TB

        %% UI Layer
        subgraph "UI Layer"
            direction TB
            AppEntry1["App.tsx"]:::ui
            AppEntry2["index.ts"]:::ui

            subgraph "Screens"
                direction TB
                Login["Login Screen"]:::ui
                Register["Register Screen"]:::ui
                Dashboard["Dashboard Screen"]:::ui
                RecoverPass["Password Recovery Screen"]:::ui
                ResetPassword["Reset Password Screen"]:::ui
                NotFound["Not Found Screen"]:::ui
            end

            subgraph "Components"
                direction TB
                AnimalCard["Animal Card"]:::ui
                AuthGate["Authentication Gate"]:::ui
                CustomTabBar["Custom Tab Bar"]:::ui
                Favorites["Favorites Button/View"]:::ui
                HomeHeader["Home Header"]:::ui
                LoginInputs["Login Form Inputs"]:::ui
                RegisterInputs["Register Form Inputs"]:::ui
                RegisterConfirmModal["Registration Confirmation Modal"]:::ui
                RecoverInputs["Password Recovery Inputs"]:::ui
                RecoverEmailScreen["Recover Email Screen"]:::ui
                Profile["Profile View"]:::ui
                HomeComp["Home Component"]:::ui
            end
        end

        %% Logic Layer
        subgraph "Logic Layer"
            direction TB
            useAuth["useAuth Hook"]:::logic
            useFiltro["useFiltroAnimales Hook"]:::logic
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            supaClient["Supabase Client"]:::service
        end
    end

    %% External Services
    subgraph "Supabase (External)"
        direction TB
        supAuth["Auth Service"]:::external
        supDB["Database"]:::external
        supStorage["Storage"]:::external
    end

    %% Ancillary
    Expo["Expo Bundler/Metro"]:::external

    %% Connections
    Expo -->|"Launch App"| AppEntry1
    AppEntry1 --> AppEntry2
    AppEntry2 --> Login
    AppEntry2 --> Register
    AppEntry2 --> Dashboard
    AppEntry2 --> RecoverPass
    AppEntry2 --> ResetPassword
    AppEntry2 --> NotFound

    %% UI to Logic
    Login -->|"auth actions"| useAuth
    Register -->|"auth actions"| useAuth
    RecoverPass -->|"password reset"| useAuth
    ResetPassword -->|"password update"| useAuth
    AuthGate -->|"guard routes"| useAuth

    Dashboard -->|"fetch/filter animals"| useFiltro
    HomeComp -->|"list animals"| useFiltro
    Favorites -->|"save favorite"| useFiltro

    %% Logic to Service
    useAuth -->|"supabase.auth calls"| supaClient
    useFiltro -->|"supabase.from('animals') calls"| supaClient

    %% Service to Supabase
    supaClient -->|"HTTPS"| supAuth
    supaClient -->|"HTTPS"| supDB
    supaClient -->|"HTTPS"| supStorage

    %% Click Events
    click AppEntry1 "https://github.com/netrix4/adogtame/blob/main//App.tsx"
    click AppEntry2 "https://github.com/netrix4/adogtame/blob/main//index.ts"
    click Login "https://github.com/netrix4/adogtame/blob/main//Screens/Login.tsx"
    click Register "https://github.com/netrix4/adogtame/blob/main//Screens/Register.tsx"
    click Dashboard "https://github.com/netrix4/adogtame/blob/main//Screens/DashBoard.tsx"
    click RecoverPass "https://github.com/netrix4/adogtame/blob/main//Screens/RecoverPass.tsx"
    click ResetPassword "https://github.com/netrix4/adogtame/blob/main//Screens/RessetPassword.tsx"
    click NotFound "https://github.com/netrix4/adogtame/blob/main//Screens/NotFoundScreen.tsx"
    click AnimalCard "https://github.com/netrix4/adogtame/blob/main//Components/AnimalCard.tsx"
    click AuthGate "https://github.com/netrix4/adogtame/blob/main//Components/AuthGate.tsx"
    click CustomTabBar "https://github.com/netrix4/adogtame/blob/main//Components/CustomTabBar.tsx"
    click Favorites "https://github.com/netrix4/adogtame/blob/main//Components/Favorites.tsx"
    click HomeHeader "https://github.com/netrix4/adogtame/blob/main//Components/ListHeaderHome.tsx"
    click LoginInputs "https://github.com/netrix4/adogtame/blob/main//Components/LoginInputs.tsx"
    click RegisterInputs "https://github.com/netrix4/adogtame/blob/main//Components/RegisterInputs.tsx"
    click RegisterConfirmModal "https://github.com/netrix4/adogtame/blob/main//Components/RegisterConfirmModal.tsx"
    click RecoverInputs "https://github.com/netrix4/adogtame/blob/main//Components/RecoverInputs.tsx"
    click RecoverEmailScreen "https://github.com/netrix4/adogtame/blob/main//Components/RecoverEmailScreen.tsx"
    click Profile "https://github.com/netrix4/adogtame/blob/main//Components/Profile.tsx"
    click HomeComp "https://github.com/netrix4/adogtame/blob/main//Components/Home.tsx"
    click useAuth "https://github.com/netrix4/adogtame/blob/main//hooks/useAuth.ts"
    click useFiltro "https://github.com/netrix4/adogtame/blob/main//hooks/useFiltroAnimales.ts"
    click supaClient "https://github.com/netrix4/adogtame/blob/main//lib/supabase.ts"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366d6,color:#0366d6
    classDef logic fill:#DFF5D0,stroke:#2E7D32,color:#2E7D32
    classDef service fill:#FFE8B0,stroke:#FF8C00,color:#FF8C00
    classDef external fill:#E1D0FF,stroke:#6A1B9A,color:#6A1B9A
```
