📋 Project Overview
API Gateway & User Portal
Full-stack application built with Node.js backend and Next.js frontend providing user authentication, API key management, and usage analytics.
- 🔐 JWT Authentication System
- 🔑 API Key Management (Max 3/user)
- 📊 Usage Analytics & Quota Tracking
- 💻 React-based Web Dashboard
Python RAG API
FastAPI-based content moderation service with AI-powered analysis using Google Gemini and ChromaDB vector database.
- 🛡️ AI-Powered Content Moderation
- 📚 Vector Database Integration
- 🎯 Custom Rule Management
- 🔒 Multi-User Environment Support
🏗️ System Architecture
High-Level Architecture
Frontend Layer
Next.js 15 with React 19, TypeScript, and Tailwind CSS for modern, responsive UI
API Gateway Layer
Node.js/Express backend with SQLite database and JWT authentication
AI Moderation Layer
FastAPI with ChromaDB vector database and Google Gemini AI integration
🎥 Video Demo
Platform Walkthrough
Watch this comprehensive demo to see the Content Policy Platform in action, including user authentication, API key management, content moderation setup, and real-time testing of the AI-powered moderation system.
📁 Project Structure
Complete Project Layout
The project consists of two main applications with comprehensive documentation and testing scripts.
📂 Moderato/
├── 📁 apigateway-v1/ // API Gateway & User Portal
│ ├── 📁 .github/workflows/
│ │ └── 📄 ci.yml // GitHub Actions CI/CD
│ ├── 📁 nodejs-backend/ // Node.js API Service
│ │ ├── 📁 database/
│ │ │ ├── 📄 schema.sql
│ │ │ └── 📄 sqlite-schema.sql
│ │ ├── 📁 src/
│ │ │ ├── 📄 server.js // Express server & routes
│ │ │ ├── 📄 auth.js // JWT authentication
│ │ │ ├── 📄 database.js // SQLite operations
│ │ │ ├── 📄 apikeys.js // API key management
│ │ │ ├── 📄 quota.js // Usage tracking
│ │ │ ├── 📄 models.js // Data models
│ │ │ ├── 📄 utils.js // Utilities
│ │ │ └── 📄 endpoints.js // Public API endpoints
│ │ ├── 📄 package.json // Project configuration
│ │ └── 📄 README.md
│ ├── 📁 userportal/ // Next.js Frontend
│ │ ├── 📁 app/ // Next.js app router
│ │ │ ├── 📁 api-testing/
│ │ │ ├── 📁 apikeys/
│ │ │ ├── 📁 auth/
│ │ │ ├── 📁 docs/
│ │ │ ├── 📁 settings/
│ │ │ ├── 📄 layout.tsx
│ │ │ └── 📄 page.tsx
│ │ ├── 📁 components/ // React components
│ │ │ ├── 📄 ApiKeyManagement.tsx
│ │ │ ├── 📄 DashboardHome.tsx
│ │ │ ├── 📄 LoginForm.tsx
│ │ │ └── 📄 ... (15+ components)
│ │ ├── 📁 hooks/ // Custom React hooks
│ │ ├── 📁 lib/ // Utility libraries
│ │ ├── 📄 package.json
│ │ └── 📄 tsconfig.json
│ ├── 📄 API_DOCUMENTATION.md // Complete API docs
│ ├── 📄 README.md // Main documentation
│ └── 📄 *.bat, *.sh, *.ps1 // Testing & setup scripts
├── 📁 python-rag-api/ // AI Content Moderation API
│ ├── 📁 app/
│ │ ├── 📁 core/
│ │ │ └── 📄 config.py // Environment configuration
│ │ ├── 📁 endpoints/
│ │ │ └── 📄 moderation.py // API endpoints
│ │ ├── 📄 main.py // FastAPI application
│ │ ├── 📄 services.py // Business logic
│ │ └── 📄 schemas.py // Pydantic models
│ ├── 📁 chroma_db/ // Vector database storage
│ ├── 📄 requirements.txt // Python dependencies
│ ├── 📄 test_client.html // HTML test interface
│ └── 📄 README.md
├── 📁 docs/ // Documentation Website
│ ├── 📄 index.html // Main documentation page
│ ├── 📄 styles.css // Dark theme styling
│ └── 📄 script.js // Interactive functionality
└── 📄 COMPLETE_PROJECT_DOCUMENTATION.md // Comprehensive guide
🛠️ Technology Stack
Backend
Frontend
Security
🌐 API Gateway & User Portal
🔐 Authentication System
- User Registration/Login: Email validation and secure password handling
- JWT Token Management: 1-hour expiry with secure token tracking
- Password Security: SHA256 hashing with salt protection
- Token Revocation: Immediate invalidation on logout
🔑 API Key Management
- Secure Generation: 32-character hash with 'ak_' prefix
- User Limits: Maximum 3 API keys per user account
- Status Control: Active/inactive/revoked states
- Usage Tracking: Lifetime and monthly statistics
📊 Quota System
- Monthly Limits: 100 requests per API key per month
- Auto Reset: Automatic quota reset on first day of month
- Real-time Monitoring: Live usage updates and warnings
- Enforcement: HTTP 429 when quota exceeded
🐍 Python RAG API
🤖 AI-Powered Moderation
- Google Gemini Integration: Advanced language model for content analysis
- Semantic Rule Matching: Vector similarity search for relevant rules
- Multi-Rule Evaluation: Comprehensive analysis against multiple policies
- Confidence Scoring: Detailed reasoning for moderation decisions
📚 Vector Database
- ChromaDB Integration: Efficient semantic search capabilities
- Rule Storage: Persistent storage with metadata and context
- Top-K Retrieval: Finds 5 most relevant rules per query
- Auto Initialization: Automatic database setup and management
🎯 Custom Rules
- User-Specific Rules: Organized by API key and user ID
- CRUD Operations: Complete rule lifecycle management
- Flexible Format: Support for complex, multi-paragraph policies
- Real-time Updates: No service restart required for rule changes
🚀 Quick Start Guide
Prerequisites
# Required Software
- Node.js (18.0+)
- npm or yarn
- Python (3.11+)
Start API Gateway
# Backend (Node.js)
cd apigateway-v1/nodejs-backend
npm install
npm start
# Frontend (Next.js)
cd apigateway-v1/userportal
npm install
npm run dev
Start Python RAG API
# Setup Environment
cd python-rag-api
python -m venv .venv
.venv\Scripts\activate # Windows
# Install & Configure
pip install -r requirements.txt
# Create .env with GEMINI_API_KEY
# Start Service
uvicorn app.main:app --reload
Access Applications
📚 API Documentation
API Gateway Endpoints (Port 8080)
Authentication
API Key Management
Python RAG API Endpoints (Port 8000)
Rule Management
Content Moderation
🎯 Use Cases
Social Media Platform
AI-powered content moderation for user-generated content with custom community guidelines and real-time analysis.
Enterprise SaaS
Multi-tenant content policy management with client isolation and environment-specific rule sets.
Developer Platform
API key management with quota tracking and usage analytics for development teams.