Project-Judy

Project Judy Architecture

Runtime Flow

main.py validates configuration, initializes storage, loads non-empty cogs, connects to Discord, synchronizes slash commands, and publishes the current version in Judy’s activity.

config.py is the source of truth for project paths, database locations, credentials, models, AI controls, feature limits, cooldowns, public URLs, colors, and version metadata.

Unified AI Core

ai_service.py owns all Gemini access.

The service provides:

Chat and ambient cogs no longer create their own Gemini clients.

For direct chat, the AI service also receives bounded server-scoped identity and relationship context from identity_service.py. Scores and internal tiers are context only and must not be exposed in normal conversation.

Identity and Relationships

identity_service.py stores profiles and relationship state in database/identity.db.

Each Discord server has an independent profile for a user. Direct interactions update:

Progression is deterministic, gradual, and clamped. It does not use a second AI request or allow one message to create a high-trust relationship.

Public-Server Setup

guild_service.py stores setup state in database/guilds.db.

cogs/utility.py provides:

Setup validates channel permissions, configures the chat channel, optionally enables ambient presence, updates live cog state, and persists the result.

Persistence

Runtime SQLite databases:

The memory manager stores recent channel conversations and server-scoped user facts in JSON. A one-server legacy installation automatically converts old unscoped user-memory keys during the first 2.0 startup.

Data Isolation and Deletion

Server-specific records include a Discord guild ID. User facts, profiles, and relationships are keyed by guild ID and user ID.

data_service.py removes configuration, chat settings, ambient settings, XP, warnings, user memory, identity state, and known channel conversations when:

Cog Responsibilities

Security Boundaries