Management dashboard and API for Defenra distributed DDoS protection platform. Built with Next.js 16, MongoDB, and NextAuth.
- Agent Management - Register, configure, and monitor edge agents
- Domain Configuration - DNS records, GeoDNS routing, SSL certificates
- WAF Rules - Lua-based Web Application Firewall scripts
- Proxy Configuration - HTTP/HTTPS reverse proxy settings
- Statistics - Traffic metrics, attack logs, agent health
- User Management - Multi-user authentication and authorization
- Node.js 23+
- MongoDB 5.0+
Clone and install dependencies:
git clone https://github.com/Defenra/DefenraCore.git
cd DefenraCore
npm installConfigure environment variables:
cp .env.example .env.localEdit .env.local:
MONGODB_URI=mongodb://localhost:27017/defenra
NEXTAUTH_SECRET=your-random-secret-key-here
NEXTAUTH_URL=http://localhost:3000
Generate a random secret:
openssl rand -base64 32Development mode:
npm run devProduction build:
npm run build
npm startAccess the dashboard at http://localhost:3000
On first launch with an empty database:
- Navigate to http://localhost:3000
- You'll be redirected to
/setup - Create an admin account
- Log in with your credentials
src/
├── app/
│ ├── api/ # API routes
│ │ ├── agent/ # Agent polling, stats, connection
│ │ ├── domain/ # Domain CRUD operations
│ │ ├── proxy/ # Proxy configuration
│ │ ├── geodns/ # GeoDNS mapping
│ │ └── auth/ # NextAuth endpoints
│ ├── dashboard/ # Dashboard pages
│ │ ├── agents/ # Agent management
│ │ ├── domains/ # Domain management
│ │ ├── statistics/ # Traffic stats
│ │ └── profile/ # User profile
│ ├── login/ # Login page
│ └── setup/ # Initial setup page
├── components/ # React components
├── lib/
│ ├── auth.js # NextAuth configuration
│ ├── mongodb.js # MongoDB connection
│ └── ipInfo.js # GeoIP lookup (MaxMind)
├── models/ # Mongoose schemas
│ ├── User.js
│ ├── Agent.js
│ ├── Domain.js
│ └── Proxy.js
└── middleware.js # Route protection
Agents poll these endpoints every 60 seconds:
POST /api/agent/poll
POST /api/agent/stats
GET /api/agent/connect/:token
GET /api/agent/list
POST /api/agent/create
DELETE /api/agent/:id
GET /api/domain/list
POST /api/domain/create
PUT /api/domain/:id
DELETE /api/domain/:id
GET /api/statistics
GET /api/logs
See AGENT_API_INTEGRATION.md for detailed API documentation.
Local MongoDB:
MONGODB_URI=mongodb://localhost:27017/defenra
MongoDB Atlas:
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/defenra
Required environment variables:
NEXTAUTH_SECRET=<random-32-byte-string>
NEXTAUTH_URL=http://localhost:3000
In production, set NEXTAUTH_URL to your domain.
Download MaxMind GeoLite2-City database:
mkdir -p data
cd data
wget https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-City.mmdbThe database is used for agent geolocation and GeoDNS fallback calculations.
Format code:
npm run formatLint code:
npm run lintdocker build -t defenra-core .
docker run -d \
-p 3000:3000 \
-e MONGODB_URI=mongodb://host.docker.internal:27017/defenra \
-e NEXTAUTH_SECRET=your-secret \
-e NEXTAUTH_URL=https://your-domain.com \
defenra-core- Push to GitHub
- Import project in Vercel
- Set environment variables
- Deploy
npm run build
pm2 start npm --name defenra-core -- start- Framework: Next.js 16 (App Router)
- Auth: NextAuth 5 (beta)
- Database: MongoDB with Mongoose
- UI: Tailwind CSS 4, Radix UI, Lucide icons
- Code Quality: Biome (formatter + linter)
- Agent API Integration - API contract between Core and Agent
- Architecture - System architecture and data flows
MIT