# mshivam019/storysail architecture

> Architecture diagram of the GitHub repository mshivam019/storysail, 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/mshivam019/storysail
- Repository: https://github.com/mshivam019/storysail

## Overview

##### Project Type and Purpose
- Story Sail is a mobile application built with Expo and React Native. Its purpose is to allow users to explore captivating stories across various genres.
- The README emphasizes features like notifications, rich text editing, swipeable tabs, sortable lists, deep linking, and integration with Supabase and FCM. This indicates a full-featured mobile front-end that communicates with a backend (Supabase) and uses third-party services (Firebase for notifications).

##### File Structure
- The top-level directories include:
- app: Contains the routing structure, layout files, and screen components (organized as tabs for account, create, explore, favourites, and home).
- assets: Contains static files such as images and JSON used for onboarding and home data.
- components: Provides reusable UI elements for various screens (Create, Explore, Favourites, Home, Onboarding, Settings, etc.).
- provider: Hosts the AuthProvider, which likely manages user authentication states.
- store: Houses state management files (stores for home, notifications, user data, writings, etc.), suggesting a clear separation of presentation and state logic.
- lib: Contains service configuration such as the Supabase connection.
- supabase: Contains backend configuration, functions (like push notifications), migrations, and seeds.
- utils: Contains custom hooks like useHaptic and other utility methods.
- Additional configuration files (e.g., .env.local.example, babel.config.js, tsconfig.json) indicate a standard mobile project setup with environment management, linting, and TypeScript support.

a. Frontend (Mobile Client):
- Expo/React Native App:
- UI Components: Group components by category (e.g., Home cards, Create components like RichEditor and DynamicInput, Onboarding components, etc.).
- Routing and Layouts: Display the hierarchy where higher-level layout components (_layout.tsx files) wrap the child routes.

b. Backend & External Services:
- Supabase Backend:
- Database and API: Represent Supabase as the primary backend service (drawing connections between the mobile client and Supabase), touching upon migrations, seed data, and connection handling via lib/supabase.ts.
- Functions: Indicate the push notification function in supabase/functions/push.
- Firebase Cloud Messaging (FCM):
- External Notification Service: Show how FCM integrates with Supabase and the mobile client (for in-app notifications).

c. Architectural Interactions:
- Data Flow:
- Architectural Patterns:
- Separation of Concerns: Distinction between UI (components/screens), business logic/state (store, providers), and backend integration (lib & supabase).
- Modular Routing: The use of multiple layouts and tabs for organizing different features.
- Dependency Injection: Usage of providers (like AuthProvider) to make authentication and related state available globally.

##### Additional Details to Capture
- In the mobile client section, differentiate between presentation (UI components under app, assets and components directories) and application logic (store and provider directories).
- Routing structure based on the file tree structure under the “app” folder (e.g., tab-based navigation that distinguishes between account, create, explore, favourites, and home).
- Integration points for third-party setups. For instance, mention that environment variables (from .env files) and configuration files (such as google-services.json) are vital when connecting to FCM and Supabase.
- That the Supabase folder is not just a library but also includes database migrations and functions meant to support the mobile app’s functionality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Client"
        subgraph "Screens & Navigation"
            N_tabs["Tabs (Home,Account,Create,Explore,Favourites)"] 
            N_login["Login Screen"]
            N_notif["Notifications Screen"]
            N_onboard["Onboarding Screen"]
            N_profile["Profile Screen"]
            N_tc["Terms & Conditions Screen"]
        end
        N_ui["UI Components"]
        N_store["State Management (Store)"]
        N_provider["Auth Provider"]
    end

    subgraph "Backend Services"
        subgraph "Supabase Backend"
            S_api["Supabase API"]
            S_push["Push Notification Function"]
            S_db["Database (Migrations & Seed)"]
        end
        E_fcm["FCM Notification Service"]
    end

    N_tabs -->|"api_calls"| S_api
    S_api -->|"trigger_push"| S_push
    S_push -->|"send_notification"| E_fcm
    N_provider -->|"auth_inject"| N_tabs
    N_store -->|"state_update"| N_ui

    click N_tabs "https://github.com/mshivam019/storysail/blob/master/app/(tabs)/_layout.tsx"
    click N_login "https://github.com/mshivam019/storysail/blob/master/app/login.tsx"
    click N_notif "https://github.com/mshivam019/storysail/blob/master/app/notifications.tsx"
    click N_onboard "https://github.com/mshivam019/storysail/blob/master/app/onboarding.tsx"
    click N_profile "https://github.com/mshivam019/storysail/blob/master/app/profile.tsx"
    click N_tc "https://github.com/mshivam019/storysail/blob/master/app/tc.tsx"
    click N_ui "https://github.com/mshivam019/storysail/tree/master/components"
    click N_store "https://github.com/mshivam019/storysail/tree/master/store"
    click N_provider "https://github.com/mshivam019/storysail/blob/master/provider/AuthProvider.tsx"
    click S_api "https://github.com/mshivam019/storysail/blob/master/lib/supabase.ts"
    click S_push "https://github.com/mshivam019/storysail/tree/master/supabase/functions/push"
    click S_db "https://github.com/mshivam019/storysail/tree/master/supabase/migrations"
    click E_fcm "https://github.com/mshivam019/storysail/blob/master/google-services.json"

    classDef navigation fill:#ccebc5,stroke:#333,stroke-width:2px;
    classDef ui fill:#fddb92,stroke:#333,stroke-width:2px;
    classDef store fill:#ffc8dd,stroke:#333,stroke-width:2px;
    classDef provider fill:#bde0fe,stroke:#333,stroke-width:2px;
    classDef backend fill:#ffb4a2,stroke:#333,stroke-width:2px;
    classDef external fill:#d0efeb,stroke:#333,stroke-width:2px;

    class N_tabs,N_login,N_notif,N_onboard,N_profile,N_tc navigation;
    class N_ui ui;
    class N_store store;
    class N_provider provider;
    class S_api,S_push,S_db backend;
    class E_fcm external;
```
