feat: add books APIs

This commit is contained in:
gosangam
2026-05-09 23:19:19 +05:30
commit b055b8ba0c
43 changed files with 4307 additions and 0 deletions
+116
View File
@@ -0,0 +1,116 @@
package model
import "time"
// Book represents a book's metadata from MongoDB.
type Book struct {
ID string `json:"id"`
Book string `json:"book"`
Data map[string]interface{} `json:"data"`
}
// Verse represents a single verse from MongoDB.
type Verse struct {
ID string `json:"id"`
Book string `json:"book"`
Division *string `json:"division,omitempty"`
Chapter int `json:"chapter"`
Verse int `json:"verse"`
VerseEnd *int `json:"verse_end,omitempty"`
Reference string `json:"reference"`
BookTitle string `json:"book_title"`
Devanagari string `json:"devanagari"`
Bengali *string `json:"bengali,omitempty"`
Transliteration string `json:"transliteration"`
Synonyms []Synonym `json:"synonyms"`
Translation string `json:"translation"`
Purport []string `json:"purport"`
}
// Synonym represents a word-meaning pair in verse synonyms.
type Synonym struct {
Word string `json:"word"`
Meanings []string `json:"meanings"`
}
// Letter represents a letter from MongoDB.
type Letter struct {
ID string `json:"id"`
Slug string `json:"slug"`
Recipients []string `json:"recipients"`
RecipientDisplay string `json:"recipient_display"`
Date *string `json:"date,omitempty"`
DateRef *string `json:"date_ref,omitempty"`
Year *int `json:"year,omitempty"`
Month *int `json:"month,omitempty"`
Day *int `json:"day,omitempty"`
Location *string `json:"location,omitempty"`
Salutation *string `json:"salutation,omitempty"`
Paragraphs []string `json:"paragraphs"`
}
// Essay represents an essay from MongoDB.
type Essay struct {
ID string `json:"id"`
Slug string `json:"slug"`
Title string `json:"title"`
Author string `json:"author"`
Year *int `json:"year,omitempty"`
Group *string `json:"group,omitempty"`
Order int `json:"order"`
Paragraphs []string `json:"paragraphs"`
}
// GlossaryEntry represents a glossary term from MongoDB.
type GlossaryEntry struct {
ID string `json:"id"`
Term string `json:"term"`
Definition string `json:"definition"`
DefinitionHTML string `json:"definition_html"`
}
// Disciple represents a disciple from MongoDB.
type Disciple struct {
ID string `json:"id"`
InitiatedName string `json:"initiated_name"`
Suffix string `json:"suffix"`
InitiationDate *time.Time `json:"initiation_date,omitempty"`
InitiationPlace *string `json:"initiation_place,omitempty"`
KarmiName *string `json:"karmi_name,omitempty"`
Avatar *string `json:"avatar,omitempty"`
About *string `json:"about,omitempty"`
Tags []string `json:"tags"`
IsVerified bool `json:"is_verified"`
}
// Transcription represents a lecture/conversation from MongoDB.
type Transcription struct {
ID string `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Type string `json:"type"` // "lecture" | "conversation"
Date *string `json:"date,omitempty"`
Year *int `json:"year,omitempty"`
Month *int `json:"month,omitempty"`
Day *int `json:"day,omitempty"`
Place *string `json:"place,omitempty"`
Context *string `json:"context,omitempty"`
Reference *string `json:"reference,omitempty"`
Summary *string `json:"summary,omitempty"`
Content []ContentBlock `json:"content"`
Tags []string `json:"tags"`
Participants []string `json:"participants"`
Language string `json:"language"`
Source *string `json:"source,omitempty"`
DurationMinutes *int `json:"duration_minutes,omitempty"`
AudioUrl *string `json:"audio_url,omitempty"`
IsPublished bool `json:"is_published"`
}
// ContentBlock represents a rich text block within a transcription.
type ContentBlock struct {
Text string `json:"text"`
Format string `json:"format"` // "paragraph" | "heading" | "quote" | "verse" | "note"
Alignment string `json:"alignment"` // "left" | "center" | "right"
Speaker *string `json:"speaker,omitempty"`
}
+60
View File
@@ -0,0 +1,60 @@
package model
import "time"
// User represents a user in PostgreSQL.
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
Avatar *string `json:"avatar,omitempty"`
Role string `json:"role"` // "user" | "admin" | "moderator"
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Bookmark represents a user's bookmarked content.
type Bookmark struct {
ID string `json:"id"`
UserID string `json:"user_id"`
ContentType string `json:"content_type"` // "verse" | "letter" | "essay" | "transcription" | etc.
ContentID string `json:"content_id"`
ContentRef string `json:"content_ref"` // human-readable reference (e.g., "BG 1.1")
SelectedText *string `json:"selected_text,omitempty"`
Note *string `json:"note,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// Collection represents a user-created collection.
type Collection struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
IsPublic bool `json:"is_public"`
ItemCount int `json:"item_count"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Mention represents a mention of content shared by a user.
type Mention struct {
ID string `json:"id"`
UserID string `json:"user_id"`
ContentType string `json:"content_type"`
ContentID string `json:"content_id"`
ContentRef string `json:"content_ref"`
Text string `json:"text"`
CreatedAt time.Time `json:"created_at"`
}
// ShortURL represents a shortened URL.
type ShortURL struct {
ID string `json:"id"`
Slug string `json:"slug"`
TargetURL string `json:"target_url"`
CreatedBy *string `json:"created_by,omitempty"`
ClickCount int64 `json:"click_count"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}