




- post_id (UUID, primary key)
- user_id (foreign key to users)
- post_type (text, image, video, book_share, poll)
- content (text, max 5000 chars)
- media_urls (JSON array)
- visibility (public, followers, private, unlisted)
- hashtags (array)
- mentioned_users (array of user_ids)
- book_id (foreign key, nullable)
- created_at, updated_at
- deleted_at (soft delete)- interaction_id (UUID)
- post_id (foreign key)
- user_id (foreign key)
- interaction_type (like, comment, repost, bookmark, report)
- comment_text (nullable)
- parent_comment_id (for nested replies)
- created_at- follower_id (foreign key to users)
- following_id (foreign key to users)
- created_at
- muted (boolean)
- notifications_enabled (boolean)code blocks)





- conversation_id (UUID, primary key)
- conversation_type (direct, group, broadcast)
- created_at, updated_at
- last_message_at (for sorting)
- group_name (nullable, for groups)
- group_description (nullable)
- group_photo_url (nullable)- participant_id (UUID)
- conversation_id (foreign key)
- user_id (foreign key)
- role (member, admin, owner)
- joined_at
- left_at (nullable)
- muted (boolean)
- archived (boolean)
- last_read_message_id (for unread count)- message_id (UUID, primary key)
- conversation_id (foreign key)
- sender_id (foreign key to users)
- message_type (text, image, file, voice, book_share, system)
- content (text, nullable)
- media_urls (JSON array, nullable)
- reply_to_message_id (nullable, for threaded replies)
- created_at, updated_at
- edited_at (nullable)
- deleted_at (soft delete)
- deleted_for_everyone (boolean)- receipt_id (UUID)
- message_id (foreign key)
- user_id (foreign key)
- status (delivered, read)
- timestamp- reaction_id (UUID)
- message_id (foreign key)
- user_id (foreign key)
- emoji (text)
- created_at










- bookmark_id (UUID, primary key)
- user_id (foreign key)
- book_id (foreign key)
- chapter_id (foreign key, nullable)
- bookmark_type (highlight, page, chapter, quote_card)
- content (text of highlighted passage)
- start_position, end_position (character offsets)
- color (yellow, blue, pink, green, nullable)
- note (user annotation, nullable)
- visibility (public, followers, private)
- created_at, updated_at- collection_id (UUID, primary key)
- user_id (foreign key)
- name (text)
- description (text, nullable)
- visibility (public, private)
- created_at, updated_at- item_id (UUID)
- collection_id (foreign key)
- bookmark_id (foreign key)
- position (integer, for ordering)
- added_at- list_id (UUID, primary key)
- creator_id (foreign key to users)
- title (text)
- description (text, nullable)
- cover_image_url (text, nullable)
- visibility (public, unlisted, private, collaborative)
- list_type (curated, challenge, book_club, recommendation)
- created_at, updated_at- item_id (UUID)
- list_id (foreign key)
- book_id (foreign key)
- position (integer, for ordering)
- added_by_user_id (foreign key, for collaborative lists)
- notes (text, nullable)
- added_at- follower_id (UUID)
- list_id (foreign key)
- user_id (foreign key)
- followed_at
- notifications_enabled (boolean)- interaction_id (UUID)
- bookmark_id (foreign key)
- user_id (foreign key)
- interaction_type (like, save, comment, report)
- comment_text (nullable)
- created_at



CREATE TABLE security_events (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(id),
username TEXT NOT NULL, -- denormalized for audit
device_id TEXT NOT NULL,
os_type TEXT NOT NULL CHECK (os_type IN ('android', 'ios', 'web')),
book_id UUID NOT NULL REFERENCES books(id),
chapter_id UUID REFERENCES chapters(id),
page_index INTEGER NOT NULL,
event_type TEXT NOT NULL CHECK (event_type IN
('screenshot', 'screen_record', 'drm_violation')),
capture_result TEXT CHECK (capture_result IN
('blocked', 'blank', 'successful')),
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(),
ip_address INET,
user_agent TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Indexes for query performance
CREATE INDEX idx_security_events_user_id ON security_events(user_id);
CREATE INDEX idx_security_events_timestamp ON security_events(timestamp DESC);
CREATE INDEX idx_security_events_book_id ON security_events(book_id);
CREATE INDEX idx_security_events_event_type ON security_events(event_type);
-- RLS policies (insert-only for application role)
ALTER TABLE security_events ENABLE ROW LEVEL SECURITY;
CREATE POLICY security_events_insert ON security_events
FOR INSERT WITH CHECK (auth.role() = 'service_role');
CREATE POLICY security_events_select ON security_events
FOR SELECT USING (auth.role() IN ('admin', 'super_admin'));
Section 7: Content Protection and Security Monitoring7.1 Screenshot and Recording Restrictions: You explicitly agree that all content accessed through StoriesHut applications and services is protected by technical security measures including but not limited to screenshot prevention, screen recording detection, and watermarking technologies. You acknowledge that attempting to capture, record, or circumvent these protection mechanisms violates this Agreement and applicable intellectual property laws.7.2 Security Event Monitoring: You consent to comprehensive monitoring of your device interactions with StoriesHut applications for security and fraud prevention purposes. This monitoring includes but is not limited to: detection of screenshot attempts regardless of success, screen recording detection, reading pattern analysis, device fingerprinting, and behavioral anomaly detection. All security events generate immutable logs accessible to StoriesHut security personnel and potentially shared with law enforcement or rights holders.7.3 Blank Screenshot Treatment: You acknowledge that screenshot attempts resulting in blank captured images due to security protection mechanisms constitute violations of this Agreement identical to successful content captures. The attempt itself, rather than success, triggers violation recording and consequence enforcement.7.4 Consequences and Enforcement: Security violations trigger graduated enforcement responses including but not limited to: risk score increases, reading session invalidation for royalty purposes, temporary account suspension, permanent account termination, legal action for intellectual property theft, and referral to law enforcement. You acknowledge these consequences and agree that suspension or termination for security violations does not entitle you to subscription refunds.








There was an error generating this image














































- friendship_id (UUID, primary key)
- user_id_1 (foreign key to users)
- user_id_2 (foreign key to users)
- status (pending, accepted, declined, blocked)
- requested_by (user_id_1 or user_id_2)
- requested_at (timestamp)
- accepted_at (timestamp, nullable)
- created_at, updated_at- request_id (UUID, primary key)
- sender_id (foreign key to users)
- receiver_id (foreign key to users)
- status (pending, accepted, declined, cancelled)
- message (optional text, nullable)
- created_at, updated_at- suggestion_id (UUID, primary key)
- user_id (foreign key to users)
- suggested_user_id (foreign key to users)
- reason (mutual_friends, similar_interests, location, contacts)
- score (relevance score, float)
- dismissed (boolean)
- created_at- close_friend_id (UUID)
- user_id (foreign key)
- friend_id (foreign key)
- added_at (timestamp)