SGuard is a comprehensive Discord security and moderation platform that includes an intelligent bot, a robust API, and a modern web interface.
This project is organized as a monorepo containing three main components:
sguard-project/
├── api/ # Backend server (Express.js + TypeScript)
├── bot/ # Discord Bot (DiscordX + TypeScript)
├── frontend/ # Web interface (React/Next.js + TypeScript)
└── shared/ # Shared code between projects
- Automatic moderation with intelligent content analysis
- Moderation commands for administrators
- Configurable sanctions system
- Keyword detection in multiple languages
- Sentiment and toxicity analysis
- RESTful API for configuration management
- OAuth2 authentication with Discord
- Guild and user management
- Per-server moderation configuration
- Action logging and auditing
- Intuitive admin dashboard
- Visual configuration of moderation parameters
- Real-time statistics and metrics
- User and permission management
- Responsive and modern interface
- TypeScript - Primary language
- Node.js - JavaScript runtime
- Discord.js - Library for Discord interaction
- DiscordX - Framework for Discord bots
- Express.js - Web framework for the API
- React/Next.js - Frontend framework
- PostgreSQL - Primary database
- Docker - Containerization
- Node.js >= 18.0.0
- npm >= 8.0.0
- Git
-
Clone the repository:
git clone https://github.com/danielvflores/SGuard.git cd sguard-project -
Install dependencies:
npm install
-
Configure environment variables:
# Copy example files cp api/.env.example api/.env cp bot/.env.example bot/.env cp frontend/.env.example frontend/.env.local -
Configure variables according to your environment
# Install all dependencies
npm run install:all
# Build all projects
npm run build
# Development mode (all services)
npm run dev
# Production mode (all services)
npm run start
# Clean generated files
npm run clean
# Run tests
npm run test
# Linting
npm run lint# API
npm run dev:api
npm run build:api
npm run start:api
# Bot
npm run dev:bot
npm run build:bot
npm run start:bot
# Frontend
npm run dev:frontend
npm run build:frontend
npm run start:frontend- Create an application in Discord Developer Portal
- Create a bot and get the token
- Configure necessary permissions and scopes
- Add the token to the
bot/.envfile
- Set up PostgreSQL
- Create the necessary databases
- Run migrations
- Configure connection in
api/.env
- Configure OAuth2 in Discord Developer Portal
- Add callback URLs
- Configure credentials in
api/.env
sguard-project/
├── api/
│ ├── src/
│ │ ├── controllers/ # API controllers
│ │ ├── middlewares/ # Express middlewares
│ │ ├── routes/ # Route definitions
│ │ └── app/ # Application configuration
│ ├── package.json
│ └── tsconfig.json
├── bot/
│ ├── src/
│ │ ├── commands/ # Discord commands
│ │ ├── events/ # Event listeners
│ │ ├── utils/ # Utilities and helpers
│ │ └── bot.ts # Bot entry point
│ ├── package.json
│ └── tsconfig.json
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Application pages
│ │ ├── hooks/ # Custom hooks
│ │ └── utils/ # Frontend utilities
│ ├── package.json
│ └── tsconfig.json
├── shared/
│ ├── types/ # Shared TypeScript types
│ ├── constants/ # Global constants
│ └── utils/ # Shared utilities
├── package.json # Monorepo configuration
├── tsconfig.json # Base TypeScript configuration
└── README.md
PORT=3000
DATABASE_URL=postgresql://...
DISCORD_CLIENT_ID=...
DISCORD_CLIENT_SECRET=...
JWT_SECRET=...DISCORD_TOKEN=...
DISCORD_CLIENT_ID=...
API_BASE_URL=http://localhost:3000NEXT_PUBLIC_API_URL=http://localhost:3000
NEXT_PUBLIC_DISCORD_CLIENT_ID=...# Run all tests
npm test
# Tests per project
npm run test:api
npm run test:bot
npm run test:frontend
# Tests in watch mode
npm run test:watch- Fork the project
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Create a Pull Request
This project is licensed under the ISC License. See the LICENSE file for more details.
- Daniel Flores - Initial development - @danielvflores
- Discord.js and DiscordX for the excellent libraries
- The TypeScript community
- All project contributors
If you have any questions or need help:
- 📧 Email: your-email@example.com
- 🐛 Issues: GitHub Issues
- 💬 Discord: Support Server
⭐ Don't forget to give the project a star if you found it useful!