A web platform for an AI-powered Web3 security platform that provides smart contract analysis, vulnerability detection, and real-time security monitoring.
- Modular Architecture: Clean, scalable NestJS architecture with separation of concerns
- Database: PostgreSQL with Prisma ORM for type-safe database operations
- Caching & Queues: Redis for caching and BullMQ for background job processing
- Logging: Winston-based structured logging with multiple levels and outputs
- API Documentation: Swagger/OpenAPI documentation
- Security: Built-in rate limiting, validation, and security best practices
- Docker Support: Complete Docker setup for development and production
- TypeScript: Full TypeScript support with strict typing
- Framework: NestJS
- Language: TypeScript
- Database: PostgreSQL + Prisma ORM
- Cache/Queue: Redis + BullMQ
- Logging: Winston
- Documentation: Swagger/OpenAPI
- Containerization: Docker & Docker Compose
src/
├── app.controller.ts # Application controller
├── app.service.ts # Application service
├── app.module.ts # Root module
├── main.ts # Application entry point
├── common/ # Common utilities
│ ├── database/ # Database configuration
│ │ ├── database.module.ts
│ │ └── prisma.service.ts
│ ├── redis/ # Redis configuration
│ │ ├── redis.module.ts
│ │ └── redis.service.ts
│ └── logger/ # Logging configuration
│ ├── logger.module.ts
│ └── logger.service.ts
├── config/ # Configuration files
│ ├── logger.config.ts
│ └── database.config.ts
├── modules/ # Business modules (to be implemented)
└── queues/ # Queue management
├── queue.module.ts
└── queue.service.ts
- Node.js (v18+)
- Docker & Docker Compose
- PostgreSQL (if not using Docker)
- Redis (if not using Docker)
-
Clone the repository
git clone <repository-url> cd ai-web3-security-platform
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Start infrastructure services
# Start PostgreSQL and Redis docker-compose up -d # Optional: Start with admin tools docker-compose --profile tools up -d
-
Setup database
# Generate Prisma client npm run prisma:generate # Run database migrations npm run prisma:migrate # (Optional) Seed database npm run prisma:seed
-
Start the application
# Development mode npm run start:dev # Production mode npm run build npm run start:prod
npm run start- Start the applicationnpm run start:dev- Start in development mode with hot reloadnpm run start:debug- Start in debug modenpm run start:prod- Start in production modenpm run build- Build the applicationnpm run test- Run unit testsnpm run test:cov- Run tests with coveragenpm run lint- Run ESLintnpm run format- Format code with Prettiernpm run prisma:generate- Generate Prisma clientnpm run prisma:migrate- Run database migrationsnpm run prisma:studio- Open Prisma Studionpm run prisma:seed- Seed the database
Once the application is running, visit:
- API Docs: http://localhost:3000/api/docs
- Health Check: http://localhost:3000/health
- PgAdmin: http://localhost:8080 (admin@example.com / admin)
- Prisma Studio:
npm run prisma:studio
- Redis Commander: http://localhost:8081
Key environment variables (see .env.example for complete list):
# Application
NODE_ENV=development
PORT=3000
# Database
DATABASE_URL=postgresql://postgres:password@localhost:5432/ai_web3_security
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
# Security
JWT_SECRET=your-super-secret-jwt-key
# Web3 Configuration
ETHEREUM_RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID
# AI Services
OPENAI_API_KEY=your-openai-api-keyThe application follows a modular architecture where each feature is organized into its own module:
- Common: Shared utilities and configurations
- Config: Environment-based configuration
- Queues: Background job processing with BullMQ
- Modules: Business logic modules (to be implemented)
Uses PostgreSQL with Prisma ORM for type-safe database operations. The schema is defined in prisma/schema.prisma and includes:
- Users management
- Audit logging
- Security scan results
- Alert system
- Security rules
- Network configurations
Redis is used for:
- Session storage
- API response caching
- Real-time data
- Queue backend for BullMQ
BullMQ handles:
- Smart contract analysis jobs
- Security scanning tasks
- Notification processing
- Data synchronization
Winston provides structured logging with:
- Console output (development)
- File output (production)
- Different log levels
- Context-aware logging
- Performance and security logging
# Build production image
docker build -t ai-web3-security-platform .
# Run with Docker Compose
docker-compose -f docker-compose.prod.yml up -d- Set production environment variables
- Configure secure database connections
- Set up Redis with persistence
- Configure logging and monitoring
- Set up reverse proxy (nginx)
- Configure SSL certificates
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run linting and tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions, please open an issue in the repository.
