This project is a complete solution for generating, validating, and managing serial keys (software licenses), composed of a RESTful API, a Discord bot, and a command-line interface (CLI). The entire system is orchestrated with Docker and Docker Compose for easy and fast deployment.
- Centralized API (Node.js/Express): A robust backend written in TypeScript that handles all business logic.
- Persistent Database: Uses MongoDB to securely store key information.
- Flexible Key Generation:
- Create lifetime keys.
- Create keys with a specific duration (expiration in days).
- Advanced Validation:
- Checks if a key is valid, expired, or inactive.
- Supports binding keys to a Hardware ID (
HWID).
- Multiple User Interfaces:
- Discord Bot (Python): Manage keys directly from Discord with simple commands.
- CLI (Python): An interactive terminal tool for developers.
- Easy Deployment: Fully containerized with Docker and orchestrated with Docker Compose.
- Database Management: Includes Mongo Express for easy data visualization and management.
- Backend (API): Node.js, Express, TypeScript, Mongoose
- Database: MongoDB
- Bot & CLI: Python,
discord.py,requests - Orchestration: Docker, Docker Compose
.
├── API/ # Source code for the RESTful API (Node.js)
├── CLI/ # Source code for the Command-Line Interface (Python)
├── DISCORD_BOT/ # Source code for the Discord Bot (Python)
├── .env # Configuration file (DO NOT commit to git)
├── docker-compose.yml # Orchestrates all services
└── README.md # This file
Follow these steps to get the entire system up and running.
- Docker
- Docker Compose (usually included with Docker Desktop)
First, clone the repository. Then, create a .env file in the project root by copying the content below. This file is crucial for configuring all services.
#---------------------------------------
# API Serial Keys
# Internal port for the API container
APP_PORT_INTERNAL=3000
# Port you will expose on your host machine to access the API
HOST_PORT_API=6700
# MongoDB connection URI (the name 'mongodb' is the service name in docker-compose)
MONGO_URI=mongodb://mongodb:27017/serialkeys
#---------------------------------------
# Discord Bot
# Your Discord bot token
DISCORD_BOT_TOKEN=YOUR_DISCORD_BOT_TOKEN_HERE
# Base URL for the bot to communicate with the API (the name 'app' is the service name in docker-compose)
API_BASE_URL=http://app:3000/api/serialkeys
# Prefix for the bot commands
DISCORD_BOT_PREFIX=+
# Activity the bot will display on Discord
DISCORD_BOT_ACTIVITY=Generating Serial Keys
#---------------------------------------
# Mongo Express (Web interface for the database)
# MongoDB service name
ME_CONFIG_MONGODB_SERVER=mongodb
ME_CONFIG_MONGODB_PORT=27017
# Credentials to access Mongo Express
ME_CONFIG_BASICAUTH_USERNAME=admin
ME_CONFIG_BASICAUTH_PASSWORD=pass
ME_CONFIG_MONGODB_ENABLE_ADMIN=trueImportant: Replace YOUR_DISCORD_BOT_TOKEN_HERE with your actual Discord bot token.
Open a terminal in the project root and run the following command. This will build the Docker images and start all containers in the background.
docker-compose up --build -d- API: Open your browser or an API client and navigate to
http://localhost:6700. You should see the message "Serial Key API is running!". - Mongo Express: Navigate to
http://localhost:8081and log in with the credentials from your.envfile (admin/pass). - Discord Bot: The bot should appear online in your Discord server.
- Logs: To view the logs for all services, use
docker-compose logs -f. For a specific service, usedocker-compose logs -f <service-name>(e.g.,app,discord-bot).
Invite your bot to a Discord server and use the following commands (with the prefix defined in your .env file):
-
Generate a lifetime key:
+genlifetime <ProductName> -
Generate a key with an expiration date:
+gencad <ProductName> <days>Example:+gencad MySoftware 30 -
Check a key:
+checkkey <SerialKey> [HWID]TheHWIDis optional. If provided on the first validation, the key will be bound to it.
To use the command-line interface, run the following command from your terminal in the project root. This command starts the cli-app container, runs the Python script, and automatically removes the container when you exit.
docker-compose run --rm cli-app python main.pyYou will be presented with an interactive prompt CLI>. The available commands are:
genlifetime <productName>gencad <productName> <days>check <serialKey> [hwid]helpexit
To stop all running containers, execute:
docker-compose downIf you also want to remove the database data (the Docker volume), use:
docker-compose down -v