# ruddyp/sleepie-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/ruddyp/sleepie-frontend
- Repository: https://github.com/ruddyp/sleepie-frontend

## Overview

##### Project Type and Purpose
- Sleepie-frontend is a mobile front-end application built in React Native.
- Its purpose is to present screens for discovery, playback, creation, user auth, and settings; manage app state; and communicate with a backend service for content (stories, tracks, user data).

##### File Structure
Top-level:
- App.js / index.js – app entry point
- app.json, eas.json – Expo/React Native config
- components – reusable UI & feature components (Create, Player, KitUI, SignIn, SignUp…)
- screens – full-screen views (Home, Discover, Favorites, Create, Login, Profil, etc.)
- modules – pure JS utilities, constants, database actions, API wrappers
- reducers – Redux reducers for createForm, modal, stories, track, users
- service.js – REST API client
- sleepTimerStore.js – local state/persistence for timer
- package.json – dependencies

##### Pull Insights from README
- README simply names the project. The file names and folders confirm a Redux-backed React Native app connecting to external services for media and user data.

##### Main Components
a. Presentation Layer
- Screens (Home, Discover, Favorites, Create, etc.)
- Reusable Components (KitUI, Player widgets, CreateForm steps, Modals)
b. State Management Layer
- Redux Store (reducers folder)
- Actions & Action Creators (modules/databaseAction.js, modules/utils.js)
- sleepTimerStore (local persistent store)
c. Data Layer / API
- service.js (REST client)
- External Backend Services (Authentication API, Stories API, Tracks API)
d. Assets & Configuration
- assets directory
- app.json / eas.json

##### Relationships and Interactions
- Screens mount Components → dispatch Redux Actions → pass through Reducers → update Store → mapStateToProps back into Screens/Components.
- service.js calls to External Backend → returns JSON → dispatch success/failure Actions.
- sleepTimerStore manages local timer state for the Player.

##### Architectural Patterns / Design Principles
- Unidirectional Data Flow (Redux)
- Container vs. Presentational Components (Screens vs. KitUI elements)
- Modularization (modules folder for shared logic, components folder for UI)
- Feature Breakdown (CreateForm is its own sub-feature with steps/Modals)

