# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kastle.cc/readme/architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
