revelation_bible/lib.rs
1// SPDX-FileCopyrightText: 2025-2026 Revelation Team
2//
3// SPDX-License-Identifier: MIT
4
5//! # revelation-bible
6//!
7//! A comprehensive, type-safe Bible domain library for Rust applications.
8//!
9//! This crate provides the foundational domain types and port traits for
10//! building Bible-related applications following hexagonal architecture
11//! principles. It separates domain logic from infrastructure, enabling flexible
12//! adapter implementations.
13//!
14//! ## Architecture
15//!
16//! ```text
17//! ┌─────────────────────────────────────────────────────────────┐
18//! │ Your Application │
19//! ├─────────────────────────────────────────────────────────────┤
20//! │ revelation-bible │
21//! │ ┌─────────────────────┐ ┌─────────────────────────────┐ │
22//! │ │ Domain Types │ │ Port Traits │ │
23//! │ │ ───────────────── │ │ ───────────────────────── │ │
24//! │ │ Book, Verse │ │ BibleRepository │ │
25//! │ │ CrossReference │◄───│ BibleSearch │ │
26//! │ │ SearchResult │ │ BibleCrossReference │ │
27//! │ │ DailyReading │ │ ReadingPlan │ │
28//! │ └─────────────────────┘ └─────────────────────────────┘ │
29//! └─────────────────────────────────────────────────────────────┘
30//! ```
31//!
32//! ## Features
33//!
34//! | Feature | Description | Dependencies |
35//! |---------|-------------|--------------|
36//! | `db` | SQLx type derives for PostgreSQL enum mapping | `sqlx` |
37//! | `api` | OpenAPI schema generation for REST APIs | `utoipa` |
38//! | `backend` | Repository port traits with error handling | `masterror` |
39//!
40//! ## Quick Start
41//!
42//! ```rust
43//! use revelation_bible::{Book, Testament, Verse, VerseRef};
44//!
45//! // Create a book reference
46//! let genesis = Book {
47//! id: 1,
48//! name: "Genesis".into(),
49//! name_ru: "Бытие".into(),
50//! abbreviation: "Gen".into(),
51//! testament: Testament::Old,
52//! chapters_count: 50
53//! };
54//!
55//! // Create verse references
56//! let single = VerseRef::single(43, 3, 16); // John 3:16
57//! let range = VerseRef::range(45, 5, 1, 5); // Romans 5:1-5
58//! ```
59//!
60//! ## Domain Types
61//!
62//! ### Core Bible Structure
63//!
64//! - [`Book`] - Bible book with metadata (1-66 canonical books)
65//! - [`Verse`] - Individual verse with text content
66//! - [`ChapterInfo`] - Chapter metadata with verse counts
67//! - [`Testament`] - Old/New Testament enum
68//!
69//! ### Navigation & Study
70//!
71//! - [`Pericope`] - Section headings for navigation
72//! - [`SearchResult`] - Full-text search results with highlighting
73//! - [`CrossReference`] - Links between related passages
74//! - [`CrossReferenceExpanded`] - Cross-reference with full verse text
75//! - [`VerseRef`] - Flexible verse/range reference
76//!
77//! ### Reading Plans
78//!
79//! - [`DailyReading`] - Daily reading assignment
80//! - [`VerseResponse`] - User reflection on readings
81//! - [`CreateVerseResponse`] - Request to create reflection
82//!
83//! ## Port Traits
84//!
85//! When the `backend` feature is enabled, the following traits are available:
86//!
87//! - [`ports::BibleRepository`] - CRUD operations for Bible data
88//! - [`ports::BibleSearch`] - Full-text and symphony search
89//! - [`ports::BibleCrossReference`] - Cross-reference lookups
90//! - [`ports::ReadingPlan`] - Daily reading plan management
91//!
92//! ## Example: Implementing a Repository
93//!
94//! ```rust,ignore
95//! use revelation_bible::ports::BibleRepository;
96//! use revelation_bible::{Book, Verse, Testament};
97//! use masterror::AppResult;
98//! use sqlx::PgPool;
99//!
100//! struct PostgresBibleRepository {
101//! pool: PgPool,
102//! }
103//!
104//! impl BibleRepository for PostgresBibleRepository {
105//! async fn get_books(&self) -> AppResult<Vec<Book>> {
106//! // Implementation using sqlx
107//! todo!()
108//! }
109//! // ... other methods
110//! }
111//! ```
112
113pub mod domain;
114
115#[cfg(feature = "backend")]
116pub mod ports;
117
118pub use domain::*;