# nyamwaya/tableties architecture

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

- Interactive diagram: https://gitdiagram.com/nyamwaya/tableties
- Repository: https://github.com/nyamwaya/tableties

## Overview

─────────────────────────────
##### Project Type and Purpose
─────────────────────────────
- The project is a Flutter-based mobile app (with multi-platform support: Android, iOS, macOS, Linux, Windows, and Web) for connecting strangers over dinner based on shared interests.
- Its primary goal is social interaction by pairing users with shared interests, addressing loneliness.
- The application uses the BLoC (Business Logic Component) pattern to manage state and handle user interactions.

─────────────────────────────
##### Main Components of the System
─────────────────────────────
A. Presentation Layer (UI)
- Located predominantly in the "lib/screens" and "lib/widgets" directories.
- Contains various screens such as Login, SignUp, Home, Profile, Match, and Settings.
- Implements the UI for diverse platforms (mobile, web, desktop) as seen by platform-specific directories (android, ios, etc.).

B. Business Logic Layer (BLoC)
- Found in the "lib/blocs" directory with subdirectories for home, login, profile, and signup.
- Manages events and state transitions:
- Events: Represent user interactions (e.g., login, signup, profile update).
- States: Represent UI updates after processing events.
- BLoCs: Act as controllers to bridge events and their resulting states.

C. Data Layer (Repositories/Models)
- Repositories are in "lib/repo" (login_repo, profile_repo, sign_up_repo, supabase_repo).
- Models representing data structures in "lib/data_models" and "lib/models".
- Communication with external services (like Supabase) is encapsulated here.

D. Configuration and Utilities
- Configuration files like "lib/config/routes.dart" and "lib/config/theme.dart" set up navigation and theming.
- Utility classes and services, including "lib/services" for dio_client and preferences_service, aid in API interactions and local data handling.

E. External Services
- Supabase integration for backend services (as noted in the README’s Supabase configuration section).
- Other potential external APIs or services can be included here as part of the repositories.

─────────────────────────────
##### Relationships and Interactions
─────────────────────────────
- The UI dispatches user actions (events) to the appropriate BLoC.
- BLoCs process events, interact with repositories for data (e.g., fetching, updating user data), and then emit new states.
- The UI listens to these state changes and updates the view accordingly.
- Repositories use service classes (like dio_client) for network/API communication with external systems such as Supabase.

─────────────────────────────
##### Architectural Patterns and Design Principles
─────────────────────────────
- The BLoC Pattern – Ensuring a clean separation between UI (presentation) and business logic.
- Separation of Concerns – Clear division between user interface, business logic, and data handling.
- Multi-Platform Support – The presence of platform-specific directories (android, ios, macos, etc.) signifies a design architecture that targets multiple form factors.
- Modularity – Organized folder structure (blocs, repo, models, screens) suggests that each functionality is encapsulated in a dedicated module.

─────────────────────────────

##### Final Touches
─────────────────────────────
- Use a clean layout with hierarchical flow from UI -> BLoC -> Repositories -> External Services.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Presentation Layer (UI)"
        Screens["Screens (Login,Signup,Home,Profile,Match,Settings)"]:::ui
        Widgets["Reusable Widgets"]:::ui
    end

    subgraph "Business Logic Layer (BLoC)"
        Bloc["BLoC Components\n(Events,States,Controllers)"]:::bloc
    end

    subgraph "Data Layer (Repositories & Models)"
        Repos["Repositories"]:::data
        Models["Models & Data Structures"]:::data
    end

    subgraph "Configuration & Utilities"
        Config["Routes & Theme"]:::config
        Utilities["Utility Services\n(Dio,Preferences)"]:::config
    end

    subgraph "External Services"
        Supabase["Supabase Integration"]:::external
        API["API Communication"]:::external
    end

    Screens -->|"dispatchEvent"| Bloc
    Widgets -->|"dispatchEvent"| Bloc
    Bloc -->|"fetchData"| Repos
    Repos -->|"useModels"| Models
    Repos -->|"dataOps"| Supabase
    Repos -->|"dataOps"| API
    Bloc -->|"emitState"| Screens
    Bloc -->|"emitState"| Widgets
    Config -->|"supportUI"| Screens
    Utilities -->|"supportServices"| Repos

    %% Click Events
    click Screens "https://github.com/nyamwaya/tableties/tree/master/lib/screens"
    click Widgets "https://github.com/nyamwaya/tableties/tree/master/lib/widgets"
    click Bloc "https://github.com/nyamwaya/tableties/tree/master/lib/blocs"
    click Repos "https://github.com/nyamwaya/tableties/tree/master/lib/repo"
    click Models "https://github.com/nyamwaya/tableties/tree/master/lib/data_models"
    click Config "https://github.com/nyamwaya/tableties/tree/master/lib/config"
    click Utilities "https://github.com/nyamwaya/tableties/tree/master/lib/services"
    click Supabase "https://github.com/nyamwaya/tableties/blob/master/lib/repo/supabase_repo.dart"
    click API "https://github.com/nyamwaya/tableties/blob/master/lib/services/dio_client.dart"

    %% Styles
    classDef ui fill:#d1e8ff,stroke:#0277bd,stroke-width:2px;
    classDef bloc fill:#ffe082,stroke:#ff8f00,stroke-width:2px;
    classDef data fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;
    classDef config fill:#e1bee7,stroke:#8e24aa,stroke-width:2px;
    classDef external fill:#ffccbc,stroke:#d84315,stroke-width:2px;
```
