Skip to content

Commit b6af0c5

Browse files
feat: Improve Samnples
Adds CLI parsing, a `ClassifySingle` sample, and adds READMEs.
1 parent 591f938 commit b6af0c5

12 files changed

Lines changed: 2736 additions & 667 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ dist/
3333
.venv
3434

3535
src/generated
36+
37+
uploads/

samples/.env.example

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Athena SDK Configuration
2+
# Copy this file to .env and fill in your actual values
3+
4+
# Required: OAuth credentials
5+
ATHENA_CLIENT_ID=your-client-id
6+
ATHENA_CLIENT_SECRET=your-client-secret
7+
8+
# Required: Service configuration
9+
ATHENA_AFFILIATE=your-affiliate-name
10+
11+
# Optional: Service endpoints (defaults provided)
12+
# ATHENA_ISSUER_URL=https://crispthinking.auth0.com/ # Default: Crisp Auth0
13+
# ATHENA_GRPC_ADDRESS=trust.messages.crispthinking.com:443 # Default: production
14+
# ATHENA_AUDIENCE=crisp-athena-live # Default: live audience
15+
16+
# Development: Uncomment for debugging
17+
# NODE_ENV=development
18+
19+
# Usage:
20+
# 1. Copy this file: cp .env.example .env
21+
# 2. Edit .env with your actual values
22+
# 3. Source with auto-export: set -a; source .env; set +a
23+
# OR: export $(cat .env | grep -v '^#' | xargs)

samples/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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

samples/check-single/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Environment variables
5+
.env
6+
.env.local
7+
.env.*.local
8+
9+
# Logs
10+
*.log
11+
npm-debug.log*
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage/
21+
22+
# Test images (user provided)
23+
*.jpg
24+
*.jpeg
25+
*.png
26+
*.gif
27+
*.bmp
28+
*.webp
29+
test-*
30+
sample-*
31+
32+
# OS generated files
33+
.DS_Store
34+
.DS_Store?
35+
._*
36+
.Spotlight-V100
37+
.Trashes
38+
ehthumbs.db
39+
Thumbs.db

0 commit comments

Comments
 (0)