# edwinrajesh/selene architecture

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

- Interactive diagram: https://gitdiagram.com/edwinrajesh/selene
- Repository: https://github.com/edwinrajesh/selene

## Overview

##### Project Type and Purpose
- This is a mobile client app built on Expo + React Native + TypeScript.
- It offers journaling, task management, media browsing, chat/AI-powered transcription, and user profiles.
- It uses file-based routing under the `app/` directory and integrates with Firebase (via `FirebaseConfig.ts`) and an external AI API (via `app/chat/grokapi.ts`).

##### File Structure
- Top-level “app/” folder: file-based screens and layouts
- `(tabs)/…`: tab-based navigation pages (Home, Journal, Media, Task)
- `chat/…`: AIJournalScreen, Transcription, and API wrapper
- `journals/…`: CRUD pages for journal entries, tags, search
- `tasks/…`: task pages
- global layouts: `_layout.tsx`, `Login.tsx`, `Profile.tsx`
- `src/components/`: reusable UI components (buttons, lists, calendars, search bars)
- `src/providers/`: React Context providers for user data and date state
- `FirebaseConfig.ts`: initialization of Firebase services
- `babel.config.js`, `tsconfig.json`: build and type configuration
- `assets/`: fonts/images

##### README
- Confirms Expo/React Native, file-based routing, start commands.
- No backend server code here—backend responsibilities are fully offloaded to Firebase and external AI.

##### Main Components
a. Mobile Client Layer (Expo app)
- Entrypoint: `app/index.tsx` → Root layout `_layout.tsx`
- Navigation: file-based router → Tab navigator under `app/(tabs)`
- Screens: Home, Journal, Media, Task, Login, Profile, Chat module, Journals module, Tasks module
- UI Components: those under `src/components/`
b. State Management Layer
- `UserDataProvider`
- `dateProvider`
c. Service Layer
- Firebase services: Auth, Firestore (user profiles, journal entries, tasks), Storage (media)
- External AI API: grokapi wrapper calling OpenAI or similar
d. Static Assets
e. Build & Config
- Babel, TypeScript, package.json

##### Relationships and Data Flows
- UI Screens ↔ Providers (React Context)
- Providers ↔ Firebase SDK (reads/writes user data, journals, tasks, media URLs)
- Chat screens → grokapi.ts → External AI API → chat/transcriptions
- Assets → loaded by components at runtime
- Navigation flows: top-level layout → tab navigator → nested screens

