Skip to content

Domain Model

vgartg edited this page May 27, 2026 · 1 revision

Domain Model

Users and auth

User - central model. Key fields:

  • role enum: basic, moderator, admin
  • is_frozen + unfreeze_at - manual freeze with optional auto-expiry
  • email_confirmed - must be true before the user can do anything
  • provider + uid - OAuth fields; oauth_user? returns provider.present?
  • visibility, theme, link_username - profile settings

Session - one record per device, stores (user_id, ip, browser) + remember token.

Auth concerns in app/models/concerns/:

  • Rememberable - remember-me cookie logic
  • Confirmable - email confirmation token
  • Recoverable - password reset token

Jams

Jam - the main event model:

  • author_id - who created it
  • Schedule: start_date, deadline, end_date
  • Key methods: can_manage?, can_configure?, judge?, voting_open?, submission_open?

JamContributor - roles on a jam: host, admin, judge. Status: pending or accepted.

JamRatingSetting - per-jam voting config: jury_enabled, audience_enabled, locked.

JamCriterion - a voting axis for a jam:

  • kind enum: voted_on (star rating) or manually_ranked (one pick per user)
  • archived?, position for ordering

JamCriterionPick - a "1 vote for this game" record for manually_ranked criteria. One per user per criterion.

JamSubmission - links a user to a jam. game_id can be nil if a participant hasn't submitted a game yet.

JamNomination - a named award (title) with a winner_game_id.

Voting and ratings

Review - a single vote:

  • vote_type enum: audience (0) or jury (1)
  • Unique per (user, game, jam, criterion, vote_type)

Rating - cached average. Updated via after_save / after_destroy callbacks on Review through update_average_rating(game, jam_id).

Game#jam_rating(jam_id, vote_type:) and Game#overall_rating are the public interface for reading scores.

Games

Game - a published game:

  • author_id
  • status enum: 0 = under moderation, 1 = accepted, 2 = rejected
  • reason - moderation rejection reason

Games have many Tags (HABTM, max 10 per game).

Social

Friendship - a connection between two users. Statuses: pending, accepted. The model has two associations: friendships and inverse_friendships to cover both directions.

Notification - activity feed:

  • recipient_id, actor_id
  • action string - must match a key in config/locales/*/notifications.actions.*
  • notifiable polymorphic association

Moderation

Report - a content complaint:

  • reportable polymorphic
  • reason, comment, status
  • Creating a report sends a notification to every admin and moderator.

AdministrationTracking - audit log for admin/mod actions:

  • admin_id, structure_type, structure_id
  • changed_fields (JSON), action string

Stats

StatisticForDay - daily snapshot of is_online_today. Written by DailyActivityJob.

Relationships at a glance

User
 ├── has_many :sessions
 ├── has_many :games (as author)
 ├── has_many :jam_submissions
 ├── has_many :jams (through submissions)
 ├── has_many :jam_contributors
 ├── has_many :reviews
 ├── has_many :friendships + inverse_friendships
 └── has_many :notifications (as recipient)

Jam
 ├── belongs_to :author (User)
 ├── has_one :jam_rating_setting
 ├── has_many :jam_contributors
 ├── has_many :jam_criteria
 ├── has_many :jam_submissions
 └── has_many :jam_nominations

Game
 ├── belongs_to :author (User)
 ├── has_many :reviews
 ├── has_many :ratings
 └── has_and_belongs_to_many :tags

Clone this wiki locally