forked from
smokesignal.events/smokesignal
i18n+filtering fork - fluent-templates v2
1//! # Storage Module
2//!
3//! Database operations and data models using PostgreSQL with SQLx for type-safe queries.
4//!
5//! This module provides a comprehensive data layer for the smokesignal application, handling all
6//! database interactions, caching, and data modeling. It uses SQLx for compile-time verified SQL
7//! queries and PostgreSQL for reliable, ACID-compliant data storage.
8//!
9//! ## Architecture
10//!
11//! The storage layer is organized around several key data domains:
12//!
13//! ### Core Data Models
14//! - **[`event`]** - Event creation, modification, and querying
15//! - **[`handle`]** - User handle management and DID resolution
16//! - **[`oauth`]** - OAuth session and token management
17//! - **[`cache`]** - Redis-based caching for performance optimization
18//!
19//! ### Support Systems
20//! - **[`denylist`]** - Content moderation and spam prevention
21//! - **[`types`]** - Common data types and structures
22//! - **[`errors`]** - Storage-specific error handling
23//!
24//! ## Features
25//!
26//! ### Type-Safe Queries
27//! All database queries are verified at compile time using SQLx:
28//! - Compile-time SQL validation
29//! - Automatic Rust type mapping
30//! - Protection against SQL injection
31//! - Schema migration support
32//!
33//! ### Performance Optimization
34//! - Redis caching for frequently accessed data
35//! - Connection pooling for database efficiency
36//! - Prepared statement reuse
37//! - Efficient pagination for large datasets
38//!
39//! ### Data Integrity
40//! - ACID transactions for complex operations
41//! - Foreign key constraints
42//! - Data validation at the storage layer
43//! - Consistent error handling
44//!
45//! ## Database Schema
46//!
47//! The application uses PostgreSQL with the following main tables:
48//! - `events` - Event data and metadata
49//! - `rsvps` - User responses to events
50//! - `handles` - User identity and DID mapping
51//! - `oauth_sessions` - Authentication session data
52//! - `denylist` - Moderation and filtering data
53//!
54//! ## Example Usage
55//!
56//! ```rust,no_run
57//! use smokesignal::storage::event::EventStorage;
58//! use sqlx::PgPool;
59//!
60//! async fn create_event_example(pool: &PgPool) -> anyhow::Result<()> {
61//! let event_storage = EventStorage::new(pool);
62//!
63//! // Create a new event
64//! let event = event_storage.create_event(
65//! "Community Meetup",
66//! "A friendly local gathering",
67//! "organizer.did",
68//! ).await?;
69//!
70//! println!("Created event: {}", event.name);
71//! Ok(())
72//! }
73//! ```
74
75pub mod cache;
76pub mod denylist;
77pub mod errors;
78pub mod event;
79pub mod handle;
80pub mod oauth;
81pub mod types;
82
83pub use types::*;