obsidian/wiki/tech-patterns/nextjs-fastapi-fullstack.md
2026-04-15 10:48:47 +01:00

3.2 KiB

title aliases tags sources created updated
Next.js + FastAPI Fullstack
nextjs-fastapi
nextjs-stack
nextjs
fastapi
python
typescript
fullstack
01 Projects/enterprise-ai-hub-nexus
01 Projects/sandbox-notebookllamalm-nextjs
01 Projects/Oliver-ai-bot_2.0
01 Projects/ppt-tool
2026-04-15 2026-04-15

Next.js + FastAPI Fullstack

Used for the most complex Oliver AI platforms. Next.js App Router handles SSR + auth; FastAPI handles AI workloads + data.

Key Takeaways

  • Next.js 14/15 App Router is the choice for production Oliver AI platforms
  • Paired with FastAPI backend (Python AI workloads, DB operations)
  • Azure AD PKCE auth lives in Next.js layer
  • Docker Compose orchestrates all services
  • Qdrant for vector search (RAG projects), Redis for caching/queuing

When to Use

  • Complex, multi-user AI platforms needing SSR, SEO, or M365 integration
  • When the frontend state is complex enough to warrant Next.js routing
  • Production deployments with multi-service architectures

Key Details

  • Next.js versions: 14 (Enterprise Nexus), 15 App Router (Sandbox NotebookLM)
  • Package manager: npm (standard), uv for Python backend (Sandbox)
  • Auth: Azure AD PKCE in Next.js; backend validates tokens
  • API pattern: src/lib/api.ts (axios wrapper) → FastAPI backend
  • State: Zustand (auth store in Sandbox NotebookLM)
  • Real-time: WebSocket chat routes in FastAPI (Sandbox NotebookLM)

Projects Using This Pattern

Architecture Pattern

Browser → Azure AD PKCE (auth)
    ↓
Next.js (SSR + App Router)
    src/lib/api.ts → FastAPI backend
                       ├── AI service (Claude/Gemini/LlamaIndex)
                       ├── PostgreSQL (data)
                       ├── Redis (cache/queue)
                       └── Celery workers (async jobs)

Gotchas & Lessons

  • Next.js 15 App Router + React 19 is cutting edge — expect breaking changes in dependencies
  • python-pptx must be pinned to 0.6.23 for stable PPTX generation (Sandbox NotebookLM)
  • max_tokens defaults are too low for document generation — increase to 16000+ for long outputs
  • nginx reverse proxy needed when Next.js + FastAPI must share a single public port (DeckForge pattern)
  • Celery beat for scheduled tasks (SharePoint sync in Enterprise Nexus) needs careful token refresh logic