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

  • WalletNumber
  • BankNumber
  • Bank CapacityNumber
  • Net WorthComputed

RPG Stats

  • Health100/100
  • RankName, Tier, Stars
  • CharacterAizen, Goku, etc.
  • AwakeningLevel & XP

Inventory Systems

  • ItemsArray of Objects
  • PropertiesReal Estate Data
  • PetsEvolution & Stats
  • Blox FruitsMastery & Type

Illegal Activities

  • DrugsWeed, Opioid, etc.
  • FarmingPlots & Seeds
  • PrinterCounterfeit Cash
  • BriefcasesStealing 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