# metin-aksu/kelimatik architecture

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

- Interactive diagram: https://gitdiagram.com/metin-aksu/kelimatik
- Repository: https://github.com/metin-aksu/kelimatik

## Overview

##### Project type and purpose
- This is a cross-platform mobile application built with React Native (TypeScript), named “Kelimatik.”
- It embeds a pre-populated SQLite database (`Kelimeler.db`) in the native assets and exposes it to the JavaScript layer via a native bridge or community SQLite module.
- No remote backend is present; all data lives locally.

##### File structure
- Top-level app code:
- App.tsx, index.js — entry points for the JS bundle.
- Native containers:
- android/ — Gradle build, MainActivity.kt, MainApplication.kt, assets/www/Kelimeler.db.
- ios/ — Xcode project, AppDelegate, Info.plist, embedded DB under src/db too (for possible code-side copy).
- Tooling & config:
- metro.config.js, babel.config.js — bundler configuration.
- jest.config.js and __tests__ — unit testing setup.
- package.json, Gemfile — npm/Yarn and Ruby (cocoa pods) dependencies.

##### README for additional insights
- Confirms use of Metro Bundler for JS, running on Android Emulator or iOS Simulator.
- No mention of remote APIs—app runs entirely locally.

##### Main components
a. Developer environment
- Code editor/IDE
- CLI tools (npm/Yarn, Metro)
- Android Studio / Xcode
b. Bundler & build
- Metro Bundler → produces a single JavaScript bundle
- Platform-specific build systems (Gradle for Android, CocoaPods + Xcode for iOS)
c. Runtime stack on device/emulator
- JavaScriptCore (iOS) or Hermes/V8 (Android)
- Native modules (Activity/AppDelegate, UI Manager)
d. Application code
- UI layer: React components in src/screens/
- Business logic & state: React Context or hooks in App.tsx & database.ts
- Data layer: SQLite DB exposed through a native SQLite plugin
e. Database
- Pre-populated Kelimeler.db packaged into native assets
- File copied on first launch to device storage; accessed via native module
f. Testing
- Jest runs unit tests against JS components and database wrappers

##### Relationships and interactions
- Developer writes TS/JS → Metro bundles → bundle loaded into JS engine at runtime.
- JS UI components call into native modules via the React Native bridge to open/read the SQLite DB.
- Native code (Android Activity or iOS AppDelegate) bootstraps the JS runtime and registers database modules.
- User gestures on the UI → event handlers in JS → queries against SQLite → results rendered back into the UI.

##### Architectural patterns & design principles
- Component-based UI: screens and subcomponents under src/screens/.
- Layered separation: Presentation (React components), Business Logic (TypeScript services/hooks), Data Access (database.ts + native SQLite).
- Single-page application model within a native container.

##### Relevant technologies & frameworks
- React Native (JS + bridge to native)
- TypeScript
- Metro Bundler
- SQLite (via community/native plugin)
- Gradle (Android), CocoaPods + Xcode (iOS)
- Jest (testing)

