# tkhwang/tkcapture architecture

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

- Interactive diagram: https://gitdiagram.com/tkhwang/tkcapture
- Repository: https://github.com/tkhwang/tkcapture

## Overview

##### Project Type and Purpose
- The project is designed as a multi-app monorepo featuring a backend (using Nest.js) and two client applications—a mobile app (tkCaptureBook) built with React Native Expo and a web app.
- It’s positioned as a development tool suite with AI components (as noted in the “Common” section) and covers authentication, book searching, camera features, and other UI‐features using libraries like jotai and tailwind.
- The README emphasizes a tech stack for the mobile app that includes supabase for backend services, which—per your special instructions—should be directly connected to the mobile app rather than integrated with the Nest.js backend.

##### Breaking Down the File Structure
- There is a clear separation at the top level:
- apps/backend → Contains Nest.js-based backend logic, controllers, modules, and test suites.
- apps/tk-capture-book → Houses the mobile application’s business logic, user interface (React Native with Expo), supabase calls, assets, and various features (auth, camera, book search, etc.).
- apps/web → Contains a web interface built with a modern React-based framework (layout, CSS, components).
- packages/mobile-components → A shared library that might offer UI components for mobile.
- Build and configuration files (e.g., package.json files, tsconfigs, Android & iOS subdirectories) show that each application is configured separately for its respective platform.

##### Major Components and Relationships
a. Core Components to Represent:
- Mobile App (tkCaptureBook): Built with React Native Expo. This is the primary consumer of Supabase given the new instructions.
- Web App: Provides a browser-based user experience.
- Supabase: As the data and authentication backend. With the custom instruction, this is disconnected from the backend service and shown as a direct dependency of the mobile app.
- Shared/Utility Components: Such as libraries (mobile-components) and possibly other utilities (e.g., jotai-storage, react-query-client) seen in the tkCaptureBook’s lib directory.

b. Connections and Data Flow:
- The Web App might or might not directly interact with Supabase based on how its own lib/integration is defined; assess if there’s a direct connection or if it relies on the Nest.js API (if it does use Supabase directly, mark that accordingly).

##### Architectural Patterns and Technologies
- That the mobile app uses a modern frontend stack (React Native Expo with jotai state management and tailwind css styling).
- That the backend is implemented with a Nest.js framework suggesting a modular architecture.
- That Supabase is used as a Backend-as-a-Service for mobile app data management and authentication (and now, per instructions, it is decoupled from the backend).
- Use of build/deployment tools (EAS Build scripts for iOS and Android) as part of the mobile development cycle.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Applications
    subgraph "Client Applications"
        direction TB
        MobileApp("Mobile App (tkCaptureBook)"):::frontend
        subgraph "Mobile App Internals"
            direction TB
            MobileSupabaseClient("Supabase Client Integration"):::integration
            MobileSupabaseUser("Supabase User Repository"):::repository
        end
        WebApp("Web Application"):::frontend
    end

    %% Backend Services
    subgraph "Backend Services"
        direction TB
        Backend("API/Backend Server (Nest.js)"):::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Supabase("Supabase (Data & Auth Service)"):::external
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        Shared("Mobile Components Library"):::library
    end

    %% Connections
    MobileApp -->|"uses"| MobileSupabaseClient
    MobileApp -->|"uses"| MobileSupabaseUser
    MobileSupabaseClient -->|"connects"| Supabase
    MobileSupabaseUser -->|"handlesAuth"| Supabase
    MobileApp -->|"UserAuth&DataQueries"| Supabase
    WebApp -->|"APIcalls"| Backend
    MobileApp -->|"Utilizes"| Shared
    WebApp -->|"Utilizes"| Shared

    %% Click Events
    click MobileApp "https://github.com/tkhwang/tkcapture/tree/main/apps/tk-capture-book"
    click WebApp "https://github.com/tkhwang/tkcapture/tree/main/apps/web"
    click Backend "https://github.com/tkhwang/tkcapture/tree/main/apps/backend"
    click MobileSupabaseClient "https://github.com/tkhwang/tkcapture/blob/main/apps/tk-capture-book/lib/supabase.ts"
    click MobileSupabaseUser "https://github.com/tkhwang/tkcapture/blob/main/apps/tk-capture-book/features/user/repository/supabase/supabase-user-repository.ts"
    click Shared "https://github.com/tkhwang/tkcapture/tree/main/packages/mobile-components"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#D5DBDB,stroke:#566573,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef library fill:#E8DAEF,stroke:#7D3C98,stroke-width:2px;
    classDef integration fill:#D1F2EB,stroke:#17A589,stroke-width:2px;
    classDef repository fill:#FAD7A0,stroke:#CA6F1E,stroke-width:2px;
```
