A modern, responsive React-based frontend application built with React 18, Tailwind CSS, and Framer Motion. Features role-based dashboards, project management, real-time chat via Socket.IO, attendance tracking, daily progress updates, and comprehensive user management.
cd frontend-react
npm install
npm startApplication will be available at: http://localhost:3000
- Node.js: v16+ (v18+ recommended for React 18)
- npm: v7.0.0+
- Backend API: Externship Manager backend running on
http://localhost:5050
Create .env file in the frontend-react/ directory:
# API Configuration
REACT_APP_API_URL=http://localhost:5050/api
# App Configuration
REACT_APP_NAME=Externship Manager
REACT_APP_VERSION=1.0.0
# Development Settings
GENERATE_SOURCEMAP=true
SKIP_PREFLIGHT_CHECK=trueREACT_APP_API_URL: Backend API base URL (must start withREACT_APP_)REACT_APP_NAME: Application display nameREACT_APP_VERSION: Current version numberGENERATE_SOURCEMAP: Enable/disable source maps (falsefor production)SKIP_PREFLIGHT_CHECK: Skip React dependency conflict checks
npm install- react (^18.2.0): Core React library
- react-dom (^18.2.0): React DOM rendering
- react-router-dom (^6.20.0): Client-side routing
- axios (^1.6.0): HTTP client with interceptors
- socket.io-client (^4.8.1): Real-time messaging
- framer-motion (^10.16.0): Animations and gestures
- react-icons (^4.12.0): Icon library
- @heroicons/react (^2.0.18): Heroicons
- recharts (^2.10.0): Charts and data visualization
- tailwindcss (^3.3.0): Utility-first CSS framework
- autoprefixer (^10.4.16): CSS vendor prefixing
- postcss (^8.4.31): CSS processing
- react-scripts (5.0.1): Create React App tooling
npm start- Opens
http://localhost:3000automatically - Hot reload enabled
- Source maps for debugging
- React DevTools support
npm run build- Creates optimized build in
build/folder - Minified and compressed assets
- Ready for deployment
npm start: Start development servernpm run build: Build for productionnpm test: Run test suitenpm run lint: Lint codenpm run lint:fix: Auto-fix linting issues
frontend-react/
βββ public/
β βββ index.html # Main HTML template
β βββ manifest.json # PWA manifest
βββ src/
β βββ components/ # Reusable UI components
β β βββ ui/ # Base components (Button, Card, Input, Modal)
β β βββ forms/ # Form components
β β βββ modals/ # Modal dialogs (ProjectModal, UserModal)
β β βββ widgets/ # Dashboard widgets
β β βββ common/ # Common components
β βββ contexts/
β β βββ AuthContext.jsx # Authentication state management
β βββ pages/ # Main application pages
β β βββ Dashboard.jsx # Role-based dashboard
β β βββ Login.jsx # Authentication page
β β βββ Projects.jsx # Project management
β β βββ Attendance.jsx # Attendance tracking
β β βββ DailyUpdates.jsx # Progress updates
β β βββ Chat.jsx # Real-time messaging
β β βββ UserManagement.jsx # User admin (Admin only)
β βββ services/
β β βββ api.js # Axios instance with interceptors
β β βββ socketConfig.js # Socket.IO configuration
β βββ utils/ # Helper functions
β βββ App.jsx # Main app component with routing
β βββ index.jsx # Application entry point
β βββ index.css # Global styles + Tailwind imports
βββ tailwind.config.js # Tailwind configuration
βββ postcss.config.js # PostCSS configuration
βββ package.json # Dependencies and scripts
After running backend seed script, use these credentials:
| Role | Password | Access Level | |
|---|---|---|---|
| Admin | admin@example.com |
admin123 |
Full system access, user management |
| Project Manager | pm@example.com |
pm123456 |
Project creation, team management |
| Team Leader | tl@example.com |
tl123456 |
Team oversight, progress tracking |
| Intern | intern1@example.com |
intern123 |
Daily updates, attendance, projects |
- Login: User enters credentials on
/login - Token Storage: JWT tokens stored in localStorage:
token(access token)refreshToken(refresh token)userEmailanduserData(user info)
- Auto-Injection: Axios interceptor adds
Authorization: Bearer <token>to all requests - Auto-Refresh: On 401 error, automatically attempts
POST /auth/refresh - Session Management: Invalid tokens redirect to login page
- β JWT-based authentication with automatic refresh
- β Role-based UI rendering and route protection
- β Secure token storage with cleanup on logout
- β Client-side token expiration checking
- β Protected routes with navigation guards
Role-Specific Interface
- Intern: Submit updates, view attendance, access projects
- Team Leader: Team overview, update reviews, attendance stats
- Project Manager: Project stats, team management, analytics
- Admin: System overview, user stats, all reports
Features:
- Quick action buttons
- Real-time statistics
- Recent activity feed
- Refresh button for live data
Permissions:
- Admin: Full CRUD access to all projects
- Project Manager: Create/manage own projects
- Team Leader: View assigned projects
- Intern: View assigned projects only
Features:
- Create new projects with details
- Edit/delete projects (Admin/PM)
- Assign/unassign team members
- Archive/unarchive projects
- View project details and timelines
- Set weekly goals
API Calls:
GET /projects- List projectsPOST /projects- Create projectPUT /projects/:id- Update projectPUT /projects/:id/assign- Assign usersPUT /projects/:id/unassign- Remove usersPUT /projects/:id/archive- Toggle archive
Submit Update (/daily-updates/submit)
- Required fields:
workDone,planForTomorrow - Optional:
challenges,attachments,project - Auto-loads today's update if exists
- Supports file uploads via FormData
- Automatically marks attendance
View Updates
- Interns: Project-specific cards with quick submit
- TL/PM/Admin: Filtered list view with date/project/user filters
- Review capability for managers
- Export functionality
API Calls:
POST /updates- Submit/update today's updateGET /updates/my- Get user's updatesGET /updates/today- Check today's updateGET /updates/team- Team updates (TL+)PUT /updates/:id/review- Review update (TL+)
Views:
- Interns: Personal calendar view
- Team Leaders: Team attendance with project breakdowns
- Admins: System-wide reports
Features:
- Calendar visualization
- Attendance percentage
- Monthly/yearly statistics
- Manual attendance marking (TL+)
- Report generation (Admin)
API Calls:
GET /attendance/my- User's attendanceGET /attendance/user/:userId- Specific user (TL+)POST /attendance/mark- Manual marking (TL+)GET /attendance/stats- Project stats (PM+)GET /attendance/report- Global report (Admin)
Real-time Messaging (Socket.IO)
- Project-based chat rooms
- Message history persistence
- Typing indicators
- Online user count
- Real-time message delivery
- User role badges
Features:
- Left panel: Project list
- Right panel: Message feed
- Send text messages
- File attachments support
- Auto-scroll to latest message
- User presence tracking
API Calls:
GET /chat/:projectId/messages- Load history (up to 1000)POST /chat/:projectId/messages- Send message
Socket Events:
join-project- Join chat roomsend-message- Send messagenew-message- Receive messagetyping-start/typing-stop- Typing indicatorsuser-joined/user-left- Presence updates
Admin Only
- Create users with role assignment
- Edit user details
- Toggle active/inactive status
- Delete users (cannot delete self)
- Filter by role
API Calls:
GET /users- List all usersPOST /users- Create userPUT /users/:id- Update userDELETE /users/:id- Delete userGET /users/role/:role- Filter by role
- Framework: Tailwind CSS utility-first approach
- Typography: System font stack with proper hierarchy
- Spacing: Consistent Tailwind spacing scale
- Colors: Custom palette with role-based theming
- Animations: Framer Motion for smooth transitions
Located in src/components/ui/:
- Button: Multiple variants, sizes, loading states
- Card: Container with optional glass effect
- Input: Form inputs with validation and icons
- Modal: Overlay dialogs with animations
- Loading: Spinner and skeleton states
- Toast: Notification system
Base Setup:
const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:5050/api';
const api = axios.create({
baseURL: API_BASE_URL,
timeout: 10000,
headers: { 'Content-Type': 'application/json' }
});Request Interceptor:
- Automatically adds
Authorization: Bearer <token>header - Retrieves token from localStorage
Response Interceptor:
- Handles 401 errors with automatic token refresh
- Retries failed requests after refresh
- Redirects to login on refresh failure
All available in apiService object:
- Authentication:
login(),register(),refreshToken(),logout() - Users:
getAllUsers(),createUser(),updateUser(),deleteUser() - Projects:
getAllProjects(),createProject(),assignUserToProject() - Updates:
submitDailyUpdate(),getMyUpdates(),reviewUpdate() - Attendance:
getMyAttendance(),markAttendance(),getAttendanceStats() - Chat:
getProjectMessages(),sendMessage()
Connection:
const socket = io('http://localhost:5050', {
auth: { token: localStorage.getItem('token') }
});Event Handling:
- Join project room on chat page load
- Send messages via socket
- Receive messages in real-time
- Track typing indicators
- Monitor user presence
- User enters credentials on
/login - Frontend calls
POST /auth/login - Backend returns tokens and user data
- Tokens stored in localStorage
- User redirected to
/dashboard
- Navigate to
/daily-updates/submit - Fill required fields (workDone, planForTomorrow)
- Optionally select project and add attachments
- Click Submit β
POST /updates - Backend automatically marks attendance
- Success notification displayed
- Go to
/projectsβ Click "New Project" - Fill project details β
POST /projects - Open team assignment modal
- Select users and roles
- Submit β
PUT /projects/:id/assign - Users now see project in their list
- Navigate to
/daily-updates - Filter by team/project
- Click on update to open details
- Add review comment and rating
- Submit β
PUT /updates/:id/review
# Verify backend is running
curl http://localhost:5050/api/health
# Check REACT_APP_API_URL in .env
echo $REACT_APP_API_URL// Clear localStorage in browser console
localStorage.clear()
// Check token expiration
const token = localStorage.getItem('token');
console.log(JSON.parse(atob(token.split('.')[1])));# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear React cache
npm start -- --reset-cache# Verify Tailwind is processing
npm run build
# Check tailwind.config.js content paths
# Clear browser cache (Cmd/Ctrl + Shift + R)- Verify backend Socket.IO server is running
- Check CORS configuration in backend
- Ensure token is valid and not expired
- Check browser console for socket errors
# Create production build
npm run build
# Test build locally
npx serve -s buildCreate .env.production:
REACT_APP_API_URL=https://your-api-domain.com/api
REACT_APP_NAME=Externship Manager
REACT_APP_VERSION=1.0.0
GENERATE_SOURCEMAP=falseStatic Hosting (Recommended):
- Netlify: Drag-drop
build/folder or connect Git repo - Vercel: Connect Git repository for auto-deployment
- GitHub Pages: Use
gh-pagespackage
Web Servers:
- Nginx: Serve static files with SPA routing
- Apache: Configure
.htaccessfor React Router
server {
listen 80;
server_name yourdomain.com;
root /path/to/build;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}# Interactive watch mode
npm test
# Run once
npm test -- --watchAll=false
# With coverage
npm test -- --coverage