| .. | ||
| app | ||
| components | ||
| lib | ||
| .gitignore | ||
| Dockerfile | ||
| next-env.d.ts | ||
| next.config.js | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.js | ||
| README.md | ||
| tailwind.config.ts | ||
| tsconfig.json | ||
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
-
Install dependencies
npm install -
Set up environment variables
cp .env.example .env.local # Edit .env.local with your configuration -
Start development server
npm run dev -
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:
- User registers/logs in on
/auth/login - Backend returns
access_tokenandrefresh_token - Frontend stores tokens in secure storage
- API requests include
Authorization: Bearer {access_token} - 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:
import { apiClient } from '@/lib/api'
const blogPosts = await apiClient.get('/blog')
See lib/api.ts for client configuration.
🧪 Testing
Unit Tests (TODO):
npm run test
Build Check:
npm run build
Type Check:
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
npm run build
Start
npm start
Docker
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
- Ensure backend is running on
localhost:8000 - Check CORS configuration in backend
- Verify
NEXT_PUBLIC_API_BASE_URLenvironment variable
Build Errors
- Clear
.nextdirectory - Reinstall dependencies:
npm install - Check TypeScript errors:
npm run type-check
Port Conflicts
Change port in package.json:
npm run dev -- -p 3001
🤝 Contributing
- Follow OpenSpec lifecycle for feature changes
- Create feature branches:
claude/feature-name-date - Link commits to Job IDs
- Ensure accessibility compliance
- Add tests for new features
📝 Git Workflow
# 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)