new redis migration

Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-12-15 16:35:35 +01:00
padre ad7a1cf0a7
commit 3ce64eeb8e
Se han modificado 20 ficheros con 1021 adiciones y 712 borrados

Ver fichero

@@ -2,7 +2,7 @@
## 📋 Project Overview
**Hasher** is a modern, high-performance hash search and generation tool built with Next.js and powered by Elasticsearch. It provides a beautiful web interface for searching hash values and generating cryptographic hashes from plaintext.
**Hasher** is a modern, high-performance hash search and generation tool built with Next.js and powered by Redis. It provides a beautiful web interface for searching hash values and generating cryptographic hashes from plaintext.
### Version: 1.0.0
### Status: ✅ Production Ready
@@ -13,7 +13,7 @@
## ✨ Key Features
### 🔍 Hash Search
- Search for MD5, SHA1, SHA256, SHA512, and Bcrypt hashes
- Search for MD5, SHA1, SHA256, and SHA512 hashes
- Automatic hash type detection
- Case-insensitive matching
- Real-time results
@@ -25,10 +25,10 @@
- Copy-to-clipboard functionality
### 📊 Backend
- Elasticsearch 8.x integration
- 10-shard index for horizontal scaling
- Redis integration with ioredis
- Key-value storage with hash indexes
- RESTful API with JSON responses
- Automatic index creation and initialization
- Automatic key structure initialization
- Health monitoring endpoint
### 🎨 Frontend
@@ -52,7 +52,7 @@
### Stack
- **Frontend**: Next.js 16.0, React 19.2, Tailwind CSS 4.x
- **Backend**: Next.js API Routes, Node.js 18+
- **Database**: Elasticsearch 8.x
- **Database**: Redis 6.x+
- **Language**: TypeScript 5.x
- **Icons**: Lucide React
@@ -68,7 +68,7 @@ hasher/
│ └── globals.css # Global styles
├── lib/
│ ├── elasticsearch.ts # ES client & config
│ ├── redis.ts # Redis client & config
│ └── hash.ts # Hash utilities
├── scripts/
@@ -106,7 +106,7 @@ Search for hashes or generate from plaintext
- **Output**: Hash results or generated hashes
### GET /api/health
Check system health and Elasticsearch status
Check system health and Redis status
- **Output**: System status and statistics
---
@@ -139,28 +139,34 @@ npm run index-file wordlist.txt -- --batch-size 500
### Environment Configuration
```bash
# Optional: Set Elasticsearch endpoint
export ELASTICSEARCH_NODE=http://localhost:9200
# Optional: Set Redis connection details
export REDIS_HOST=localhost
export REDIS_PORT=6379
export REDIS_PASSWORD=your-password
export REDIS_DB=0
```
---
## 🗄️ Elasticsearch Configuration
## 🗄️ Redis Data Structure
### Index: `hasher`
- **Shards**: 10 (horizontal scaling)
- **Replicas**: 1 (redundancy)
- **Analyzer**: Custom lowercase analyzer
### Key Patterns
- **Documents**: `hash:plaintext:{plaintext}` - Main document storage
- **MD5 Index**: `hash:index:md5:{hash}` - MD5 hash lookup
- **SHA1 Index**: `hash:index:sha1:{hash}` - SHA1 hash lookup
- **SHA256 Index**: `hash:index:sha256:{hash}` - SHA256 hash lookup
- **SHA512 Index**: `hash:index:sha512:{hash}` - SHA512 hash lookup
- **Statistics**: `hash:stats` - Redis Hash with count and size
### Schema
### Document Schema
```json
{
"plaintext": "text + keyword",
"md5": "keyword",
"sha1": "keyword",
"sha256": "keyword",
"sha512": "keyword",
"created_at": "date"
"plaintext": "string",
"md5": "string",
"sha1": "string",
"sha256": "string",
"sha512": "string",
"created_at": "ISO 8601 date string"
}
```
@@ -174,16 +180,15 @@ export ELASTICSEARCH_NODE=http://localhost:9200
| SHA1 | 40 | `^[a-f0-9]{40}$` |
| SHA256 | 64 | `^[a-f0-9]{64}$` |
| SHA512 | 128 | `^[a-f0-9]{128}$` |
| Bcrypt | 60 | `^\$2[abxy]\$` |
---
## 🚀 Performance Metrics
- **Bulk Indexing**: 1000-5000 docs/sec
- **Search Latency**: <50ms (typical)
- **Concurrent Users**: 50+ supported
- **Horizontal Scaling**: Ready with 10 shards
- **Search Latency**: <10ms (typical O(1) lookups)
- **Concurrent Users**: 100+ supported
- **Horizontal Scaling**: Ready with Redis Cluster
---
@@ -221,9 +226,9 @@ export ELASTICSEARCH_NODE=http://localhost:9200
### Requirements
- Node.js 18.x or higher
- Elasticsearch 8.x
- Redis 6.x or higher
- 512MB RAM minimum
- Internet connection for Elasticsearch
- Redis server running locally or remotely
---
@@ -245,7 +250,6 @@ export ELASTICSEARCH_NODE=http://localhost:9200
## 📈 Future Enhancements
### Planned Features
- Bcrypt hash validation
- Argon2 hash support
- Search history
- Batch lookup
@@ -287,7 +291,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
## 🙏 Acknowledgments
- Built with [Next.js](https://nextjs.org/)
- Powered by [Elasticsearch](https://www.elastic.co/)
- Powered by [Redis](https://redis.io/)
- Icons by [Lucide](https://lucide.dev/)
- Styled with [Tailwind CSS](https://tailwindcss.com/)
@@ -315,7 +319,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
### Completed ✅
- [x] Core hash search functionality
- [x] Hash generation from plaintext
- [x] Elasticsearch integration
- [x] Redis integration
- [x] Modern responsive UI
- [x] Bulk indexing script
- [x] API endpoints