How harshsrivastava1323/ems works
Project Type and Purpose
• This is a single-page web application (SPA) named EMS (Employee Management System).
• Built entirely as a React + Vite front end that interfaces with a backend API (not included in this repo) for authentication and task management.
• Purpose: Provide Admins with user/task management capabilities, and Employees with task-viewing and completion features.
File Structure
• Top-level:
• package.json, vite.config.js, tailwind.config.js → build & styling configuration
• public/index.html → SPA shell
• src/
– main.jsx + index.css → React entry point and global styles
– App.jsx / App.css → root React component
– components/
· Auth/Login.jsx → user sign-in
· Dashboard/AdminDashboard.jsx, EmployeeDashboard.jsx → role-specific views
· TaskList/* → task CRUD and status components (NewTask, AcceptTask, CompleteTask, FailedTask, TaskList)
· others/* → shared UI elements (Header, AllTask, CreateTask, TaskListNumber)
– context/AuthProvider.jsx → Context API for auth state & token persistence
– utils/localStorage.jsx → helper to read/write auth tokens
README
• Confirms: React.js + Vite + Tailwind CSS + Context API are the key technologies.
• Mentions two primary user flows: Admin management and Employee task management.
Main Components
a. Browser / Client Layer
• Static assets served via Vite’s dev server or a CDN in production
• index.html bootstraps the React app
b. React Application Layer
• App Router / Conditional Rendering → routes users to Login, AdminDashboard, or EmployeeDashboard
• AuthProvider (Context) → centralizes user state and JWT token management
• UI Components: grouped into Auth, Dashboard, TaskList, and shared “others”
c. Persistence Layer (Client)
• localStorage via utils/localStorage.jsx for token storage
d. External Backend Services
• Authentication API (e.g., POST /login → returns JWT)
• Task Management API (GET /tasks, POST /tasks, PATCH /tasks/:id/status, etc.)
e. Styling & Build Tools
• Tailwind CSS → utility-first styling
• Vite → dev server, module bundling, HMR
Relationships & Data Flows
• User opens Browser → requests index.html → Vite serves the bundle
• React mounts App → AuthProvider reads token from localStorage
• If unauthenticated, user sees Login → on submit → AuthProvider calls Auth API → stores JWT in Context + localStorage
• Authenticated user → App routes to AdminDashboard or EmployeeDashboard based on Context role
• Dashboard components call Task APIs (list, create, accept, complete, fail) via fetch/axios → update UI state
• All API calls carry the JWT in an Authorization header managed by AuthProvider/utility
Architectural Patterns & Design Principles
• Component-based UI (React)
• Context API for cross-component state (authentication)
• Single Source of Truth: AuthProvider Context + localStorage
• Separation of Concerns:
• UI logic in components/
• Auth logic in context/
• Persistence logic in utils/