docs: improved schema.md

This commit is contained in:
nostrdev-com 2025-03-19 15:07:17 +03:00
parent 9f1e9998e7
commit 98576aa6a4
2 changed files with 126 additions and 97 deletions

2
.gitignore vendored Normal file

@ -0,0 +1,2 @@
# Mac OS system files
.DS_Store

221
schema.md

@ -1,128 +1,155 @@
## Database Schema: ## Database Schema:
preferably using Cassandra: A distributed NoSQL database preferably using Cassandra: A distributed NoSQL database
1. **Events** (Nostr protocol's core data structure): 1. **Events** (Nostr protocol's core data structure):
* `id` (unique identifier)
* `pubkey` (public key of the event creator) - `id` (unique identifier)
* `created_at` (timestamp) - `pubkey` (public key of the event creator)
* `kind` (event type, e.g., review, article, comment) - `created_at` (timestamp)
* `tags` (array of keywords or hashtags) - `kind` (event type, e.g., review, article, comment)
* `content` (text content of the event) - `tags` (array of keywords or hashtags)
- `content` (text content of the event)
This duplicates the relay, so should only be relevant kinds (eg nominated Review kind) This duplicates the relay, so should only be relevant kinds (eg nominated Review kind)
2. **User Reviews**: 2. **User Reviews**:
* `event_id` (foreign key referencing the Events table)
* `product_id` (unique identifier for the product) - `event_id` (foreign key referencing the Events table)
* `rating` (numerical rating, e.g., 1-100) - `product_id` (unique identifier for the product)
* `review_text` (text content of the review) - `rating` (numerical rating, e.g., 1-100)
* `tasting_notes` (array of tasting notes, e.g., flavors, aromas) - `review_text` (text content of the review)
- `tasting_notes` (array of tasting notes, e.g., flavors, aromas)
3. **Wines**: 3. **Wines**:
* `product_id` (uuid)
* `wine_id` ( type/style/characteristic, EAN/UPC, sku) - `product_id` (uuid)
* `type` (white, amber, rose, red) - `wine_id` ( type/style/characteristic, EAN/UPC, sku)
* `style` (bubbles+fizz, table, dessert, fortified, vermouth) - `type` (white, amber, rose, red)
* `characteristic` (light aromatic, textural, fruit forward, structural & savoury, powerful) - `style` (bubbles+fizz, table, dessert, fortified, vermouth)
* `country` - `characteristic` (light aromatic, textural, fruit forward, structural & savoury, powerful)
* `region` (appellation, village, sub-region, vineyard) - `country`
* `name` (label) - `region` (appellation, village, sub-region, vineyard)
* `producer` - `name` (label)
* `varietal` (if more than one, listl as blend) - `producer`
* `vintage` (year, nv, mv) - `varietal` (if more than one, listl as 'blend')
* `alcohol` - `vintage` (year, nv, mv)
* `standard drinks` (Australia) - `alcohol`
* `viticulture` (biodynamic, organic, conventional) - `standard drinks` (Australia)
* `sulfites` (parts per million) - `viticulture` (biodynamic, organic, conventional)
* `filtration` - `sulfites` (parts per million)
* `vegan` - `filtration`
* `kosher` - `vegan`
* `closure` (cork, crown-seal, screwcap) - `kosher`
* `price` (NIP-89, NIP-99) - `closure` (cork, crown-seal, screwcap)
* `image` (optional image URL)cellar.social - `price` (NIP-89, NIP-99)
- `image` (optional image URL)cellar.social
- `description` (detailed description of the product)
- `url` (e.g. producer's website)
- `availability` (in stock, out of stock, discontinued)
4. **Sake**: 4. **Sake**:
* `product_id` (uuid)
* `sake_id` (designation, polish rate, starter, yeast, EAN/UPC, sku ) - `product_id` (uuid)
*` country - `sake_id` (designation, polish rate, starter, yeast, EAN/UPC, sku )
* `region` - `country`
* `name` (label) - `region`
* `producer` - `name` (label)
* `designation`(table, pure, blended, mirin: new/true/salt) - `producer`
*` polish rate` (%) - `designation` (table, pure, blended, mirin: new/true/salt)
*` starter` (koji) - `polish rate` (%)
*` yeast strain` - `starter` (koji)
*` alcohol` - `yeast strain`
* `standard drinks` (Australia) - `alcohol`
* `vintage` (year, nv, mv) - `standard drinks` (Australia)
* `price` (NIP-89, NIP-99) - `vintage` (year, nv, mv)
* `image` (optional image URL) - `price` (NIP-89, NIP-99)
- `image` (optional image URL)
- `description` (detailed description of the product)
- `url` (e.g. producer's website)
- `availability` (in stock, out of stock, discontinued)
5. **Spirits**: 5. **Spirits**:
* `product_id` (uuid)
* `spirit_id` (EAN/UPC, sku) - `product_id` (uuid)
*` country - `spirit_id` (EAN/UPC, sku)
* `region` - `country`
* `name` (label) - `region`
* `producer` - `name` (label)
* `type`(white, dark, liqueurs) - `producer`
*` variant`(vodka, rum, liqueur cream, etc) - `type`(white, dark, liqueurs)
*` flavouring/ingredients` - `variant`(vodka, rum, liqueur cream, etc)
*` alcohol` - `flavouring/ingredients`
* `standard drinks` (Australia) - `alcohol`
* `vintage` (year, VS/VSOP/XO, age statement) - `standard drinks` (Australia)
* `price` (NIP-89, NIP-99) - `vintage` (year, VS/VSOP/XO, age statement)
* `image` (optional image URL) - `price` (NIP-89, NIP-99)
- `image` (optional image URL)
- `description` (detailed description of the product)
- `url` (e.g. producer's website)
- `availability` (in stock, out of stock, discontinued)
6. **Coffee**: 6. **Coffee**:
* `coffee_id` (unique identifier)
*` country - `coffee_id` (unique identifier)
* `region` - `country`
* `origin` - `region`
* `variety` - `origin`
*` processing` (type: de-caff/honey/semi-dry/swiss water/sundried/washed) - `variety`
* `producer` (roaster) - `processing` (type: de-caff/honey/semi-dry/swiss water/sundried/washed)
* `roast` - `producer` (roaster)
* `price` (g/kg/ton, NIP-89, NIP-99)) - `roast`
* `image` (optional image URL)cellar.social - `price` (g/kg/ton, NIP-89, NIP-99)
- `image` (optional image URL)cellar.social
- `description` (detailed description of the product)
- `url` (e.g. producer's website)
- `availability` (in stock, out of stock, discontinued)
7. **Articles**: 7. **Articles**:
* `event_id` (foreign key referencing the Events table)
* `title` - `event_id` (foreign key referencing the Events table)
* `content` (text content of the article) - `title`
* `author` (public key of the author) - `content` (text content of the article)
* `tags` (array of keywords or hashtags) - `author` (public key of the author)
- `tags` (array of keywords or hashtags)
8. **Comments**: 8. **Comments**:
* `event_id` (foreign key referencing the Events table)
* `parent_event_id` (foreign key referencing the Events table)
* `content` (text content of the comment)
- `event_id` (foreign key referencing the Events table)
- `parent_event_id` (foreign key referencing the Events table)
- `content` (text content of the comment)
## Frontend Schema: ## Frontend Schema:
1. **Review Page**: 1. **Review Page**:
* Display details (name, producer, region, varietal, vintage)
* Display review text and rating
* Display tasting notes
* Allow users to create new reviews and comments
2. **Article Page**:
* Display article title and content
* Display author information (public key, profile picture)
* Allow users to create new comments
3. **Wine List Page**:
* Display a list of wines with basic information (name, producer, region)
* Allow users to filter by region, varietal, or vintage
* Allow users to create new wine reviews
4. **Tag Page**:
* Display a list of events (reviews, articles, comments) associated with a particular tag
* Allow users to create new events with the same tag
- Display details (name, producer, region, varietal, vintage)
- Display review text and rating
- Display tasting notes
- Allow users to create new reviews and comments
2. **Article Page**:
- Display article title and content
- Display author information (public key, profile picture)
- Allow users to create new comments
3. **Wine List Page**:
- Display a list of wines with basic information (name, producer, region)
- Allow users to filter by region, varietal, or vintage
- Allow users to create new wine reviews
4. **Tag Page**:
- Display a list of events (reviews, articles, comments) associated with a particular tag
- Allow users to create new events with the same tag
## Nostr Protocol Integration: ## Nostr Protocol Integration:
1. Use a Nostr client library to connect to the Nostr network and retrieve events. 1. Use a Nostr client library to connect to the Nostr network and retrieve events.
2. Use the `pubkey` field to authenticate users and authorize actions (e.g., creating new reviews 2. Use the `pubkey` field to authenticate users and authorize actions (e.g., creating new reviews
or comments). or comments).
3. Use the `created_at` field to display events in chronological order. 3. Use the `created_at` field to display events in chronological order.
4. Use the `kind` field to determine the type of event and render it accordingly (e.g., review, 4. Use the `kind` field to determine the type of event and render it accordingly (e.g., review,
article, comment).cellar.social article, comment).cellar.social