# MoreThanADiagnosis Web Platform Next.js 14 web frontend for the MoreThanADiagnosis community platform. **Job ID**: MTAD-IMPL-2025-11-18-CL ## ๐Ÿ— Technology Stack - **Framework**: Next.js 14+ (App Router) - **Language**: TypeScript - **Styling**: Tailwind CSS - **State Management**: Zustand - **API Client**: Axios + React Query - **Package Manager**: npm ## ๐Ÿ“ฆ Project Structure ``` web/ โ”œโ”€โ”€ app/ # Next.js App Router โ”‚ โ”œโ”€โ”€ layout.tsx # Root layout โ”‚ โ”œโ”€โ”€ page.tsx # Home page โ”‚ โ”œโ”€โ”€ auth/ # Authentication pages โ”‚ โ”‚ โ”œโ”€โ”€ login/ โ”‚ โ”‚ โ”œโ”€โ”€ signup/ โ”‚ โ”‚ โ””โ”€โ”€ reset-password/ โ”‚ โ”œโ”€โ”€ blog/ # Blog pages โ”‚ โ”œโ”€โ”€ forum/ # Forum pages โ”‚ โ”œโ”€โ”€ merch/ # Merch store pages โ”‚ โ”œโ”€โ”€ podcast/ # Podcast pages โ”‚ โ”œโ”€โ”€ profiles/ # User profiles โ”‚ โ”œโ”€โ”€ resources/ # Resources knowledge base โ”‚ โ”œโ”€โ”€ tribute/ # Tributes/memorials โ”‚ โ””โ”€โ”€ dashboard/ # User dashboard โ”œโ”€โ”€ components/ โ”‚ โ”œโ”€โ”€ common/ # Shared components โ”‚ โ”‚ โ”œโ”€โ”€ Header.tsx โ”‚ โ”‚ โ”œโ”€โ”€ Footer.tsx โ”‚ โ”‚ โ”œโ”€โ”€ Navigation.tsx โ”‚ โ”‚ โ””โ”€โ”€ Button.tsx โ”‚ โ”œโ”€โ”€ layouts/ # Layout components โ”‚ โ”‚ โ”œโ”€โ”€ MainLayout.tsx โ”‚ โ”‚ โ””โ”€โ”€ AuthLayout.tsx โ”‚ โ””โ”€โ”€ mvps/ # MVP-specific components โ”‚ โ”œโ”€โ”€ blog/ โ”‚ โ”œโ”€โ”€ forum/ โ”‚ โ”œโ”€โ”€ merch/ โ”‚ โ”œโ”€โ”€ podcast/ โ”‚ โ”œโ”€โ”€ profiles/ โ”‚ โ”œโ”€โ”€ resources/ โ”‚ โ””โ”€โ”€ tribute/ โ”œโ”€โ”€ lib/ โ”‚ โ”œโ”€โ”€ api.ts # API client configuration โ”‚ โ”œโ”€โ”€ auth.ts # Authentication utilities โ”‚ โ”œโ”€โ”€ hooks.ts # Custom React hooks โ”‚ โ”œโ”€โ”€ store.ts # Zustand store โ”‚ โ””โ”€โ”€ types.ts # TypeScript types โ”œโ”€โ”€ styles/ โ”‚ โ”œโ”€โ”€ globals.css # Global styles โ”‚ โ””โ”€โ”€ variables.css # CSS variables โ”œโ”€โ”€ public/ # Static files โ”œโ”€โ”€ package.json โ”œโ”€โ”€ next.config.js โ”œโ”€โ”€ tsconfig.json โ””โ”€โ”€ README.md (this file) ``` ## ๐Ÿš€ Quick Start ### Prerequisites - Node.js 18+ - npm 8+ ### Installation 1. **Install dependencies** ```bash npm install ``` 2. **Set up environment variables** ```bash cp .env.example .env.local # Edit .env.local with your configuration ``` 3. **Start development server** ```bash npm run dev ``` 4. **Open browser** ``` http://localhost:3000 ``` ## ๐Ÿ“ Environment Variables Create `.env.local`: ``` NEXT_PUBLIC_API_BASE_URL=http://localhost:8000/api/v1 NEXT_PUBLIC_APP_URL=http://localhost:3000 ``` ## ๐ŸŽจ Design System The web frontend integrates with the MoreThanADiagnosis Design System (`../../openspec/specs/design-system.md`). **Available Components**: - Button (variants: primary, secondary, ghost, danger) - Input (text, email, password, textarea) - Card - Modal/Dialog - Form helpers - Navigation components See Design System spec for complete documentation. ## ๐Ÿ” Authentication All protected routes require authentication via JWT tokens. **Authentication Flow**: 1. User registers/logs in on `/auth/login` 2. Backend returns `access_token` and `refresh_token` 3. Frontend stores tokens in secure storage 4. API requests include `Authorization: Bearer {access_token}` 5. Token refresh handled automatically See `lib/auth.ts` for implementation. ## ๐Ÿ“ฑ Features (MVPs) ### 1. Blog - List and search published posts - Read full articles - Filter by author/category - Responsive design ### 2. Forum - Browse categories and threads - Read discussions - View user profiles - Real-time updates (WebSocket) ### 3. Merch Store - Browse products - View details and pricing - Shopping cart management - Checkout flow ### 4. Podcast - Episode list with playback - Audio player - Episode notes and metadata - Subscribe/download ### 5. Profiles - View user profiles - Edit own profile - Display pseudonym/health journey - Privacy-conscious design ### 6. Resources - Browse knowledge base - Search by tags/topics - Filter by access tier - Related resources ### 7. Tribute - View memorials - Create tribute entries - Share memories - Respectful layout ## ๐Ÿ”„ API Integration The frontend communicates with the FastAPI backend at `/api/v1/`. **Example API Call**: ```typescript import { apiClient } from '@/lib/api' const blogPosts = await apiClient.get('/blog') ``` See `lib/api.ts` for client configuration. ## ๐Ÿงช Testing **Unit Tests** (TODO): ```bash npm run test ``` **Build Check**: ```bash npm run build ``` **Type Check**: ```bash npm run type-check ``` ## ๐Ÿ“Š Performance - Static generation for blog/resources - ISR (Incremental Static Regeneration) for frequently updated content - Image optimization with Next.js Image component - Code splitting per route - CSS-in-JS optimization ## ๐Ÿš€ Production Deployment ### Build ```bash npm run build ``` ### Start ```bash npm start ``` ### Docker ```bash docker build -t mtad-web . docker run -p 3000:3000 mtad-web ``` ## ๐Ÿ” Accessibility (WCAG 2.2 AA+) - Semantic HTML - ARIA labels and roles - Keyboard navigation - Screen reader support - Color contrast compliance - Focus management - Reduced motion support ## ๐Ÿ“š Documentation - **Design System**: `../../openspec/specs/design-system.md` - **API Spec**: `../../backend/README.md` - **Architecture**: `../../openspec/specs/architecture.md` ## ๐Ÿ›  Troubleshooting ### API Connection Issues 1. Ensure backend is running on `localhost:8000` 2. Check CORS configuration in backend 3. Verify `NEXT_PUBLIC_API_BASE_URL` environment variable ### Build Errors 1. Clear `.next` directory 2. Reinstall dependencies: `npm install` 3. Check TypeScript errors: `npm run type-check` ### Port Conflicts Change port in `package.json`: ```bash npm run dev -- -p 3001 ``` ## ๐Ÿค Contributing 1. Follow OpenSpec lifecycle for feature changes 2. Create feature branches: `claude/feature-name-date` 3. Link commits to Job IDs 4. Ensure accessibility compliance 5. Add tests for new features ## ๐Ÿ“ Git Workflow ```bash # Create feature branch git checkout -b claude/feature-name-2025-11-18 # Make changes, commit with Job ID git commit -m "feat: description (JOB MTAD-IMPL-2025-11-18-CL)" # Push and create PR git push origin claude/feature-name-2025-11-18 ``` ## Status - โœ… Project scaffolding complete - โณ Component development (in progress) - โณ Feature page implementation (pending) - โณ Integration testing (pending) - โณ Production deployment (pending) --- **Job ID**: MTAD-IMPL-2025-11-18-CL **Last Updated**: 2025-11-18 **Maintained By**: Claude (Frontend Agent)