Database Architecture
The Celestia bot uses MongoDB as its primary data store, managed via the Mongoose ODM. This ensures scalable, schema-based document storage for everything from user economy profiles to server-specific configurations.
Connection Handler
The database connection is established in database.js. It connects using the MONGODB_URI environment variable.
async function connectDB() {
await mongoose.connect(process.env.MONGODB_URI, {
dbName: 'discord_bot',
serverSelectionTimeoutMS: 5000,
});
}Economy Model
The Economy.js model is the most complex schema, storing all user progress, inventory, and RPG stats.
Core Finance
- Wallet
Number - Bank
Number - Bank Capacity
Number - Net Worth
Computed
RPG Stats
- Health
100/100 - Rank
Name, Tier, Stars - Character
Aizen, Goku, etc. - Awakening
Level & XP
Inventory Systems
- Items
Array of Objects - Properties
Real Estate Data - Pets
Evolution & Stats - Blox Fruits
Mastery & Type
Illegal Activities
- Drugs
Weed, Opioid, etc. - Farming
Plots & Seeds - Printer
Counterfeit Cash - Briefcases
Stealing Logic
Server Configuration
Guild-specific settings are stored in serverconfig.js. This handles the "Setme" module configuration.
Field
Description
guildId
Unique Discord Server ID (Primary Key)
roles
Object storing IDs for mute, jail, etc.
channels
Object storing IDs for jail, staffChat, etc.
setupBy
ID of the admin who configured the bot
Other Collections
Antinuke
Security settings & whitelists
Level
Global XP and leveling data
Warning
User moderation history
Giveaway
Active giveaway tracking
Alias
Custom command aliases
Starboard
Message highlighting config