# leoorellanad/anki-card-creator architecture

> Architecture diagram of the GitHub repository leoorellanad/anki-card-creator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leoorellanad/anki-card-creator
- Repository: https://github.com/leoorellanad/anki-card-creator

## Overview

##### Project type and purpose
- This is an Electron-based desktop application with a React + TypeScript + Vite front end and a Node/Electron main process for backend logic.
- From the file tree and README we see:
- src/ui → React UI, Vite build, Tailwind CSS, i18n
- src/electron → Electron main process, SQLite DB access, IPC handlers, services (Anki, TTS, user, card, language)
- app.db → local SQLite database
- electron-builder.json → packaging config

##### File structure
- Top-level:
- package.json, tsconfig*.json, tailwind.config.ts, vite.config.ts
- index.html → shell for React/Vite renderer
- src/ui (renderer process):
- App.tsx, pages, components, context, hooks, services (configService)
- i18n integration
- src/electron (main process + preload):
- main.ts → bootstraps BrowserWindow and preload script
- preload.cts → exposes safe IPC APIs to renderer
- ipc/*Handler.ts → map incoming IPC calls to service methods
- services/*.ts → business logic and external integrations
- db/*.ts → database initialization & connection
- models/*.ts → TypeScript ORM-style models
- utils/ → audio, logging, config helpers

##### Extract additional insights from the README
- The README is the standard Vite + React template documentation, confirming:
- React with Fast Refresh via @vitejs/plugin-react
- TypeScript and ESLint setup

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Renderer Process"
        direction TB
        UIEntry["main.tsx"]:::ui
        App["App.tsx"]:::ui
        Pages["Pages"]:::ui
        Components["Components"]:::ui
        Context["SettingsContext"]:::ui
        Hooks["Hooks"]:::ui
        ConfigSvc["ConfigService (IPC Facade)"]:::ui
        I18n["i18n Layer"]:::ui
    end

    subgraph "Main Process"
        direction TB
        Preload["Preload Script"]:::backend
        MainEntry["main.ts"]:::backend

        subgraph "IPC Handlers"
            direction TB
            AnkiH["AnkiHandler"]:::backend
            CardH["CardHandler"]:::backend
            ConfigH["ConfigHandler"]:::backend
            LangH["LanguageHandler"]:::backend
            UserH["UserHandler"]:::backend
            TTSH["ttsHandlerEdge"]:::backend
        end

        subgraph "Services"
            direction TB
            AnkiS["AnkiService"]:::backend
            CardS["CardService"]:::backend
            TTS["EdgeTTSService"]:::backend
            LangS["LanguageService"]:::backend
            UserS["UserService"]:::backend
        end

        subgraph "Database Layer"
            direction TB
            InitDB["db/init"]:::backend
            DBConn["db/database"]:::backend
            Models["Models"]:::backend
        end

        Utils["Utils"]:::backend
        PathRes["PathResolver"]:::backend
    end

    subgraph "External & Config"
        direction TB
        DBFile["SQLite DB (app.db)"]:::db
        AnkiExt["AnkiConnect API"]:::external
        TTSext["Edge TTS Engine"]:::external
        Builder["electron-builder.json"]:::external
    end

    UIEntry --> App
    App --> Pages
    App --> Components
    App --> Context
    App --> Hooks
    App --> ConfigSvc
    App --> I18n

    ConfigSvc -->|"window.api calls"| Preload
    I18n --> ConfigSvc

    Preload -->|"ipcRenderer.send"| MainEntry

    MainEntry --> AnkiH
    MainEntry --> CardH
    MainEntry --> ConfigH
    MainEntry --> LangH
    MainEntry --> UserH
    MainEntry --> TTSH

    AnkiH --> AnkiS
    CardH --> CardS
    ConfigH --> PathRes
    LangH --> LangS
    UserH --> UserS
    TTSH --> TTS

    AnkiS --> AnkiExt
    TTS --> TTSext

    CardS --> DBConn
    LangS --> DBConn
    UserS --> DBConn

    InitDB --> DBConn
    DBConn --> Models
    DBConn --> DBFile
    Models --> DBFile

    Utils --> AnkiS
    Utils --> CardS
    Utils --> TTS
    Utils --> LangS
    Utils --> UserS
    PathRes --> Utils

    click UIEntry "https://github.com/leoorellanad/anki-card-creator/blob/main/src/ui/main.tsx"
    click App "https://github.com/leoorellanad/anki-card-creator/blob/main/src/ui/App.tsx"
    click Pages "https://github.com/leoorellanad/anki-card-creator/tree/main/src/ui/pages/"
    click Components "https://github.com/leoorellanad/anki-card-creator/tree/main/src/ui/components/"
    click Context "https://github.com/leoorellanad/anki-card-creator/blob/main/src/ui/context/SettingsContext.tsx"
    click Hooks "https://github.com/leoorellanad/anki-card-creator/tree/main/src/ui/hooks/"
    click ConfigSvc "https://github.com/leoorellanad/anki-card-creator/blob/main/src/ui/services/configService.ts"
    click I18n "https://github.com/leoorellanad/anki-card-creator/blob/main/src/i18n/i18n.ts"
    click Preload "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/preload.cts"
    click MainEntry "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/main.ts"
    click AnkiH "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/ipc/AnkiHandler.ts"
    click CardH "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/ipc/CardHandler.ts"
    click ConfigH "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/ipc/ConfigHandler.ts"
    click LangH "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/ipc/LanguageHandler.ts"
    click UserH "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/ipc/UserHandler.ts"
    click TTSH "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/ipc/ttsHandlerEdge.ts"
    click AnkiS "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/services/AnkiService.ts"
    click CardS "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/services/CardService.ts"
    click TTS "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/services/EdgeTTSService.ts"
    click LangS "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/services/LanguageService.ts"
    click UserS "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/services/UserService.ts"
    click InitDB "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/db/init.ts"
    click DBConn "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/db/database.ts"
    click Models "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/models/CardModel.ts"
    click Models "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/models/LanguageModel.ts"
    click Models "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/models/UserModel.ts"
    click Utils "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/utils.ts"
    click PathRes "https://github.com/leoorellanad/anki-card-creator/blob/main/src/electron/pathResolver.ts"
    click DBFile "https://github.com/leoorellanad/anki-card-creator/blob/main/app.db"
    click Builder "https://github.com/leoorellanad/anki-card-creator/blob/main/electron-builder.json"

    classDef ui fill:#D6E4FF,stroke:#4C6EF5,color:#000
    classDef backend fill:#D4F8E8,stroke:#2F9E44,color:#000
    classDef external fill:#FFE6CC,stroke:#F08C00,color:#000
    classDef db fill:#F3E5F5,stroke:#8E44AD,color:#000
```
