The frontend has been fully integrated with the FastAPI backend, implementing complete CRUD operations for all features.
- Centralized API service with all backend endpoints
- Token management (get, set, remove)
- Error handling and request formatting
- Support for all CRUD operations
- Global authentication state management
- User session persistence
- Login, register, logout functions
- Automatic token refresh and validation
- Route protection for dashboard pages
- Automatic redirect to login if not authenticated
- Loading states during authentication check
-
Login (
src/components/login.js)- Integrated with backend API
- Error handling and loading states
- Token storage on successful login
-
Signup (
src/components/signup.js)- User registration with API
- Auto-login after registration
- Form validation
-
Dashboard (
src/components/dashboard.js)- Displays user information from API
- Logout functionality
- Navigation to settings
-
StatsGrid (
src/components/StatsGrid.js)- Fetches dashboard statistics from API
- Displays: completed lessons, day streak, overall progress, achievements
-
ModulesGrid (
src/components/ModulesGrid.js)- Loads module progress from API
- Displays practice module statistics
-
CourseGrid (
src/components/lessons/CourseGrid.js)- Fetches all courses from API
- Displays course information and stats
-
LessonList (
src/components/lessons/LessonList.js)- Loads lessons for courses
- Shows user progress status (completed, in-progress, locked)
- Integrates with progress API
-
PracticeGrid (
src/components/practice/PracticeGrid.js)- Loads practice modules from API
- Displays session counts and accuracy
-
ConversationModal (
src/components/practice/ConversationModal.js)- Saves practice sessions to API
- Tracks accuracy and duration
- Settings (
src/components/settings/Settings.js)- Loads user settings from API
- Updates profile information
- Changes password
- Updates notification preferences
- Deletes account
- Real-time settings sync
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/me- Get current user
GET /api/users/me- Get profilePUT /api/users/me- Update profileGET /api/users/me/settings- Get settingsPUT /api/users/me/settings- Update settingsPOST /api/users/me/change-password- Change passwordDELETE /api/users/me- Delete account
GET /api/courses- Get all coursesGET /api/courses/{id}- Get course by IDGET /api/courses/{id}/lessons- Get course lessons
GET /api/progress/dashboard- Dashboard statisticsGET /api/progress/lessons- Lesson progressPOST /api/progress/lessons- Update lesson progressGET /api/progress/practice- Practice sessionsPOST /api/progress/practice- Create practice sessionGET /api/progress/modules- Module progressGET /api/progress/achievements- User achievements
Create a .env file in the root directory:
REACT_APP_API_URL=http://localhost:8000- Create: User registration, practice sessions, progress updates
- Read: All data loaded from backend (courses, lessons, progress, settings)
- Update: Profile, settings, password, progress
- Delete: Account deletion
- JWT token-based authentication
- Protected routes
- Automatic token management
- Session persistence
- Dashboard stats update from backend
- Module progress tracking
- Practice session recording
- Settings synchronization
- API error messages displayed to users
- Loading states during API calls
- Graceful fallbacks for missing data
- Loading indicators
- Success/error messages
- Form validation
- Automatic redirects
-
Start Backend:
cd backend uvicorn main:app --reload --port 8000 -
Start Frontend:
npm start
-
Test Flow:
- Register a new user at
/signup - Login at
/login - View dashboard with real data
- Browse courses and lessons
- Practice and see sessions saved
- Update settings and see changes persist
- Register a new user at
To enhance the integration further:
- Add progress tracking for lessons (mark as completed)
- Implement real-time updates using WebSockets
- Add file upload for profile pictures
- Implement pagination for large data sets
- Add caching for frequently accessed data
- Implement offline support with service workers
- All API calls include authentication tokens automatically
- Error messages are user-friendly
- Loading states prevent duplicate requests
- Data is fetched on component mount
- Settings auto-save when toggles change