Extension Icon

Sadaqah Box

Manage your charity boxes and sadaqahs
Overview

Sadaqah Box Raycast Extension

Sadaqah Box Logo

Track Your Charity & Sadaqah Contributions

Raycast extension for tracking your charitable giving (Sadaqah) with multi-currency support and gold value conversion.

TypeScript React License

Sponsor

Erklab

Sponsored by erklab β€” Architecting production-grade systems with AI-driven velocity and human-centered precision.

Demo

Sadaqah Box Demo

Features

πŸ“¦ Box Management

  • Create Boxes: Organize your sadaqahs into different boxes (e.g., "Ramadan Charity", "Daily Sadaqah")
  • Track Progress: Monitor total value, count, and currency breakdown for each box
  • Multi-Currency Support: Handle donations in different currencies with automatic conversion tracking

⚑ Quick Actions

  • Presets: Define preset amounts for quick donation recording (e.g., "Daily Sadaqah - 0.1g Gold")
  • Keyboard Shortcuts: βŒ˜β‡§1-5 for quick preset access
  • Default Preset: Set a preset as default for one-click adding

πŸ“Š Statistics & Reporting

  • Dashboard Overview: Total boxes, sadaqahs, and value across all boxes
  • Collection Receipts: Generate beautiful markdown receipts when emptying boxes
  • Historical Data: Track all collections and their values over time

πŸ” Security & Performance

  • Input Validation: All inputs validated with Zod schemas
  • Request Timeouts: 30-second timeout with retry logic
  • API Response Caching: Intelligent caching to reduce API calls
  • Secure Error Handling: User-friendly error messages without exposing internals
  • Cryptographically Secure IDs: Using crypto.randomUUID() for ID generation

Installation

Prerequisites

  • Raycast installed on macOS
  • Node.js 18+ and npm
  • Access to a SadaqahBox API instance

Setup

  1. Clone this repository:
git clone <repository-url>
cd sadaqahbox-raycast
  1. Install dependencies:
npm install
  1. Configure the extension in Raycast:

    • Open Raycast Preferences
    • Go to Extensions β†’ Sadaqah Box
    • Set the following preferences:
      • API Host: Your SadaqahBox API URL (e.g., https://api.yourdomain.com)
      • API Key: Your Better Auth API key
  2. Build and install:

npm run build

Configuration

Extension Preferences

SettingDescriptionRequired
API HostBase URL of your SadaqahBox APIYes
API KeyBetter Auth API key for authenticationYes

Getting an API Key

  1. Log in to your SadaqahBox web application
  2. Navigate to Settings β†’ API Keys
  3. Generate a new API key
  4. Copy the key and paste it into Raycast preferences

Commands

Dashboard

Command: Dashboard

Main interface for managing your sadaqah boxes:

  • View all boxes with their statistics
  • Quick add using presets (βŒ˜β‡§1-5)
  • Open box details
  • Collect/empty boxes
  • Delete boxes

Manage Presets

Command: Manage Presets

Configure quick-add presets:

  • Create preset amounts with names and currencies
  • Set default preset for one-click adding
  • Reorder presets (βŒ˜β‡§β†‘/↓)
  • Delete unused presets

Architecture

src/
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ client.ts          # Base HTTP client with timeout & retry
β”‚   β”œβ”€β”€ index.ts           # API endpoint functions
β”‚   └── cached.ts          # Cached API wrappers
β”œβ”€β”€ constants/
β”‚   └── index.ts           # App constants & configuration
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ cache.ts           # Raycast Cache utilities
β”‚   β”œβ”€β”€ error-handler.ts   # Error categorization & sanitization
β”‚   β”œβ”€β”€ security.ts        # Secure ID generation
β”‚   └── type-guards.ts     # Runtime type checking
β”œβ”€β”€ validation/
β”‚   └── schemas.ts         # Zod validation schemas
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ quotes.json        # Quranic verses & Hadith on sadaqah
β”‚   └── quotes.ts          # Quote types & utilities
β”œβ”€β”€ services/
β”‚   └── quote-service.ts   # Random quote generation
β”œβ”€β”€ dashboard.tsx          # Main dashboard command
β”œβ”€β”€ box-detail.tsx         # Box detail view
β”œβ”€β”€ create-box.tsx         # Create box form
β”œβ”€β”€ edit-box.tsx           # Edit box form
β”œβ”€β”€ add-sadaqah.tsx        # Add sadaqah form
β”œβ”€β”€ manage-presets.tsx     # Preset management
β”œβ”€β”€ collection-detail.tsx  # Collection receipt view
β”œβ”€β”€ presets-storage.ts     # LocalStorage for presets
β”œβ”€β”€ auth-client.ts         # Better Auth client setup
└── types.ts               # TypeScript type definitions

API Integration

The extension communicates with a SadaqahBox backend API. All API calls include:

  • Authentication: API key via x-api-key header
  • Timeout Protection: 30-second request timeout with AbortController
  • Retry Logic: Automatic retry on timeout errors
  • Response Caching: Intelligent caching to minimize API calls

Cache Strategy

EndpointCache TTLInvalidation
List Boxes5 minutesOn create/update/delete
Get Box5 minutesOn update/delete
Stats2 minutesOn any mutation
Currencies1 hourOn currency changes
Currency Types1 hourOn type changes
SadaqahsNo cacheReal-time data
CollectionsNo cacheReal-time data

Development

Available Scripts

# Development mode with hot reload
npm run dev

# Build for production
npm run build

# Run linting
npm run lint

# Fix linting issues
npm run fix-lint

# Publish to Raycast Store
npm run publish

Project Structure

  • Components: Each command is a separate React component
  • API Layer: Modular API functions with separation of concerns
  • Utilities: Shared utilities for caching, errors, and security
  • Validation: Centralized Zod schemas for input validation

Adding New Features

  1. New API Endpoint: Add to src/api/index.ts and wrap in src/api/cached.ts
  2. New Form: Use validation/schemas.ts for validation
  3. New Command: Create component in src/ and register in package.json

Security Considerations

Input Validation

All user inputs are validated using Zod schemas:

  • String length limits
  • Numeric range validation
  • Required field checking
  • Type coercion with validation

Error Handling

  • Raw errors are logged internally
  • User-facing messages are sanitized
  • Error categorization (network, timeout, auth, etc.)

ID Generation

  • Cryptographically secure UUID generation
  • No predictable IDs from timestamps

Data Sanitization

  • Input sanitization to prevent XSS
  • URL validation for API endpoints

Troubleshooting

Common Issues

"API Key is not configured"

  • Check Raycast preferences for the extension
  • Ensure API key is copied correctly

"Request timed out"

  • Check internet connection
  • Verify API host URL is correct
  • API server may be slow/unresponsive

"Failed to load data"

  • Verify API key has correct permissions
  • Check API server is running
  • Look at Raycast logs for details

Debug Mode

To see detailed error logs:

  1. Open Raycast
  2. Run "Toggle Debug Mode" command
  3. Reproduce the issue
  4. Check Raycast logs

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see LICENSE file for details

Acknowledgments

  • Quranic verses and Hadith provided for inspiration
  • Built with Raycast API
  • Authentication powered by Better Auth

May your sadaqah be accepted 🀲

Categories
Source code