ParentCircle Frontend
Next.js 15 frontend application for ParentCircle - Vietnam's first smart parenting community platform powered by AI.
Tech Stack
- Framework: Next.js 15 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- UI Components: Lucide React (icons)
- Charts: Recharts
- HTTP Client: Axios
- State Management: React Context API
- Authentication: JWT tokens
- PWA Support: Workbox (planned)
- Social Sharing: React Share
Features Implemented
Core Features
- Authentication System: Login/Register with JWT authentication
- Communities: Forum discussions with real-time interactions
- AI Chat Assistant: ParentChat AI for 24/7 parenting advice
- Family Scheduler: Smart calendar and task management
- Marketplace: Buy/sell used baby items with location-based search
- Dashboard: Analytics and engagement tracking
Components
- Navigation: Bottom navigation with responsive design
- Protected Routes: Authentication guards for private pages
- Error Boundary: Graceful error handling
- Loading States: Loading spinners and skeletons
Project Structure
frontend/
├── app/
│ ├── auth/
│ │ ├── login/ # Login page
│ │ └── register/ # Registration page
│ ├── communities/ # Community forums
│ │ └── [id]/ # Community detail page
│ ├── chat/ # AI Chat interface
│ ├── scheduler/ # Family calendar & tasks
│ ├── marketplace/ # Marketplace listings
│ │ └── [id]/ # Item detail page
│ ├── dashboard/ # Analytics dashboard
│ ├── components/ # Shared components
│ │ ├── Navigation.tsx
│ │ ├── ProtectedRoute.tsx
│ │ ├── ErrorBoundary.tsx
│ │ └── LoadingSpinner.tsx
│ └── lib/
│ ├── auth-context.tsx # Authentication context
│ ├── providers.tsx # App providers
│ └── types.ts # TypeScript types
├── public/ # Static assets
├── tailwind.config.ts # Tailwind configuration
├── next.config.ts # Next.js configuration
└── package.json
Getting Started
Prerequisites
- Node.js 18 or higher
- npm or yarn
- Backend API running on
http://localhost:3003
Installation
Install dependencies:
npm install --legacy-peer-depsConfigure environment variables:
# Create .env.local file NEXT_PUBLIC_API_URL=http://localhost:3003/api/v1Start development server:
npm run dev
The application will be available at http://localhost:3002
Build for Production
npm run build
npm start
Available Scripts
npm run dev- Start development server on port 3002npm run build- Build for productionnpm start- Start production servernpm run lint- Run ESLint
API Integration
The frontend communicates with the Rails backend via REST API:
Authentication
POST /api/v1/users- Register new userPOST /api/v1/users/sign_in- LoginDELETE /api/v1/users/sign_out- Logout
Communities
GET /api/v1/communities- List communitiesPOST /api/v1/communities/:id/join- Join communityGET /api/v1/communities/:id/posts- Get community postsPOST /api/v1/posts- Create post
AI Chat
POST /api/v1/chat/query- Send chat message
Family Scheduler
GET /api/v1/family_events- Get eventsPOST /api/v1/family_events- Create eventGET /api/v1/tasks- Get tasksPOST /api/v1/tasks- Create task
Marketplace
GET /api/v1/marketplace_items- List itemsPOST /api/v1/marketplace_items- Create listingGET /api/v1/marketplace_items/:id- Get item details
Dashboard
GET /api/v1/dashboard/engagement- Get engagement dataGET /api/v1/dashboard/stats- Get statistics
Authentication Flow
- User registers or logs in via
/auth/loginor/auth/register - Backend returns JWT token and user data
- Token stored in localStorage
- Token sent in Authorization header for protected routes
- Protected routes check authentication via
ProtectedRoutecomponent
Key Technologies
Next.js 15 Features
- App Router: File-based routing with React Server Components
- TypeScript: Type-safe development
- Image Optimization: Next.js Image component
- Code Splitting: Automatic route-based splitting
Tailwind CSS
- Utility-first CSS framework
- Responsive design utilities
- Custom color palette for family-friendly UI
- Component-based styling
State Management
- React Context API for global state
AuthContextfor authentication state- Local state with React hooks
Development Guidelines
Component Structure
// Use TypeScript for all components
import { FC } from 'react';
interface ComponentProps {
// Define props
}
const Component: FC<ComponentProps> = ({ props }) => {
// Component logic
return (
<div className="tailwind-classes">
{/* JSX */}
</div>
);
};
export default Component;
API Calls
import axios from 'axios';
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3003/api/v1';
const api = axios.create({
baseURL: API_URL,
headers: {
'Content-Type': 'application/json',
},
});
// Add auth token to requests
api.interceptors.request.use((config) => {
const token = localStorage.getItem('token');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
Error Handling
- Use ErrorBoundary for component errors
- Display user-friendly error messages
- Log errors for debugging
Styling Guidelines
Color Palette
- Primary: Indigo/Purple tones (#4F46E5)
- Secondary: Warm pastels
- Success: Green
- Warning: Yellow
- Error: Red
- Neutral: Gray scale
Responsive Design
- Mobile-first approach
- Breakpoints: sm (640px), md (768px), lg (1024px), xl (1280px)
- Bottom navigation for mobile
- Side navigation for desktop
Performance Optimization
- Code Splitting: Automatic with Next.js App Router
- Image Optimization: Use Next.js Image component
- Lazy Loading: Dynamic imports for heavy components
- Caching: Browser caching for static assets
- API Optimization: Debounce search queries
Future Enhancements
In Progress
- Mobile optimization and responsive refinements
- PWA implementation with service workers
- Offline mode with cached content
Planned
- Push notifications
- Advanced AI features
- Social sharing improvements
- Performance monitoring
Testing
# Unit tests (coming soon)
npm run test
# E2E tests (coming soon)
npm run test:e2e
Troubleshooting
Common Issues
Issue: npm install fails
- Solution: Use
npm install --legacy-peer-deps
Issue: API calls fail with CORS error
- Solution: Ensure backend CORS is configured to allow
http://localhost:3002
Issue: Authentication token expires
- Solution: Tokens expire after 24 hours. User must log in again.
Issue: Build fails with TypeScript errors
- Solution: Run
npm run lintto see all errors and fix them
Environment Variables
# .env.local
NEXT_PUBLIC_API_URL=http://localhost:3003/api/v1
NEXT_PUBLIC_APP_NAME=ParentCircle
Deployment
Vercel (Recommended)
- Connect GitHub repository to Vercel
- Set environment variables in Vercel dashboard
- Deploy automatically on push to main branch
Docker
# Build image
docker build -t parentcircle-frontend .
# Run container
docker run -p 3002:3002 parentcircle-frontend
Contributing
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
License
MIT License - See LICENSE file for details
Contact
- Project Repository: GitHub
- Issues: GitHub Issues
Built with ❤️ for Vietnamese parents

Log in or sign up for Devpost to join the conversation.