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>
34 lines
1.5 KiB
Python
34 lines
1.5 KiB
Python
"""Resources MVP API endpoints. Job ID: MTAD-IMPL-2025-11-18-CL"""
|
|
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.orm import Session
|
|
from app.database import get_db
|
|
from app.models import Resource
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/")
|
|
async def list_resources(access_tier: str = "public", skip: int = 0, limit: int = 20, db: Session = Depends(get_db)):
|
|
"""List resources by access tier."""
|
|
resources = db.query(Resource).filter(Resource.access_tier == access_tier).offset(skip).limit(limit).all()
|
|
return {"items": resources}
|
|
|
|
@router.get("/{resource_id}")
|
|
async def get_resource(resource_id: str, db: Session = Depends(get_db)):
|
|
"""Get a specific resource."""
|
|
resource = db.query(Resource).filter(Resource.id == resource_id).first()
|
|
if not resource:
|
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Resource not found")
|
|
return resource
|
|
|
|
@router.get("/slug/{slug}")
|
|
async def get_resource_by_slug(slug: str, db: Session = Depends(get_db)):
|
|
"""Get resource by slug."""
|
|
resource = db.query(Resource).filter(Resource.slug == slug).first()
|
|
if not resource:
|
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Resource not found")
|
|
return resource
|
|
|
|
@router.post("/")
|
|
async def create_resource(title: str, slug: str, content: str, db: Session = Depends(get_db)):
|
|
"""Create resource (admin or authorized user)."""
|
|
return {"message": "Resource creation not yet implemented"}
|