##### Detail without overcomplicating
- Major components, even if simple (e.g., list the .db file as its own component).
- Both build-time relationships (CLI → bundler → build system) and run-time interactions (JS ↔ native, JS → DB).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Developer Workstation"
        direction TB
        IDE["Code Editor / IDE"]:::tooling
        CLI["CLI Tools\n(npm/Yarn, Metro CLI)"]:::tooling
        Studio["Android Studio / Xcode"]:::tooling
    end

    subgraph "Build & Bundling"
        direction TB
        Metro["Metro Bundler"]:::tooling
        Babel["Babel Config"]:::tooling
        Gradle["Gradle Build\n(Android)"]:::tooling
        CocoaPods["CocoaPods + Xcode\n(iOS)"]:::tooling
    end

    subgraph "Device / Emulator Runtime"
        direction TB
        Bundle["JS Bundle"]:::jsLayer
        JSEngine["JS Engine\n(Hermes/V8 or JSC)"]:::jsLayer
        Bridge["React Native Bridge"]:::nativeLayer
        subgraph "Native Modules"
            direction TB
            Activity["MainActivity / AppDelegate"]:::nativeLayer
            UIManager["UI Manager"]:::nativeLayer
            SQLitePlugin["SQLite Plugin"]:::nativeLayer
        end
    end

    subgraph "Database"
        direction TB
        DBFile["Kelimeler.db"]:::db
        DBWrapper["database.ts"]:::jsLayer
    end

    subgraph "Testing"
        direction TB
        Jest["Jest Test Runner"]:::test
        TestFiles["__tests__/App.test.tsx"]:::test
    end

    subgraph "Dependencies"
        direction TB
        PackageJSON["package.json"]:::tooling
        Lock["package-lock.json / Gemfile.lock"]:::tooling
        Gemfile["Gemfile"]:::tooling
    end

    IDE --> CLI
    CLI --> Metro
    CLI --> Babel
    CLI --> Gradle
    CLI --> CocoaPods
    Metro --> Bundle
    Babel --> Bundle
    Gradle --> Bundle
    CocoaPods --> Bundle

    Bundle --> JSEngine
    JSEngine <-->|"bidirectional bridge"| Bridge
    Bridge --> Activity
    Bridge --> UIManager
    Bridge --> SQLitePlugin

    SQLitePlugin -->|reads/writes| DBFile
    DBWrapper -->|JS access| SQLitePlugin
    JSEngine -->|imports| DBWrapper

    JSEngine -->|renders UI| UIManager

    IDE -->|runs tests| Jest
    Jest --> TestFiles

    CLI --> PackageJSON
    CLI --> Lock
    CLI --> Gemfile

    classDef jsLayer fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef nativeLayer fill:#E6FFEA,stroke:#28A745,color:#28A745
    classDef tooling fill:#F0F0F0,stroke:#666666,color:#333333
    classDef db fill:#FFF4E5,stroke:#FF8C00,color:#FF8C00
    classDef test fill:#F5E6FF,stroke:#6F42C1,color:#6F42C1

    %% Click Events
    click App["App.tsx"] "App.tsx"
    click Index["index.js"] "index.js"
    click Metro "https://github.com/metin-aksu/kelimatik/blob/main/metro.config.js"
    click Babel "https://github.com/metin-aksu/kelimatik/blob/main/babel.config.js"
    click MainActivity "https://github.com/metin-aksu/kelimatik/blob/main/android/app/src/main/java/com/kelimatik/MainActivity.kt"
    click MainApplication "https://github.com/metin-aksu/kelimatik/blob/main/android/app/src/main/java/com/kelimatik/MainApplication.kt"
    click AndroidDB "https://github.com/metin-aksu/kelimatik/blob/main/android/app/src/main/assets/www/Kelimeler.db"
    click Gradle "https://github.com/metin-aksu/kelimatik/blob/main/android/app/build.gradle"
    click AppDelegateH "https://github.com/metin-aksu/kelimatik/blob/main/ios/Kelimatik/AppDelegate.h"
    click AppDelegateMM "https://github.com/metin-aksu/kelimatik/blob/main/ios/Kelimatik/AppDelegate.mm"
    click InfoPlist "https://github.com/metin-aksu/kelimatik/blob/main/ios/Kelimatik/Info.plist"
    click XcodeProj "https://github.com/metin-aksu/kelimatik/blob/main/ios/Kelimatik.xcodeproj"
    click Podfile "https://github.com/metin-aksu/kelimatik/tree/main/ios/Podfile"
    click DBWrapper "https://github.com/metin-aksu/kelimatik/blob/main/src/db/database.ts"
    click DBFile "https://github.com/metin-aksu/kelimatik/blob/main/src/db/Kelimeler.db"
    click HomeScreen "https://github.com/metin-aksu/kelimatik/blob/main/src/screens/HomeScreen.tsx"
    click TestFiles "https://github.com/metin-aksu/kelimatik/blob/main/__tests__/App.test.tsx"
    click Jest "https://github.com/metin-aksu/kelimatik/blob/main/jest.config.js"
    click PackageJSON "https://github.com/metin-aksu/kelimatik/blob/main/package.json"
    click Lock "https://github.com/metin-aksu/kelimatik/blob/main/package-lock.json"
    click Gemfile "https://github.com/metin-aksu/kelimatik/tree/main/Gemfile"
    click GemfileLock "https://github.com/metin-aksu/kelimatik/blob/main/Gemfile.lock"
```
