# odtboun/simple-flashcard-app architecture

> Architecture diagram of the GitHub repository odtboun/simple-flashcard-app, 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/odtboun/simple-flashcard-app
- Repository: https://github.com/odtboun/simple-flashcard-app

## Overview

##### Project Type & Purpose
- This is a mobile flashcard app built with React Native and Expo that leverages a custom spaced repetition algorithm to aid learning.
- It employs React Navigation for screen management and AsyncStorage for local persistence, while also integrating with a backend using Supabase (with migration scripts provided in the “supabase” directory).

##### Main Components
a. User Interface (UI):
- Mobile Screens: Represent the various screens found in “src/screens” (e.g., HomeScreen, AuthScreen, DeckListScreen, ReviewSessionScreen).
- UI Components: Include reusable components from “src/components” like Flashcard.js.
- Navigation: Mark the integration of React Navigation to move among screens.

b. State and Context Management:

c. Business Logic & Services:
- Services: Separate components such as “cardService.js”, “deckService.js”, “fsrsService.js”, and “userService.js” that encapsulate business logic and API interactions.
- Custom Utilities: Highlight the “spacedRepetition.js” in “src/utils” responsible for implementing the spaced repetition algorithm, and “theme.js” for UI theming.

d. Data Layer / Backend Integration:
- Supabase Integration: Indicate the connection via “src/lib/supabase.js”—this module likely handles API calls to the Supabase backend.
- Database: Outline the Supabase database with migration files (in the “supabase/migrations” directory) that set up tables like decks, cards, profiles, etc.

e. Configuration & Deployment:
- Project configuration files (babel.config.js, app.json, tsconfig.json) can be noted as supporting files for app setup.
- The “index.js” and “App.js” files act as bootstrap entry points linking all components.

##### Relationship and Interactions
- Connections from the screens to the service layer. The service layer, in turn, communicates with:
◦ Local persistence (AsyncStorage) for caching or offline support.
◦ The Supabase backend via “src/lib/supabase.js” for remote data operations.

##### Architectural Patterns & Design Principles
- That the app follows a separation of concerns: UI presentation (screens/components), business logic (services and utilities), and state management (contexts).
- Mention the use of hooks and custom logic for spaced repetition as a key feature.
- Optionally, note that the project embraces a modular design, where each domain (authentication, flashcards, reviews) is encapsulated in its own module.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        direction TB
        HS["HomeScreen"]:::ui
        AS["AuthScreen"]:::ui
        DS["DeckListScreen"]:::ui
        RS["ReviewSessionScreen"]:::ui
        FC["Flashcard"]:::ui
        AJS["App.js"]:::ui
        IDX["index.js"]:::ui
    end

    subgraph "State & Context"
        direction TB
        AC["AuthContext"]:::context
        UC["UserContext"]:::context
    end

    subgraph "Business Logic & Services"
        direction TB
        CS["cardService"]:::service
        DSrv["deckService"]:::service
        FS["fsrsService"]:::service
        US["userService"]:::service
        SR["spacedRepetition"]:::service
        TH["theme"]:::service
    end

    subgraph "Data Integration"
        direction TB
        SA["Supabase Integration"]:::data
        SD["Supabase Database"]:::data
        ASyn["AsyncStorage"]:::data
    end

    subgraph "Configuration"
        direction TB
        BC["babel.config.js"]:::config
        ACfg["app.json"]:::config
        TC["tsconfig.json"]:::config
    end

    %% UI Layer to State & Context
    HS -->|"triggers"| AC
    AS -->|"triggers"| AC
    DS -->|"updates"| UC
    RS -->|"updates"| UC

    %% UI Layer to Business Logic & Services
    HS -->|"calls"| CS
    AS -->|"calls"| US
    DS -->|"calls"| DSrv
    RS -->|"calls"| FS
    FC -->|"displays"| CS

    %% Navigation Integration within UI
    AJS -->|"navigates to"| HS
    IDX -->|"boots"| AJS

    %% State & Context interaction with Business Logic
    AC -->|"providesAuth"| CS
    UC -->|"providesUser"| US

    %% Business Logic interactions
    CS -->|"caches"| ASyn
    DSrv -->|"persists"| ASyn
    US -->|"fetches/upd"| SA
    FS -->|"processes"| SA
    SR -->|"calculates"| FS
    TH -.->|"applies"| FC

    %% Data Integration flows
    SA -->|"queries"| SD
    SD -->|"updates"| SA
    SA -->|"returns"| CS
    ASyn -->|"reads"| DSrv

    %% Bootstrap and Configuration connections
    AJS -->|"uses"| BC
    AJS -->|"uses"| ACfg
    IDX -->|"uses"| TC

    %% Click Events
    click HS "https://github.com/odtboun/simple-flashcard-app/blob/main/src/screens/HomeScreen.js"
    click AS "https://github.com/odtboun/simple-flashcard-app/blob/main/src/screens/AuthScreen.js"
    click DS "https://github.com/odtboun/simple-flashcard-app/blob/main/src/screens/DeckListScreen.js"
    click RS "https://github.com/odtboun/simple-flashcard-app/blob/main/src/screens/ReviewSessionScreen.js"
    click FC "https://github.com/odtboun/simple-flashcard-app/blob/main/src/components/Flashcard.js"
    click AJS "https://github.com/odtboun/simple-flashcard-app/blob/main/App.js"
    click IDX "https://github.com/odtboun/simple-flashcard-app/blob/main/index.js"
    click AC "https://github.com/odtboun/simple-flashcard-app/blob/main/src/contexts/AuthContext.js"
    click UC "https://github.com/odtboun/simple-flashcard-app/blob/main/src/contexts/UserContext.js"
    click CS "https://github.com/odtboun/simple-flashcard-app/blob/main/src/services/cardService.js"
    click DSrv "https://github.com/odtboun/simple-flashcard-app/blob/main/src/services/deckService.js"
    click FS "https://github.com/odtboun/simple-flashcard-app/blob/main/src/services/fsrsService.js"
    click US "https://github.com/odtboun/simple-flashcard-app/blob/main/src/services/userService.js"
    click SR "https://github.com/odtboun/simple-flashcard-app/blob/main/src/utils/spacedRepetition.js"
    click TH "https://github.com/odtboun/simple-flashcard-app/blob/main/src/utils/theme.js"
    click SA "https://github.com/odtboun/simple-flashcard-app/blob/main/src/lib/supabase.js"
    click SD "https://github.com/odtboun/simple-flashcard-app/tree/main/supabase/migrations"
    click BC "https://github.com/odtboun/simple-flashcard-app/blob/main/babel.config.js"
    click ACfg "https://github.com/odtboun/simple-flashcard-app/blob/main/app.json"
    click TC "https://github.com/odtboun/simple-flashcard-app/blob/main/tsconfig.json"

    %% Styles
    classDef ui fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef context fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px;
    classDef service fill:#dcedc8,stroke:#558b2f,stroke-width:2px;
    classDef data fill:#ffccbc,stroke:#d84315,stroke-width:2px;
    classDef config fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px;
```