##### Technologies/Frameworks to Call Out
- React Native + Expo
- Redux for state management
- REST API client (fetch/axios wrapper in service.js)
- Local storage/persistence (sleepTimerStore)
- React Navigation (implicitly via screens folder)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define nodes
    RNApp["React Native App"]:::ui
    subgraph "Presentation Layer"
        direction TB
        subgraph Screens
            direction TB
            Home["Home Screen"]:::ui
            Discover["Discover Screen"]:::ui
            Favorites["Favorites Screen"]:::ui
            CreateScreen["Create Screen"]:::ui
            Login["Login Screen"]:::ui
            Profil["Profil Screen"]:::ui
            Welcome["Welcome Screen"]:::ui
            KitScreen["Kit Screen"]:::ui
            Meditation["Meditation Screen"]:::ui
            Playlist["Playlist Screen"]:::ui
        end
        subgraph "Reusable Components"
            direction TB
            CreateComponents["Create Feature Components"]:::ui
            CreateForm["CreateForm Steps & Modals"]:::ui
            KitUI["KitUI Library"]:::ui
            PlayerWidgets["Player Widgets"]:::ui
            AuthComponents["Authentication Components"]:::ui
            Header["Header Component"]:::ui
        end
    end

    subgraph "State Management Layer"
        direction TB
        ReduxStore["Redux Store"]:::state
        subgraph Reducers
            direction TB
            CF["createForm reducer"]:::state
            MDL["modal reducer"]:::state
            STR["stories reducer"]:::state
            TRK["track reducer"]:::state
            USR["users reducer"]:::state
        end
        subgraph Actions_Utils
            direction TB
            DBAct["databaseAction.js"]:::state
            CheckIn["checkInput.js"]:::state
            Filter["filter.js"]:::state
            Const["constant.js"]:::state
            Utils["utils.js"]:::state
        end
        SleepTimer["Sleep Timer Store"]:::state
    end

    subgraph "Data Layer / API"
        direction TB
        Service["service.js (REST Client)"]:::data
        External["External Backend Services"]:::data
    end

    subgraph "Assets & Configuration"
        direction TB
        Assets["Static Assets"]:::config
        AppConfig["app.json / eas.json"]:::config
        Package["package.json"]:::config
    end

    %% Connections
    RNApp -->|"renders"| Home
    RNApp -->|"renders"| Discover
    RNApp -->|"renders"| Favorites
    RNApp -->|"renders"| CreateScreen
    RNApp -->|"renders"| Login
    RNApp -->|"renders"| Profil
    RNApp -->|"renders"| Welcome
    RNApp -->|"renders"| KitScreen
    RNApp -->|"renders"| Meditation
    RNApp -->|"renders"| Playlist

    RNApp -->|"includes"| CreateComponents
    RNApp -->|"includes"| CreateForm
    RNApp -->|"includes"| KitUI
    RNApp -->|"includes"| PlayerWidgets
    RNApp -->|"includes"| AuthComponents
    RNApp -->|"includes"| Header

    Home -->|dispatches actions| ReduxStore
    Discover -->|dispatches actions| ReduxStore
    Favorites -->|dispatches actions| ReduxStore
    CreateScreen -->|dispatches actions| ReduxStore
    Login -->|dispatches actions| ReduxStore
    Profil -->|dispatches actions| ReduxStore

    CreateComponents -->|uses| Service
    CreateForm -->|uses| Service
    KitUI -->|uses| Service
    PlayerWidgets -->|uses| Service
    AuthComponents -->|uses| Service

    Service -->|calls| External
    External -->|returns JSON| ReduxStore

    ReduxStore -->|updates| Home
    ReduxStore -->|updates| Discover
    ReduxStore -->|updates| Favorites
    ReduxStore -->|updates| CreateScreen
    ReduxStore -->|updates| Login
    ReduxStore -->|updates| Profil

    ReduxStore --> CF & MDL & STR & TRK & USR
    DBAct --> ReduxStore
    CheckIn --> ReduxStore
    Filter --> ReduxStore
    Const --> ReduxStore
    Utils --> ReduxStore

    SleepTimer --> PlayerWidgets

    RNApp --> Assets
    RNApp --> AppConfig
    RNApp --> Package

    %% Click Events
    click RNApp "https://github.com/ruddyp/sleepie-frontend/blob/main/App.js"
    click Home "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Home.js"
    click Discover "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Discover.js"
    click Favorites "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Favorites.js"
    click CreateScreen "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Create.js"
    click Login "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Login.js"
    click Profil "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Profil.js"
    click Welcome "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Welcome.js"
    click KitScreen "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/KitScreen.js"
    click Meditation "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Meditation.js"
    click Playlist "https://github.com/ruddyp/sleepie-frontend/blob/main/screens/Playlist.js"
    click CreateComponents "https://github.com/ruddyp/sleepie-frontend/tree/main/components/Create"
    click CreateForm "https://github.com/ruddyp/sleepie-frontend/tree/main/components/CreateForm"
    click KitUI "https://github.com/ruddyp/sleepie-frontend/tree/main/components/KitUI"
    click PlayerWidgets "https://github.com/ruddyp/sleepie-frontend/tree/main/components/Player"
    click AuthComponents "https://github.com/ruddyp/sleepie-frontend/blob/main/components/SignIn.js"
    click Header "https://github.com/ruddyp/sleepie-frontend/blob/main/components/header.js"
    click CF "https://github.com/ruddyp/sleepie-frontend/blob/main/reducers/createForm.js"
    click MDL "https://github.com/ruddyp/sleepie-frontend/blob/main/reducers/modal.js"
    click STR "https://github.com/ruddyp/sleepie-frontend/blob/main/reducers/stories.js"
    click TRK "https://github.com/ruddyp/sleepie-frontend/blob/main/reducers/track.js"
    click USR "https://github.com/ruddyp/sleepie-frontend/blob/main/reducers/users.js"
    click DBAct "https://github.com/ruddyp/sleepie-frontend/blob/main/modules/databaseAction.js"
    click CheckIn "https://github.com/ruddyp/sleepie-frontend/blob/main/modules/checkInput.js"
    click Filter "https://github.com/ruddyp/sleepie-frontend/blob/main/modules/filter.js"
    click Const "https://github.com/ruddyp/sleepie-frontend/blob/main/modules/constant.js"
    click Utils "https://github.com/ruddyp/sleepie-frontend/blob/main/modules/utils.js"
    click SleepTimer "https://github.com/ruddyp/sleepie-frontend/blob/main/sleepTimerStore.js"
    click Service "https://github.com/ruddyp/sleepie-frontend/blob/main/service.js"
    click Assets "https://github.com/ruddyp/sleepie-frontend/tree/main/assets"
    click AppConfig "https://github.com/ruddyp/sleepie-frontend/blob/main/app.json"
    click Package "https://github.com/ruddyp/sleepie-frontend/blob/main/package.json"

    %% Styles
    classDef ui fill:#bbefff,stroke:#333,stroke-width:1px
    classDef state fill:#bfffbf,stroke:#333,stroke-width:1px
    classDef data fill:#ffd59e,stroke:#333,stroke-width:1px
    classDef config fill:#e2e2e2,stroke:#333,stroke-width:1px
```
