# 🎮 AeThex Connect

**Next-Generation Communication Platform for Gamers & Game Developers**

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Node](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
[![PostgreSQL](https://img.shields.io/badge/postgresql-14%2B-blue.svg)](https://www.postgresql.org/)

AeThex Connect is a comprehensive communication platform built specifically for the gaming ecosystem. It combines real-time messaging, voice/video calls, game integration, and blockchain-based identity with a sustainable monetization model.

---

## ✨ Features

### 🔐 Phase 1: Blockchain Identity (.AETHEX Domains)
- Custom blockchain domain authentication (`username.aethex`)
- NFT-based ownership on Polygon
- Freename TLD integration
- Domain verification and management

### 💬 Phase 2: Real-Time Messaging
- End-to-end encrypted messaging
- Group conversations and DMs
- File sharing with encryption
- Rich media support (images, videos, voice messages)
- Real-time delivery via WebSocket
- Read receipts and typing indicators

### 🎮 Phase 3: GameForge Integration
- Auto-provisioned game project channels
- Role-based access control (Developer, Artist, Designer, Tester)
- System notifications (builds, commits, deployments)
- Team synchronization
- Project-specific communication

### 📞 Phase 4: Voice & Video Calls
- High-quality WebRTC calls
- 1-on-1 and group calling
- Screen sharing
- In-call chat
- Call recording (premium feature)
- STUN/TURN NAT traversal

### 🌐 Phase 5: Cross-Platform (Nexus Integration)
- Communication that follows players across games
- Friend system with cross-game presence
- Game session management
- Lobby system
- In-game overlay component
- Nexus Engine SDK plugin

### 💎 Phase 6: Premium Monetization
- Three-tier subscription model (Free, Premium, Enterprise)
- Blockchain .aethex domain NFT ownership
- Domain marketplace with 10% platform fee
- Stripe payment integration
- Usage analytics dashboard
- White-label solutions for enterprises

---

## 🚀 Quick Start

### Prerequisites
- Node.js 18+
- PostgreSQL 14+
- Stripe account (for monetization)
- Supabase project (optional)

### Installation

```bash
# Clone repository
git clone https://github.com/AeThex-Corporation/AeThex-Connect.git
cd AeThex-Connect

# Install dependencies
npm install

# Setup environment variables
cp .env.example .env
# Edit .env with your configuration

# Run database migrations
npm run migrate

# Start backend server
npm start

# Start frontend (new terminal)
cd src/frontend
npm install
npm run dev
```

**Server runs on:** `http://localhost:5000`  
**Frontend runs on:** `http://localhost:5173`

### Quick Test

```bash
# Test API health
curl http://localhost:5000/health

# Test domain availability
curl -X POST http://localhost:5000/api/premium/domains/check-availability \
  -H "Content-Type: application/json" \
  -d '{"domain": "testuser.aethex"}'
```

---

## 📖 Documentation

### Phase Guides
- [PHASE2-MESSAGING.md](PHASE2-MESSAGING.md) - Real-time chat implementation
- [PHASE3-GAMEFORGE.md](PHASE3-GAMEFORGE.md) - Game project integration
- [PHASE4-CALLS.md](PHASE4-CALLS.md) - Voice/video calling
- [PHASE5-COMPLETE.md](PHASE5-COMPLETE.md) - Cross-platform features
- [PHASE6-COMPLETE.md](PHASE6-COMPLETE.md) - Monetization & subscriptions

### Quick Start Guides
- [PHASE4-QUICK-START.md](PHASE4-QUICK-START.md) - WebRTC calls in 5 minutes
- [PHASE6-QUICK-START.md](PHASE6-QUICK-START.md) - Premium monetization in 10 minutes

### Integration Docs
- [docs/GAMEFORGE-EXAMPLES.md](docs/GAMEFORGE-EXAMPLES.md) - Integration code examples
- [nexus-sdk/README.md](nexus-sdk/README.md) - Game engine plugin docs
- [integration-package/README.md](integration-package/README.md) - Domain verification integration

---

## 💰 Pricing Tiers

| Feature | Free | Premium | Enterprise |
|---------|------|---------|------------|
| **Price** | $0 | $100/year | $500-5000/month |
| **Domain** | Subdomain | .aethex NFT | Custom domain |
| **Friends** | 5 max | Unlimited | Unlimited |
| **Messaging** | Text only | Text + Files | Everything |
| **Calls** | Audio only | HD Video (1080p) | 4K Video |
| **Storage** | 100 MB | 10 GB | Unlimited |
| **Analytics** | ❌ | ✅ | Advanced |
| **Branding** | AeThex | Custom | White-label |
| **Support** | Community | Priority | Dedicated |

---

## 🏗️ Architecture

```
┌─────────────────────────────────────────────────────────┐
│                    AeThex Connect                        │
├─────────────────────────────────────────────────────────┤
│  Frontend (React + Vite)                                 │
│  - Real-time messaging UI                                │
│  - WebRTC call interface                                 │
│  - Domain verification                                   │
│  - Premium upgrade flow                                  │
├─────────────────────────────────────────────────────────┤
│  Backend (Node.js + Express)                            │
│  - REST API                                             │
│  - WebSocket (Socket.IO)                                │
│  - WebRTC signaling                                     │
│  - Stripe webhooks                                      │
├─────────────────────────────────────────────────────────┤
│  Services                                               │
│  - Messaging Service                                    │
│  - Call Service (WebRTC)                               │
│  - Premium Service (Stripe)                            │
│  - GameForge Integration                               │
│  - Nexus Integration                                   │
├─────────────────────────────────────────────────────────┤
│  Database (PostgreSQL + Supabase)                       │
│  - Users & Authentication                               │
│  - Conversations & Messages                             │
│  - Blockchain Domains                                   │
│  - Premium Subscriptions                                │
└─────────────────────────────────────────────────────────┘
```

---

## 🔧 Configuration

Create a `.env` file in the root directory:

```bash
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/aethex_connect
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key

# Server
PORT=5000
NODE_ENV=development
JWT_SECRET=your-super-secret-jwt-key

# Stripe (Premium Features)
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

# Blockchain
POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY
FREENAME_REGISTRY_ADDRESS=0x...

# GameForge Integration
GAMEFORGE_API_KEY=your-api-key
GAMEFORGE_API_SECRET=your-secret

# WebRTC
STUN_SERVER=stun:stun.l.google.com:19302
TURN_SERVER=turn:your-turn-server.com:3478
```

---

## 🤝 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

---

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

## 🔗 Links

- **Documentation:** [Full Documentation](PROJECT-README.md)
- **Support:** [GitHub Issues](https://github.com/AeThex-Corporation/AeThex-Connect/issues)
- **Website:** [AeThex Corporation](https://aethex.com)
