> For the complete documentation index, see [llms.txt](https://docs.kastle.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kastle.cc/readme/architecture.md).

# Architecture

Kastle is built with modern tools to ensure performance, security, and extensibility:

* **wxt**: A framework for building browser extensions with TypeScript, simplifying Chrome API integration.
* **React**: A component-based UI library for creating responsive, dynamic interfaces.
* **Kaspa WASM**: WebAssembly bindings for Kaspa’s core logic, enabling fast blockchain interactions (key generation, transaction signing) client-side.
* **TypeScript**: Type-safe codebase for reduced runtime errors.
* **Vite**: Bundling and development server for rapid iteration.

## Components

1. **Background Script** (Service Worker)
   * Handles wallet initialization, key management.
   * Listens for API requests from websites and forwards them to the UI for user approval.
2. **Content Script**
   * Injects a `window.kastle` object into websites to enable dApp interactions.
   * Relays messages between websites and the background script.
3. **UI Layer** (React)
   * **Popup**: Quick access to balance, send/receive buttons, and network settings.
   * **Options Page**: Manage seed phrases, view addresses, and configure security.
   * **Approval Dialogs**: User prompts for transaction signing or dApp connections.
4. **Kaspa WASM Module**
   * Compiled Rust code for address derivation, and transaction signing.
5. **Encrypted Storage**
   * Securely stores private keys and wallet metadata using Chrome’s `chrome.storage.local` API.
