# minori-ty/expo-schedule architecture

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

- Interactive diagram: https://gitdiagram.com/minori-ty/expo-schedule
- Repository: https://github.com/minori-ty/expo-schedule

## Overview

##### Project Type and Purpose
- This is a full-stack mobile application built with Expo (React Native) using file-based routing (app/ directory).
- It fetches anime and calendar data via API wrappers (api/), persists data locally in SQLite (db/, drizzle.config.ts), and supports background sync tasks (backgroundTasks/).

##### File Structure
- app/ – all screens and layout components (file-based routes).
- api/ – wrappers around external anime & calendar REST endpoints.
- components/ – reusable UI controls and Lottie animations.
- db/ + drizzle/ – local SQLite database schema, migrations, ORM config.
- backgroundTasks/ – tasks that run off-thread for periodic sync.
- hooks/, utils/, enums/, constants/, styles/ – support layers.
- configuration files: babel.config.js, tsconfig.json, tailwind.config.js, eas.json, etc.

##### README
- Confirms Expo project, instructions to run/dev.

##### Main Components & Their Relationships
a. Mobile Client (Expo App)
- Screens (app/…) and Navigation (Expo Router)
- UI Component Library (components/, styles/, assets/)
- Hooks & State Layer (React Query via utils/react-query, hooks/)
b. Network Layer
- api/ modules call external anime/calendar services over HTTPS
c. Local Persistence
- SQLite via Drizzle ORM (db/, drizzle/*)
d. Background Sync
- backgroundTasks/ runs periodic jobs to refresh data from external API and store in DB
e. Permissions & Native APIs
- permissions/ for runtime permissions
- utils/file.android.ts, nativewind-env.d.ts, metro.config.js for native config

##### Architectural Patterns & Design Principles
- Layered architecture:
- Presentation (screens & components) → Data Fetch (React Query hooks) → Data Source (Network or Local DB)
- Separation of concerns: file-based routing isolates screen logic, components folder for pure UI, api/ for network, db/ for storage.
- Use of background tasks isolates periodic sync from UI thread.
- Declarative styling via Tailwind CSS (tailwind.config.js, nativewind).
- Typed safety: TypeScript across the stack, enums/, types/.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        subgraph "Routes & Screens" 
            direction TB
            Layout_app["_layout.tsx"]:::frontend
            Layout_tabs["(tabs)/_layout.tsx"]:::frontend
            Tab_Home["(tabs)/index.tsx"]:::frontend
            Tab_MyAnime["(tabs)/myAnime.tsx"]:::frontend
            Tab_Settings["(tabs)/settings.tsx"]:::frontend
            Add_Anime["addAnime/index.tsx"]:::frontend
            Anime_Detail["animeDetail/[id].tsx"]:::frontend
            Edit_Anime["editAnime/[id].tsx"]:::frontend
            Search_Screen["search/index.tsx"]:::frontend
        end
        subgraph "Reusable Components"
            direction TB
            BaseForm["BaseForm.tsx"]:::frontend
            Checkbox["Checkbox.tsx"]:::frontend
            Datepicker["Datepicker.tsx"]:::frontend
            HapticTab["HapticTab.tsx"]:::frontend
            Modal["Modal.tsx"]:::frontend
            PageHeader["PageHeader.tsx"]:::frontend
            RadioGroup["RadioGroup.tsx"]:::frontend
            LottieEmpty["Empty.tsx"]:::frontend
            LottieError["Error.tsx"]:::frontend
            LottieLoading["Loading.tsx"]:::frontend
            Icon["Icon.tsx"]:::frontend
            IconSymbol["IconSymbol.tsx"]:::frontend
            TabBarBackground["TabBarBackground.tsx"]:::frontend
        end
    end

    %% State & Data-Fetching Layer
    subgraph "State & Data-Fetching" 
        direction TB
        ReactQuery["react-query.ts"]:::data
        AppStateHook["useAppStateRefresh.ts"]:::data
    end

    %% API Services
    subgraph "API Services" 
        direction TB
        API_Index["index.ts"]:::external
        API_Anime["anime.ts"]:::external
        API_Calendar["calendar.ts"]:::external
    end

    %% Local Database
    subgraph "Local Database" 
        direction TB
        DB_Schema["schema.ts"]:::storage
        DB_Index["index.ts"]:::storage
        DrizzleConfig["drizzle.config.ts"]:::storage
        MigrationSQL["0000_eager_sue_storm.sql"]:::storage
        MigrationsJS["migrations.js"]:::storage
        MigrationsMeta["meta/"]:::storage
    end

    %% Background Tasks
    subgraph "Background Tasks" 
        direction TB
        SyncWorker["index.ts"]:::worker
    end

    %% Assets & Configuration
    subgraph "Assets & Config"
        direction TB
        Assets["assets/"]:::config
        AppConfig["app.config.js"]:::config
        EAS["eas.json"]:::config
        Metro["metro.config.js"]:::config
        Babel["babel.config.js"]:::config
        Tailwind["tailwind.config.js"]:::config
        GlobalCSS["global.css"]:::config
        StylesIndex["styles/index.ts"]:::config
    end

    %% Native Modules & Permissions
    subgraph "Native & Permissions"
        direction TB
        Permissions["permissions/index.ts"]:::native
        FileUtil["file.android.ts"]:::native
        Nativewind["nativewind-env.d.ts"]:::native
    end

    %% Support Layers
    subgraph "Support Layers"
        direction TB
        ColorsConst["Colors.ts"]:::support
        Enums["index.ts"]:::support
        UtilsCalendar["calendar.ts"]:::support
        UtilsCN["cn.ts"]:::support
        UtilsTime["time.ts"]:::support
        Types["index.d.ts"]:::support
    end

    %% Connections
    Layout_app -->|uses| ReactQuery
    BaseForm -->|uses| ReactQuery
    ReactQuery -->|fetches| API_Anime
    ReactQuery -->|fetches| API_Calendar
    ReactQuery -->|caches| DB_Schema
    Layout_app -->|reads cached| DB_Schema
    SyncWorker -.->|schedules| API_Anime
    SyncWorker -.->|schedules| API_Calendar
    SyncWorker -->|writes| DB_Schema
    Permissions -.->|grants| Layout_app
    Permissions -.->|grants| SyncWorker

    %% Click Events
    click Layout_app "https://github.com/minori-ty/expo-schedule/blob/master/app/_layout.tsx"
    click Layout_tabs "https://github.com/minori-ty/expo-schedule/blob/master/app/(tabs)/_layout.tsx"
    click Tab_Home "https://github.com/minori-ty/expo-schedule/blob/master/app/(tabs)/index.tsx"
    click Tab_MyAnime "https://github.com/minori-ty/expo-schedule/blob/master/app/(tabs)/myAnime.tsx"
    click Tab_Settings "https://github.com/minori-ty/expo-schedule/blob/master/app/(tabs)/settings.tsx"
    click Add_Anime "https://github.com/minori-ty/expo-schedule/blob/master/app/addAnime/index.tsx"
    click Anime_Detail "https://github.com/minori-ty/expo-schedule/blob/master/app/animeDetail/[id].tsx"
    click Edit_Anime "https://github.com/minori-ty/expo-schedule/blob/master/app/editAnime/[id].tsx"
    click Search_Screen "https://github.com/minori-ty/expo-schedule/blob/master/app/search/index.tsx"
    click BaseForm "https://github.com/minori-ty/expo-schedule/blob/master/components/BaseForm.tsx"
    click Checkbox "https://github.com/minori-ty/expo-schedule/blob/master/components/Checkbox.tsx"
    click Datepicker "https://github.com/minori-ty/expo-schedule/blob/master/components/Datepicker.tsx"
    click HapticTab "https://github.com/minori-ty/expo-schedule/blob/master/components/HapticTab.tsx"
    click Modal "https://github.com/minori-ty/expo-schedule/blob/master/components/Modal/Modal.tsx"
    click PageHeader "https://github.com/minori-ty/expo-schedule/blob/master/components/PageHeader.tsx"
    click RadioGroup "https://github.com/minori-ty/expo-schedule/blob/master/components/RadioGroup.tsx"
    click LottieEmpty "https://github.com/minori-ty/expo-schedule/blob/master/components/lottie/Empty.tsx"
    click LottieError "https://github.com/minori-ty/expo-schedule/blob/master/components/lottie/Error.tsx"
    click LottieLoading "https://github.com/minori-ty/expo-schedule/blob/master/components/lottie/Loading.tsx"
    click Icon "https://github.com/minori-ty/expo-schedule/blob/master/components/ui/Icon.tsx"
    click IconSymbol "https://github.com/minori-ty/expo-schedule/blob/master/components/ui/IconSymbol.tsx"
    click TabBarBackground "https://github.com/minori-ty/expo-schedule/blob/master/components/ui/TabBarBackground.tsx"
    click ReactQuery "https://github.com/minori-ty/expo-schedule/blob/master/utils/react-query.ts"
    click AppStateHook "https://github.com/minori-ty/expo-schedule/blob/master/hooks/useAppStateRefresh.ts"
    click API_Index "https://github.com/minori-ty/expo-schedule/blob/master/api/index.ts"
    click API_Anime "https://github.com/minori-ty/expo-schedule/blob/master/api/anime.ts"
    click API_Calendar "https://github.com/minori-ty/expo-schedule/blob/master/api/calendar.ts"
    click DB_Schema "https://github.com/minori-ty/expo-schedule/blob/master/db/schema.ts"
    click DB_Index "https://github.com/minori-ty/expo-schedule/blob/master/db/index.ts"
    click DrizzleConfig "https://github.com/minori-ty/expo-schedule/blob/master/drizzle.config.ts"
    click MigrationSQL "https://github.com/minori-ty/expo-schedule/blob/master/drizzle/0000_eager_sue_storm.sql"
    click MigrationsJS "https://github.com/minori-ty/expo-schedule/blob/master/drizzle/migrations.js"
    click MigrationsMeta "https://github.com/minori-ty/expo-schedule/tree/master/drizzle/meta/"
    click SyncWorker "https://github.com/minori-ty/expo-schedule/blob/master/backgroundTasks/index.ts"
    click Assets "https://github.com/minori-ty/expo-schedule/tree/master/assets/"
    click AppConfig "https://github.com/minori-ty/expo-schedule/blob/master/app.config.js"
    click EAS "https://github.com/minori-ty/expo-schedule/blob/master/eas.json"
    click Metro "https://github.com/minori-ty/expo-schedule/blob/master/metro.config.js"
    click Babel "https://github.com/minori-ty/expo-schedule/blob/master/babel.config.js"
    click Tailwind "https://github.com/minori-ty/expo-schedule/blob/master/tailwind.config.js"
    click GlobalCSS "https://github.com/minori-ty/expo-schedule/blob/master/styles/global.css"
    click StylesIndex "https://github.com/minori-ty/expo-schedule/blob/master/styles/index.ts"
    click Permissions "https://github.com/minori-ty/expo-schedule/blob/master/permissions/index.ts"
    click FileUtil "https://github.com/minori-ty/expo-schedule/blob/master/utils/file.android.ts"
    click Nativewind "https://github.com/minori-ty/expo-schedule/blob/master/nativewind-env.d.ts"
    click ColorsConst "https://github.com/minori-ty/expo-schedule/blob/master/constants/Colors.ts"
    click Enums "https://github.com/minori-ty/expo-schedule/blob/master/enums/index.ts"
    click UtilsCalendar "https://github.com/minori-ty/expo-schedule/blob/master/utils/calendar.ts"
    click UtilsCN "https://github.com/minori-ty/expo-schedule/blob/master/utils/cn.ts"
    click UtilsTime "https://github.com/minori-ty/expo-schedule/blob/master/utils/time.ts"
    click Types "https://github.com/minori-ty/expo-schedule/blob/master/types/index.d.ts"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef data fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef external fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00
    classDef storage fill:#EFEBE9,stroke:#5D4037,color:#5D4037
    classDef worker fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A
    classDef config fill:#ECEFF1,stroke:#455A64,color:#455A64
    classDef native fill:#FCE4EC,stroke:#AD1457,color:#AD1457
    classDef support fill:#E1F5FE,stroke:#0277BD,color:#0277BD
```
