# shadowmasteraj/toilocator architecture

> Architecture diagram of the GitHub repository shadowmasteraj/toilocator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shadowmasteraj/toilocator
- Repository: https://github.com/shadowmasteraj/toilocator

## Overview

##### Main Components

a. Client-Side (Mobile Application)
- Frontend Layer (Flutter UI)
- State Management Layer
- Service Layer
- Model Layer

b. Backend Services
- Firebase Authentication
- Firebase Database
- Google Maps Services

##### Detailed Component Breakdown

Frontend Layer (Purple):
- Auth Screens
- Home Map Screen
- Profile Screen
- Review Input Screen
- Reusable Widgets

Service Layer (Blue):
- Authentication Service
- User Database Service
- Toilet Information Service
- Directions Service
- Image Service

Data Layer (Green):
- User Model
- Toilet Model
- Review Model
- Location Data

External Services (Orange):
- Firebase Authentication
- Firebase Realtime Database
- Google Maps API
- Toilet.org Data Source

##### Architecture Pattern

**[UI Layer]**
- ↕
**[Service Layer]**
- ↕
**[Data Layer]**
- ↕
**[External Services]**

##### Key Relationships to Highlight

- User Authentication Flow:
Auth Screen → Auth Service → Firebase Auth

- Toilet Location Flow:
Screen → Google Maps Service → Location Data

- Review System Flow:
Review Input → Database Service → Firebase Database

##### Specific Implementation Details

- Clear labels for each component

##### Important Features to Emphasize

- Real-time location tracking
- Toilet search functionality
- Review system
- User authentication
- Direction services
- Image management

##### Technical Specifications

Technical elements:
- Flutter/Dart as main framework
- Firebase for backend services
- Google Maps API integration
- Local data storage
- External data scraping pipeline

##### Data Flow Patterns

Key flows:
- User authentication and session management
- Location data retrieval and processing
- Review submission and storage
- Image upload and retrieval

Remember to include:
- Component boundaries
- Data flow directions
- API endpoints
- Storage systems
- User interaction paths
- External service integrations

This will provide a clear understanding of how the various components of Toilocator interact while maintaining a focus on the core functionality of helping users locate and review public toilets.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#E6E6FA,stroke:#000
    classDef service fill:#ADD8E6,stroke:#000
    classDef data fill:#90EE90,stroke:#000
    classDef external fill:#FFA500,stroke:#000

    %% Frontend Layer
    subgraph Frontend
        AuthScreen["Auth Screen"]:::frontend
        HomeMapScreen["Home Map Screen"]:::frontend
        ProfileScreen["Profile Screen"]:::frontend
        ReviewScreen["Review Input Screen"]:::frontend
        ReusableWidgets["Reusable Widgets"]:::frontend
    end

    %% Service Layer
    subgraph Services
        AuthService["Authentication Service"]:::service
        UserDBService["User Database Service"]:::service
        ToiletService["Toilet Information Service"]:::service
        DirectionsService["Directions Service"]:::service
        ImageService["Image Service"]:::service
    end

    %% Data Layer
    subgraph Models
        UserModel["User Model"]:::data
        ToiletModel["Toilet Model"]:::data
        ReviewModel["Review Model"]:::data
        LocationData["Location Data"]:::data
    end

    %% External Services
    subgraph External
        Firebase["Firebase Authentication"]:::external
        FirebaseDB["Firebase Realtime Database"]:::external
        GoogleMaps["Google Maps API"]:::external
        ToiletData["Toilet.org Data Source"]:::external
    end

    %% Relationships
    AuthScreen --> AuthService
    AuthScreen --> ReusableWidgets
    HomeMapScreen --> ToiletService
    HomeMapScreen --> DirectionsService
    HomeMapScreen --> ReusableWidgets
    ProfileScreen --> UserDBService
    ReviewScreen --> ToiletService
    ReviewScreen --> ImageService

    AuthService --> Firebase
    UserDBService --> FirebaseDB
    ToiletService --> FirebaseDB
    ToiletService --> ToiletData
    DirectionsService --> GoogleMaps
    ImageService --> FirebaseDB

    ToiletService --> ToiletModel
    UserDBService --> UserModel
    ToiletService --> ReviewModel
    DirectionsService --> LocationData

    %% Click Events
    click AuthScreen "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/screens/auth_screen.dart"
    click HomeMapScreen "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/screens/home_map_screen.dart"
    click ProfileScreen "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/screens/profile_screen.dart"
    click ReviewScreen "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/screens/input_review_screen.dart"
    click AuthService "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/services/auth.dart"
    click UserDBService "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/services/userDatabase.dart"
    click ToiletService "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/services/getToiletInfo.dart"
    click DirectionsService "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/services/directions.dart"
    click ImageService "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/services/getToiletImageUrlList.dart"
    click UserModel "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/models/user.dart"
    click ToiletModel "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/models/toilet.dart"
    click ReviewModel "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/models/review.dart"
    click ReusableWidgets "https://github.com/ShadowMasterAJ/ToiLocator/tree/main/toilocator/lib/widgets"
    click ToiletData "https://github.com/ShadowMasterAJ/ToiLocator/blob/main/toilocator/lib/data/toilets.json"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Service_L["Services"]:::service
        Data_L["Data Layer"]:::data
        External_L["External Services"]:::external
    end
```
