> For the complete documentation index, see [llms.txt](https://nakis-organization.gitbook.io/naki-wallet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nakis-organization.gitbook.io/naki-wallet/technical-architecture.md).

# Technical Architecture

## Technical Architecture

### Technology Stack 📚

Naki Wallet leverages a modern tech stack designed for cross-platform mobile development:

* **Frontend Framework**: React Native with Expo
* **UI Framework**: NativeWind (Tailwind CSS for React Native) with Gluestack UI
* **Navigation**: Expo Router for type-safe navigation
* **State Management**: React Hooks and Context API
* **Authentication**: Privy SDK
* **Blockchain Integration**: Base Testnet via Privy SDK
* **Payment Processing**: MoonPay Sandbox
* **Styling**: CSS-in-JS with styled-components and Tailwind
* **Storage**: SecureStore for sensitive data
* **QR Code**: Expo Barcode Scanner and React Native QR Code SVG

### Application Architecture 🧩

The application follows a modular, component-based architecture:

* **App Directory Structure**:
  * `/app`: Main screens using Expo Router file-based routing
  * `/components`: Reusable UI components
  * `/hooks`: Custom React hooks for shared functionality
  * `/constants`: App-wide constants and configuration
  * `/assets`: Images, icons, and other static resources
* **Authentication Flow**:
  * Powered by Privy, handling email verification
  * Automatic wallet creation on successful authentication
  * Session management with secure token storage
* **Data Flow**:
  * React Context for global state management
  * Custom hooks for encapsulating blockchain functionality
  * Component-based UI with props for data passing

### Blockchain Integration 🔗

Naki integrates with blockchain technology through several key components:

* **Wallet Management**: Automatically creates and manages embedded wallets via Privy SDK
* **Network**: Connected to Base Testnet for testing and development
* **Token**: Focused on USDC stablecoin transactions
* **Transactions**: Abstracted through custom hooks (`useBlockchain.ts`)
* **Balance Management**: Local secure storage with blockchain verification
* **Transaction History**: Combination of local cache and blockchain queries

### Security and Storage 🔒

Security is a primary concern in our architecture:

* **Authentication Security**:
  * Email verification through Privy
  * No storage of private keys on device
  * Session-based authentication with secure tokens
* **Data Storage**:
  * Sensitive information stored using Expo SecureStore
  * Transaction data cached locally with encryption
  * No private keys stored directly in the application
* **Transaction Security**:
  * All blockchain transactions signed securely through Privy SDK
  * Balance validation before transaction execution
  * Error handling and transaction verification
* **Network Security**:
  * HTTPS for all API communications
  * Rate limiting for sensitive operations
  * Input validation and sanitization

### Performance Considerations ⚡

The architecture optimizes for mobile performance:

* Lazy loading of screens and components
* Minimal dependencies to reduce bundle size
* Efficient re-rendering through React hooks
* Optimized blockchain interactions to reduce network calls
* Local caching for frequently accessed data

This technical foundation provides a solid base for future expansion while maintaining security and performance for end users.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://nakis-organization.gitbook.io/naki-wallet/technical-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.
