A modern React/Next.js frontend for the LearnMate learning platform with authentication powered by a Fastify backend.
- 🔐 Authentication System: Login and registration with JWT tokens
- 🎨 Modern UI: Beautiful, responsive design with Tailwind CSS
- 📱 Mobile Friendly: Optimized for all device sizes
- 🔄 Real-time Updates: Toast notifications for user feedback
- 🛡️ Protected Routes: Automatic redirection for authenticated users
- Node.js 18+
- npm or yarn
- LearnMate Fastify backend running on
http://localhost:3000
-
Install Dependencies
npm install
-
Configure API URL (Optional)
Create a
.env.localfile in the frontend directory:# API Configuration NEXT_PUBLIC_API_URL=http://localhost:3000If you don't create this file, it will default to
http://localhost:3000. -
Start the Development Server
npm run dev
-
Open your browser
Navigate to
http://localhost:3001(or the port shown in your terminal)
This frontend is designed to work with the LearnMate Fastify backend. Make sure your backend is running and provides the following endpoints:
POST /register- User registrationPOST /login- User authenticationGET /profile- Get user profile (protected)
- Registration: Users can create new accounts with email, name, and password
- Login: Users authenticate with email and password
- Token Storage: JWT tokens are stored in localStorage
- Protected Routes: Authenticated users are redirected to
/dashboard - Logout: Users can logout and are redirected to login page
src/
├── app/ # Next.js app directory
│ ├── auth/ # Authentication pages
│ │ ├── login/ # Login page
│ │ └── register/ # Registration page
│ ├── dashboard/ # Dashboard page (protected)
│ └── layout.tsx # Root layout with providers
├── components/ # Reusable UI components
│ └── ui/ # Base UI components
├── contexts/ # React contexts
│ └── AuthContext.tsx # Authentication context
├── hooks/ # Custom hooks
│ └── use-toast.ts # Toast notification hook
└── lib/ # Utility libraries
└── api.ts # API service
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
| Variable | Description | Default |
|---|---|---|
NEXT_PUBLIC_API_URL |
Backend API URL | http://localhost:3000 |
If you encounter CORS errors, make sure your backend has CORS configured to allow requests from your frontend domain.
- Check that your backend is running on the correct port
- Verify the API endpoints are working correctly
- Check browser console for error messages
- Clear
.nextdirectory:rm -rf .next - Reinstall dependencies:
rm -rf node_modules && npm install
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is part of the LearnMate platform.