##### Architectural Patterns & Design Principles
- File-based routing for navigation (Expo Router)
- Component-based UI layer
- Context API for global state (user, date)
- Service layer abstraction (FirebaseConfig, grokapi)
- Separation of concerns: UI, state, services, assets

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entrypoint and Root Layout
    Index["app/index.tsx"]:::ui
    RootLayout["app/_layout.tsx"]:::ui
    Index -->|"renders"| RootLayout
    click Index "https://github.com/edwinrajesh/selene/blob/main/app/index.tsx"
    click RootLayout "https://github.com/edwinrajesh/selene/blob/main/app/_layout.tsx"

    %% Providers Layer
    subgraph "State Management Layer"
        direction TB
        UserData["UserDataProvider"]:::state
        DateProvider["dateProvider"]:::state
    end
    click UserData "https://github.com/edwinrajesh/selene/blob/main/app/providers/UserDataProvider.tsx"
    click DateProvider "https://github.com/edwinrajesh/selene/blob/main/src/providers/dateProvider.tsx"

    RootLayout -->|"wraps UI with"| UserData
    RootLayout -->|"wraps UI with"| DateProvider

    %% Mobile Client Layer - Navigation & Screens
    subgraph "Mobile Client Layer (Expo App)" 
        direction TB
        subgraph "File-based Routing"
            direction TB
            TabLayout["app/(tabs)/_layout.tsx"]:::ui
            HomeScreen["app/(tabs)/homeScreen.tsx"]:::ui
            JournalScreen["app/(tabs)/journalScreen.tsx"]:::ui
            MediaScreen["app/(tabs)/mediaScreen.tsx"]:::ui
            TaskScreen["app/(tabs)/taskScreen.tsx"]:::ui
            Login["app/Login.tsx"]:::ui
            Profile["app/Profile.tsx"]:::ui
        end
    end
    click TabLayout "https://github.com/edwinrajesh/selene/blob/main/app/(tabs)/_layout.tsx"
    click HomeScreen "https://github.com/edwinrajesh/selene/blob/main/app/(tabs)/homeScreen.tsx"
    click JournalScreen "https://github.com/edwinrajesh/selene/blob/main/app/(tabs)/journalScreen.tsx"
    click MediaScreen "https://github.com/edwinrajesh/selene/blob/main/app/(tabs)/mediaScreen.tsx"
    click TaskScreen "https://github.com/edwinrajesh/selene/blob/main/app/(tabs)/taskScreen.tsx"
    click Login "https://github.com/edwinrajesh/selene/blob/main/app/Login.tsx"
    click Profile "https://github.com/edwinrajesh/selene/blob/main/app/Profile.tsx"

    UserData -->|"provides user state"| TabLayout
    DateProvider -->|"provides date state"| TabLayout

    TabLayout --> HomeScreen
    TabLayout --> JournalScreen
    TabLayout --> MediaScreen
    TabLayout --> TaskScreen
    RootLayout --> Login
    RootLayout --> Profile

    %% Chat Module
    subgraph "Chat Module" 
        direction TB
        AIJournal["app/chat/AIJournalScreen.tsx"]:::ui
        Transcription["app/chat/Transcription.tsx"]:::ui
        GrokApi["app/chat/grokapi.ts"]:::service
    end
    click AIJournal "https://github.com/edwinrajesh/selene/blob/main/app/chat/AIJournalScreen.tsx"
    click Transcription "https://github.com/edwinrajesh/selene/blob/main/app/chat/Transcription.tsx"
    click GrokApi "https://github.com/edwinrajesh/selene/blob/main/app/chat/grokapi.ts"

    TaskScreen --> AIJournal
    AIJournal --> Transcription
    Transcription --> GrokApi
    GrokApi --->|"REST/HTTP call"| ExternalAI[External AI API]:::external

    %% Journals Module
    subgraph "Journals Module"
        direction TB
        JournalsLayout["app/journals/_layout.tsx"]:::ui
        AllEntries["app/journals/AllEntries.tsx"]:::ui
        EditJournal["app/journals/EditJournal.tsx"]:::ui
        JournalEntry["app/journals/JournalEntry.tsx"]:::ui
        SearchJournal["app/journals/SearchJournal.tsx"]:::ui
        JournalById["app/journals/[id].tsx"]:::ui
        TagsLayout["app/journals/tags/_layout.tsx"]:::ui
        TagView["app/journals/tags/[tag].tsx"]:::ui
    end
    click JournalsLayout "https://github.com/edwinrajesh/selene/blob/main/app/journals/_layout.tsx"
    click AllEntries "https://github.com/edwinrajesh/selene/blob/main/app/journals/AllEntries.tsx"
    click EditJournal "https://github.com/edwinrajesh/selene/blob/main/app/journals/EditJournal.tsx"
    click JournalEntry "https://github.com/edwinrajesh/selene/blob/main/app/journals/JournalEntry.tsx"
    click SearchJournal "https://github.com/edwinrajesh/selene/blob/main/app/journals/SearchJournal.tsx"
    click JournalById "https://github.com/edwinrajesh/selene/blob/main/app/journals/[id].tsx"
    click TagsLayout "https://github.com/edwinrajesh/selene/blob/main/app/journals/tags/_layout.tsx"
    click TagView "https://github.com/edwinrajesh/selene/blob/main/app/journals/tags/[tag].tsx"

    JournalScreen --> JournalsLayout
    JournalsLayout --> AllEntries
    JournalsLayout --> EditJournal
    JournalsLayout --> JournalEntry
    JournalsLayout --> SearchJournal
    JournalsLayout --> TagsLayout
    TagsLayout --> TagView
    AllEntries -->|"read/write Firestore"| Firestore[Firestore]:::service
    EditJournal -->|"read/write Firestore"| Firestore
    JournalEntry -->|"read/write Firestore"| Firestore
    SearchJournal -->|"query Firestore"| Firestore
    TagView -->|"query Firestore"| Firestore

    %% Tasks Module
    subgraph "Tasks Module"
        direction TB
        TasksLayout["app/tasks/_layout.tsx"]:::ui
        SetTasks["app/tasks/SetTasks.tsx"]:::ui
        EditTask["app/tasks/editTask.tsx"]:::ui
    end
    click TasksLayout "https://github.com/edwinrajesh/selene/blob/main/app/tasks/_layout.tsx"
    click SetTasks "https://github.com/edwinrajesh/selene/blob/main/app/tasks/SetTasks.tsx"
    click EditTask "https://github.com/edwinrajesh/selene/blob/main/app/tasks/editTask.tsx"

    TaskScreen --> TasksLayout
    TasksLayout --> SetTasks
    TasksLayout --> EditTask
    SetTasks -->|"read/write Firestore"| Firestore
    EditTask -->|"read/write Firestore"| Firestore

    %% Reusable UI Components
    subgraph "UI Components" 
        direction TB
        Calendar["src/components/Calender.tsx"]:::ui
        ChatBotBtn["src/components/ChatBotButton.tsx"]:::ui
        DailyQuote["src/components/DailyQoute.tsx"]:::ui
        DateComp["src/components/Date.tsx"]:::ui
        JournalBtn["src/components/JournalButton.tsx"]:::ui
        JournalList["src/components/JournalEntriesList.tsx"]:::ui
        JournalFlat["src/components/JournalFlatlistComponent.tsx"]:::ui
        MonthComp["src/components/Month.tsx"]:::ui
        RealSearch["src/components/RealSearchBar.tsx"]:::ui
        SearchBar["src/components/SearchBar.tsx"]:::ui
        SecButton["src/components/SecondaryButton.tsx"]:::ui
        TabBar["src/components/TabBar.tsx"]:::ui
        TabBarBtn["src/components/TabBarButton.tsx"]:::ui
        TagCards["src/components/TagCards.tsx"]:::ui
        TaskComp["src/components/TaskComponent.tsx"]:::ui
    end
    click Calendar "https://github.com/edwinrajesh/selene/blob/main/src/components/Calender.tsx"
    click ChatBotBtn "https://github.com/edwinrajesh/selene/blob/main/src/components/ChatBotButton.tsx"
    click DailyQuote "https://github.com/edwinrajesh/selene/blob/main/src/components/DailyQoute.tsx"
    click DateComp "https://github.com/edwinrajesh/selene/blob/main/src/components/Date.tsx"
    click JournalBtn "https://github.com/edwinrajesh/selene/blob/main/src/components/JournalButton.tsx"
    click JournalList "https://github.com/edwinrajesh/selene/blob/main/src/components/JournalEntriesList.tsx"
    click JournalFlat "https://github.com/edwinrajesh/selene/blob/main/src/components/JournalFlatlistComponent.tsx"
    click MonthComp "https://github.com/edwinrajesh/selene/blob/main/src/components/Month.tsx"
    click RealSearch "https://github.com/edwinrajesh/selene/blob/main/src/components/RealSearchBar.tsx"
    click SearchBar "https://github.com/edwinrajesh/selene/blob/main/src/components/SearchBar.tsx"
    click SecButton "https://github.com/edwinrajesh/selene/blob/main/src/components/SecondaryButton.tsx"
    click TabBar "https://github.com/edwinrajesh/selene/blob/main/src/components/TabBar.tsx"
    click TabBarBtn "https://github.com/edwinrajesh/selene/blob/main/src/components/TabBarButton.tsx"
    click TagCards "https://github.com/edwinrajesh/selene/blob/main/src/components/TagCards.tsx"
    click TaskComp "https://github.com/edwinrajesh/selene/blob/main/src/components/TaskComponent.tsx"

    %% Services Layer
    subgraph "Service Layer" 
        direction TB
        FirebaseCfg["FirebaseConfig.ts"]:::service
        Firestore
        AuthService["Auth"]:::service
        StorageService["Storage"]:::service
    end
    click FirebaseCfg "https://github.com/edwinrajesh/selene/blob/main/FirebaseConfig.ts"

    UserData -->|"auth state"| AuthService
    Profile -->|"login/logout"| AuthService
    AuthService -->|"token exchange"| FirebaseCfg
    Firestore -->|"initialized by"| FirebaseCfg
    StorageService -->|"initialized by"| FirebaseCfg
    MediaScreen -->|"fetch/upload media"| StorageService

    %% External Systems
    ExternalAI

    %% Assets
    subgraph "Static Assets"
        Fonts["assets/fonts/"]:::assets
        Images["assets/images/"]:::assets
    end

    Calendar -->|"loads fonts/images"| Fonts
    Calendar -->|"loads fonts/images"| Images

    %% Build & Configuration
    subgraph "Build & Config"
        Babel["babel.config.js"]:::config
        TsConfig["tsconfig.json"]:::config
        PackageJSON["package.json"]:::config
        AppJSON["app.json"]:::config
        Env[".env"]:::config
        GitIgnore[".gitignore"]:::config
    end

    %% Styles
    classDef ui fill:#e0f7fa,stroke:#0277bd,color:#000
    classDef state fill:#e8f5e9,stroke:#2e7d32,color:#000
    classDef service fill:#fff3e0,stroke:#f57c00,color:#000
    classDef external fill:#f3e5f5,stroke:#6a1b9a,color:#000
    classDef assets fill:#eceff1,stroke:#90a4ae,color:#000
    classDef config fill:#fbe9e7,stroke:#bf360c,color:#000
```
