Implements complete FastAPI backend infrastructure for MoreThanADiagnosis with:
Core Infrastructure:
- FastAPI application with CORS, error handling, health checks
- SQLAlchemy ORM with PostgreSQL support
- Pydantic configuration management
- Docker & Docker Compose for production deployment
Database Models (7 MVPs + Auth):
- User, Profile, Role, Consent (identity)
- RefreshToken, AuthAuditLog (authentication)
- ForumCategory, ForumThread, ForumPost, ForumReaction, ForumReport (forum)
- BlogPost (blog)
- PodcastEpisode (podcast)
- Resource (resources)
- TributeEntry (tribute)
- MerchProduct, Order, OrderItem (merch)
API Endpoints (Alphabetical MVPs):
- /api/v1/blog - Blog posts (list, get)
- /api/v1/forum - Categories, threads, posts, reactions, reports
- /api/v1/merch - Products, orders
- /api/v1/podcast - Episodes
- /api/v1/profiles - User profiles
- /api/v1/resources - Knowledge base
- /api/v1/tribute - Memorials
- /api/v1/health - Health checks
Configuration & Deployment:
- .env.example for configuration
- Dockerfile with multi-stage build
- docker-compose.yml for PostgreSQL + Redis + API
- Production-ready on nexus-vector with port 8000
- Non-root user, health checks, security best practices
Dependencies:
- FastAPI, SQLAlchemy, Pydantic
- PostgreSQL, Redis
- Testing (pytest), Security (passlib, python-jose)
- Full requirements.txt with 30+ packages
Status: Foundation complete, MVP endpoint stubs ready
Next: Database migrations, authentication implementation
Job ID: MTAD-IMPL-2025-11-18-CL
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
"""
|
|
Merch MVP models - MerchProduct and Order for commerce.
|
|
|
|
Job ID: MTAD-IMPL-2025-11-18-CL
|
|
"""
|
|
|
|
from sqlalchemy import Column, String, Text, Integer, Float, DateTime, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.database import Base
|
|
|
|
|
|
class MerchProduct(Base):
|
|
"""Merch Product - Store products."""
|
|
|
|
__tablename__ = "merch_products"
|
|
|
|
id = Column(String(36), primary_key=True, index=True)
|
|
name = Column(String(255), nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
price = Column(Float, nullable=False)
|
|
stock_count = Column(Integer, default=0)
|
|
image_url = Column(String(500), nullable=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
|
|
|
# Relationships
|
|
order_items = relationship("OrderItem", back_populates="product", cascade="all, delete-orphan")
|
|
|
|
|
|
class Order(Base):
|
|
"""Order - Purchase orders."""
|
|
|
|
__tablename__ = "orders"
|
|
|
|
id = Column(String(36), primary_key=True, index=True)
|
|
user_id = Column(String(36), ForeignKey("users.id"), index=True, nullable=False)
|
|
total = Column(Float, nullable=False)
|
|
status = Column(String(50), default="pending", index=True) # pending, completed, cancelled
|
|
shipping_address = Column(String(500), nullable=True) # PII - Encrypted
|
|
created_at = Column(DateTime, server_default=func.now(), index=True)
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="orders")
|
|
items = relationship("OrderItem", back_populates="order", cascade="all, delete-orphan")
|
|
|
|
|
|
class OrderItem(Base):
|
|
"""Order Item - Individual items in an order."""
|
|
|
|
__tablename__ = "order_items"
|
|
|
|
id = Column(String(36), primary_key=True, index=True)
|
|
order_id = Column(String(36), ForeignKey("orders.id"), index=True, nullable=False)
|
|
product_id = Column(String(36), ForeignKey("merch_products.id"), index=True, nullable=False)
|
|
quantity = Column(Integer, default=1)
|
|
price = Column(Float, nullable=False)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
|
|
# Relationships
|
|
order = relationship("Order", back_populates="items")
|
|
product = relationship("MerchProduct", back_populates="order_items")
|