# System Settings Database Design

---

**Document Version:** 1.0
**Project:** Student Bazaar
**Document Type:** System Settings Database Schema
**Status:** Approved
**Last Updated:** 28 June 2026
**Author:** Nemmi Tangha

---

# 1. Overview

The System Settings module stores configurable platform settings used throughout Student Bazaar.

Rather than hardcoding values into the application, configuration values are stored in the database, allowing the Super Admin to modify platform behavior without changing the source code.

The module consists of one table:

1. system_settings

---

# 2. Table: system_settings

## Purpose

Stores configurable platform settings as key-value pairs.

These settings control application behavior, business rules, and feature configuration.

---

## Columns

| Column        | Data Type                                           | Nullable | Default           | Key    | Description                                                        |
| ------------- | --------------------------------------------------- | -------- | ----------------- | ------ | ------------------------------------------------------------------ |
| id            | BIGINT                                              | No       | AUTO_INCREMENT    | PK     | Internal primary key                                               |
| public_id     | CHAR(36)                                            | No       | UUID              | UNIQUE | Public identifier                                                  |
| setting_key   | VARCHAR(100)                                        | No       | —                 | UNIQUE | Configuration key                                                  |
| setting_value | TEXT                                                | No       | —                 | —      | Configuration value                                                |
| data_type     | ENUM('string','integer','boolean','decimal','json') | No       | string            | —      | Data type of the setting                                           |
| description   | VARCHAR(255)                                        | Yes      | NULL              | —      | Description of the setting                                         |
| is_editable   | BOOLEAN                                             | No       | TRUE              | INDEX  | Indicates whether the setting can be modified from the admin panel |
| updated_by    | BIGINT                                              | Yes      | NULL              | FK     | References users.id (Super Admin)                                  |
| created_at    | DATETIME                                            | No       | CURRENT_TIMESTAMP | INDEX  | Record creation timestamp                                          |
| updated_at    | DATETIME                                            | No       | CURRENT_TIMESTAMP | —      | Last update timestamp                                              |

---

## Relationships

* One Super Admin → Many Updated Settings

---

## Indexes

* PRIMARY KEY (`id`)
* UNIQUE (`public_id`)
* UNIQUE (`setting_key`)
* INDEX (`is_editable`)
* INDEX (`created_at`)

---

## Business Rules

* Every setting key must be unique.
* Only Super Admins may modify settings.
* Non-editable settings cannot be changed through the admin interface.
* Settings should be loaded efficiently during application startup.
* Changes to settings should be logged in the `admin_logs` table.

---

# 3. Example Settings

The following are examples of settings that may be stored in the table:

| Setting Key              | Example Value | Description                                        |
| ------------------------ | ------------- | -------------------------------------------------- |
| application_version      | 1.0.0         | Current application version                        |
| registration_enabled     | true          | Enable or disable new user registration            |
| marketplace_enabled      | true          | Enable or disable the marketplace                  |
| chat_message_limit       | 10            | Free messages per conversation                     |
| rewarded_ad_messages     | 5             | Messages unlocked after one rewarded advertisement |
| maximum_listing_images   | 7             | Maximum images per listing                         |
| listing_expiration_days  | 30            | Number of days before listings expire              |
| account_lockout_attempts | 5             | Maximum failed login attempts                      |
| account_lockout_minutes  | 15            | Lockout duration                                   |
| maintenance_mode         | false         | Enable maintenance mode                            |

---

# 4. Module Integration

The System Settings module integrates with:

## Authentication

* Login attempt limits
* Account lockout settings
* Registration availability

---

## Marketplace

* Listing expiration
* Maximum listing images
* Marketplace availability

---

## Chat

* Free message limits
* Rewarded advertisement message unlocks

---

## Administration

* Maintenance mode
* Application version
* Platform configuration

---

# 5. Security Rules

The System Settings module enforces:

* Only Super Admins may update settings.
* Every setting modification should be recorded in `admin_logs`.
* Invalid configuration values must be rejected.
* SQLAlchemy ORM must be used for all database operations.
* Input validation is required before saving changes.

---

# 6. Summary

The System Settings module provides a centralized configuration system for Student Bazaar.

The design supports:

* Configurable business rules
* Platform-wide settings
* Administrative control
* Future scalability
* Reduced hardcoded values

The module follows the approved Student Bazaar database standards and serves as the central configuration repository for the application.
