fix error and update readme
This commit is contained in:
42
README.md
42
README.md
@@ -145,7 +145,7 @@ Association table tracking which brands are available in which shops:
|
|||||||
- `created_at`: DateTime, Creation timestamp (auto-generated)
|
- `created_at`: DateTime, Creation timestamp (auto-generated)
|
||||||
- `updated_at`: DateTime, Last update timestamp (auto-updated)
|
- `updated_at`: DateTime, Last update timestamp (auto-updated)
|
||||||
|
|
||||||
### Association Table
|
### Association Tables
|
||||||
|
|
||||||
#### Shopping Event Products (`shopping_event_products` table)
|
#### Shopping Event Products (`shopping_event_products` table)
|
||||||
Many-to-many relationship between shopping events and products with additional data:
|
Many-to-many relationship between shopping events and products with additional data:
|
||||||
@@ -155,6 +155,15 @@ Many-to-many relationship between shopping events and products with additional d
|
|||||||
- `amount`: Float, Quantity purchased in this event (required, > 0)
|
- `amount`: Float, Quantity purchased in this event (required, > 0)
|
||||||
- `price`: Float, Price at time of purchase (required, ≥ 0)
|
- `price`: Float, Price at time of purchase (required, ≥ 0)
|
||||||
|
|
||||||
|
#### Related Products (`related_products` table)
|
||||||
|
Many-to-many self-referential relationship between products for tracking related items:
|
||||||
|
- `id`: Integer, Primary key, Auto-increment
|
||||||
|
- `product_id`: Integer, Foreign key to products (required)
|
||||||
|
- `related_product_id`: Integer, Foreign key to products (required)
|
||||||
|
- `relationship_type`: String, Type of relationship (optional)
|
||||||
|
- Examples: "size_variant", "brand_variant", "similar", "alternative"
|
||||||
|
- `created_at`: DateTime, Creation timestamp (auto-generated)
|
||||||
|
|
||||||
### Relationships
|
### Relationships
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -172,6 +181,19 @@ Many-to-many relationship between shopping events and products with additional d
|
|||||||
│ │ • updated_at │
|
│ │ • updated_at │
|
||||||
│ └─────────────────┘
|
│ └─────────────────┘
|
||||||
│ │
|
│ │
|
||||||
|
│ │ N:M (self-referential)
|
||||||
|
│ ▼
|
||||||
|
│ ┌─────────────────────────────┐
|
||||||
|
│ │ Related Products │
|
||||||
|
│ │ (Association Table) │
|
||||||
|
│ │ │
|
||||||
|
│ │ • id │
|
||||||
|
│ │ • product_id │
|
||||||
|
│ │ • related_product_id │
|
||||||
|
│ │ • relationship_type │
|
||||||
|
│ │ • created_at │
|
||||||
|
│ └─────────────────────────────┘
|
||||||
|
│ │
|
||||||
│ │ N:M
|
│ │ N:M
|
||||||
│ ▼
|
│ ▼
|
||||||
│ ┌─────────────────────────────┐
|
│ ┌─────────────────────────────┐
|
||||||
@@ -217,6 +239,7 @@ Many-to-many relationship between shopping events and products with additional d
|
|||||||
|
|
||||||
- **Direct Product-Category Relationship**: Products are directly linked to categories for simplified organization
|
- **Direct Product-Category Relationship**: Products are directly linked to categories for simplified organization
|
||||||
- **Brand Tracking**: Optional brand association for products with shop availability tracking
|
- **Brand Tracking**: Optional brand association for products with shop availability tracking
|
||||||
|
- **Related Products**: Track relationships between products (size variants, brand alternatives, similar items)
|
||||||
- **Price History**: Each product purchase stores the price at that time, enabling price tracking
|
- **Price History**: Each product purchase stores the price at that time, enabling price tracking
|
||||||
- **Flexible Quantities**: Support for decimal amounts (e.g., 1.5 kg of apples)
|
- **Flexible Quantities**: Support for decimal amounts (e.g., 1.5 kg of apples)
|
||||||
- **Auto-calculation**: Total amount can be automatically calculated from individual items
|
- **Auto-calculation**: Total amount can be automatically calculated from individual items
|
||||||
@@ -334,6 +357,14 @@ Many-to-many relationship between shopping events and products with additional d
|
|||||||
- `GET /brands-in-shops/brand/{brand_id}` - Get shops that carry specific brand
|
- `GET /brands-in-shops/brand/{brand_id}` - Get shops that carry specific brand
|
||||||
- `DELETE /brands-in-shops/{id}` - Delete brand-shop association
|
- `DELETE /brands-in-shops/{id}` - Delete brand-shop association
|
||||||
|
|
||||||
|
### Related Products
|
||||||
|
- `GET /related-products/` - List all product relationships
|
||||||
|
- `POST /related-products/` - Create new product relationship
|
||||||
|
- `GET /related-products/{id}` - Get specific product relationship
|
||||||
|
- `GET /related-products/product/{product_id}` - Get all products related to a specific product
|
||||||
|
- `PUT /related-products/{id}` - Update relationship type
|
||||||
|
- `DELETE /related-products/{id}` - Delete product relationship
|
||||||
|
|
||||||
### Shopping Events
|
### Shopping Events
|
||||||
- `GET /shopping-events/` - List all shopping events
|
- `GET /shopping-events/` - List all shopping events
|
||||||
- `POST /shopping-events/` - Create new shopping event
|
- `POST /shopping-events/` - Create new shopping event
|
||||||
@@ -352,10 +383,11 @@ Many-to-many relationship between shopping events and products with additional d
|
|||||||
3. **Add Brands**: Create brands for your products (optional)
|
3. **Add Brands**: Create brands for your products (optional)
|
||||||
4. **Configure Shop-Brand Availability**: Associate brands with shops where they're available
|
4. **Configure Shop-Brand Availability**: Associate brands with shops where they're available
|
||||||
5. **Add Products**: Create product items linked directly to categories and optionally to brands
|
5. **Add Products**: Create product items linked directly to categories and optionally to brands
|
||||||
6. **Record Purchases**: Use the "Add Shopping Event" form to record purchases with multiple products
|
6. **Link Related Products**: Connect products that are related (e.g., same item in different sizes, brand alternatives)
|
||||||
7. **Track Prices**: Monitor how prices change over time for the same products
|
7. **Record Purchases**: Use the "Add Shopping Event" form to record purchases with multiple products
|
||||||
8. **Import/Export Data**: Use CSV files to bulk import or export your data
|
8. **Track Prices**: Monitor how prices change over time for the same products
|
||||||
9. **View Statistics**: Analyze spending patterns by category and shop
|
9. **Import/Export Data**: Use CSV files to bulk import or export your data
|
||||||
|
10. **View Statistics**: Analyze spending patterns by category and shop
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ class ShopStats(BaseModel):
|
|||||||
|
|
||||||
# Update forward references
|
# Update forward references
|
||||||
BrandInShop.model_rebuild()
|
BrandInShop.model_rebuild()
|
||||||
ProductWithRelated.model_rebuild()
|
|
||||||
|
|
||||||
# Related Products schemas
|
# Related Products schemas
|
||||||
class RelatedProductBase(BaseModel):
|
class RelatedProductBase(BaseModel):
|
||||||
@@ -200,3 +199,6 @@ class ProductWithRelated(Product):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
from_attributes = True
|
from_attributes = True
|
||||||
|
|
||||||
|
# Update forward references for classes that reference other classes
|
||||||
|
ProductWithRelated.model_rebuild()
|
||||||
Reference in New Issue
Block a user