|
| 1 | +# Athena SDK Samples |
| 2 | + |
| 3 | +This directory contains example applications demonstrating various use cases of the Athena Classifier SDK. |
| 4 | + |
| 5 | +## Configuration |
| 6 | + |
| 7 | +All samples use a shared configuration system. Create a `.env` file in this directory: |
| 8 | + |
| 9 | +```bash |
| 10 | +# Copy the example configuration |
| 11 | +cp .env.example .env |
| 12 | + |
| 13 | +# Edit with your credentials |
| 14 | +# Required |
| 15 | +ATHENA_CLIENT_ID=your-client-id |
| 16 | +ATHENA_CLIENT_SECRET=your-client-secret |
| 17 | +ATHENA_AFFILIATE=your-affiliate-name |
| 18 | + |
| 19 | +# Optional (defaults provided) |
| 20 | +# ATHENA_ISSUER_URL=https://crispthinking.auth0.com/ |
| 21 | +# ATHENA_GRPC_ADDRESS=trust.messages.crispthinking.com:443 |
| 22 | +# ATHENA_AUDIENCE=crisp-athena-live |
| 23 | + |
| 24 | +# Source the environment with auto-export |
| 25 | +set -a; source .env; set +a |
| 26 | +``` |
| 27 | + |
| 28 | +## Available Samples |
| 29 | + |
| 30 | +### 🔍 [check-single](./check-single/) |
| 31 | +**Single Image Classification CLI Tool** |
| 32 | + |
| 33 | +A production-ready command-line interface for classifying individual images. Features comprehensive argument parsing, error handling, and formatted output. |
| 34 | + |
| 35 | +- **Use Case**: Single image classification with CLI interface |
| 36 | +- **Features**: Multiple image formats, verbose mode, affiliate override |
| 37 | +- **Configuration**: Uses shared .env, no deployment ID needed (always empty for classifySingle) |
| 38 | +- **Best For**: Batch processing, scripting, development testing |
| 39 | + |
| 40 | +```bash |
| 41 | +cd check-single |
| 42 | +npm install |
| 43 | +node index.js ./my-image.jpg --verbose |
| 44 | +``` |
| 45 | + |
| 46 | +### � [hash-server](./hash-server/) |
| 47 | +**Continuous Image Classification Server** |
| 48 | + |
| 49 | +A TypeScript server for continuous image classification with hash computation. Processes images in batches with real-time output. |
| 50 | + |
| 51 | +- **Use Case**: Long-running classification service with hash computation |
| 52 | +- **Features**: Continuous processing, MD5/SHA1 hashes, graceful shutdown |
| 53 | +- **Configuration**: Uses shared .env, requires deployment ID as CLI parameter |
| 54 | +- **Best For**: Production services, continuous monitoring, batch processing |
| 55 | + |
| 56 | +```bash |
| 57 | +cd hash-server |
| 58 | +npm install |
| 59 | +npm start my-deployment-id |
| 60 | +``` |
| 61 | + |
| 62 | +```bash |
| 63 | +cd hash-server |
| 64 | +npm install |
| 65 | +npm start |
| 66 | +``` |
| 67 | + |
| 68 | +## Quick Start |
| 69 | + |
| 70 | +1. **Choose a sample** based on your use case |
| 71 | +2. **Navigate to the sample directory** |
| 72 | +3. **Install dependencies**: `npm install` |
| 73 | +4. **Configure environment** variables (see each sample's README) |
| 74 | +5. **Run the sample**: `npm start` or `node index.js` |
| 75 | + |
| 76 | +## Common Setup |
| 77 | + |
| 78 | +All samples require Athena service credentials. Create a `.env` file in each sample directory: |
| 79 | + |
| 80 | +```bash |
| 81 | +# Copy the template |
| 82 | +cp .env.example .env |
| 83 | + |
| 84 | +# Edit with your credentials (minimum required) |
| 85 | +ATHENA_CLIENT_ID=your-client-id |
| 86 | +ATHENA_CLIENT_SECRET=your-client-secret |
| 87 | +ATHENA_AFFILIATE=your-affiliate |
| 88 | + |
| 89 | +# Optional: Most samples use sensible defaults |
| 90 | +# ATHENA_DEPLOYMENT_ID=your-deployment-id # Default: empty (for classifySingle) |
| 91 | +# ATHENA_ISSUER_URL=https://crispthinking.auth0.com/ # Default: Crisp Auth0 |
| 92 | + |
| 93 | +# Source the environment |
| 94 | +source .env |
| 95 | +``` |
| 96 | + |
| 97 | +## Sample Comparison |
| 98 | + |
| 99 | +| Sample | Type | Complexity | Use Case | |
| 100 | +|--------|------|------------|----------| |
| 101 | +| check-single | CLI | Simple | Single image classification | |
| 102 | +| hash-server | Web Server | Medium | Image hashing service | |
| 103 | + |
| 104 | +## Development |
| 105 | + |
| 106 | +### Creating New Samples |
| 107 | + |
| 108 | +1. Create a new directory under `samples/` |
| 109 | +2. Add a `package.json` with SDK dependency: `"@crispthinking/athena-classifier-sdk": "file:../../"` |
| 110 | +3. Include comprehensive README with usage examples |
| 111 | +4. Add environment template (`.env.example`) |
| 112 | +5. Include proper error handling and logging |
| 113 | + |
| 114 | +### Testing Samples |
| 115 | + |
| 116 | +```bash |
| 117 | +# Test all samples |
| 118 | +for sample in */; do |
| 119 | + echo "Testing $sample" |
| 120 | + cd "$sample" && npm install && npm test |
| 121 | + cd .. |
| 122 | +done |
| 123 | +``` |
| 124 | + |
| 125 | +## Support |
| 126 | + |
| 127 | +- **Documentation**: See individual sample READMEs |
| 128 | +- **Issues**: Report problems in the main repository |
| 129 | +- **Examples**: Each sample includes comprehensive usage examples |
0 commit comments