A React + TypeScript application that visualizes a company's organizational structure. Users can log in, view a hierarchical org chart (CEO → Managers → Employees), search and focus on employees, and toggle light/dark themes. UI combines MUI components with TailwindCSS layout utilities.
-
Install dependencies
npm install
-
Start the development server
npm start
- App runs at
http://localhost:3000 - Public mock APIs are served from
public/data/*
- App runs at
Use any of the following credentials on the login page:
- admin / admin123
- johndoe / password123
- janedoe / password123
-
Authentication (mock)
- Login/logout with dummy users (
public/data/users.json) - Session persists via
localStorage - Protected routes block access until authenticated
- Login/logout with dummy users (
-
Employee Hierarchy Chart
- Loads employees from
public/data/employees.json - Builds a tree (CEO → Managers → Employees)
- Expand/collapse via MUI X TreeView
- Employee nodes rendered as memoized MUI Cards
- Loads employees from
-
Search and Focus
- Search by name with live feedback
- Auto-expands nodes during search
- Uses refs to scroll/focus to the first match
-
Theme Management
- Light/Dark theme toggle stored in global context
- Persists to
localStorage - Integrated with MUI theme + CssBaseline
-
Styling
- TailwindCSS for layout (containers, spacing, flex, responsiveness)
- MUI for components (AppBar, Card, TextField, Snackbar, Progress, TreeView)
-
React functional components + hooks
useState,useEffect:src/pages/Dashboard.tsx,src/pages/Login.tsx,src/components/EmployeeHierarchy.tsxuseContext:src/hooks/useAuth.ts,src/hooks/useTheme.ts, providers insrc/context/*useRef: Node focus/scroll insrc/components/EmployeeHierarchy.tsx
-
Custom hooks
useAuth:src/hooks/useAuth.ts(wrapsAuthContext)useTheme:src/hooks/useTheme.ts(wrapsThemeContext)
-
Context (global state)
- Auth:
src/context/AuthContext.tsx(login/logout, persistence, exposure to app) - Theme:
src/context/ThemeContext.tsx(toggle/reset, MUI theme integration)
- Auth:
-
Async operations (simulated APIs)
- Login mock:
src/api/auth.tsfetchespublic/data/users.json - Employees load:
src/pages/Dashboard.tsxfetchespublic/data/employees.json
- Login mock:
-
Memoization (pure components)
EmployeeCard:React.memoto reduce re-renders (src/components/EmployeeCard.tsx)
-
Hierarchy building logic
buildEmployeeHierarchy:src/utils/employeeUtils.ts
-
Protected routes
ProtectedRoute:src/components/ProtectedRoute.tsx- Route wiring:
src/App.tsx
-
TailwindCSS + MUI usage
- Tailwind setup:
tailwind.config.js,postcss.config.js, directives insrc/index.css - Tailwind classes applied in:
src/pages/Login.tsx,src/pages/Dashboard.tsx,src/components/EmployeeHierarchy.tsx - MUI components across app (Header/AppBar, Card, TreeView, etc.)
- Tailwind setup:
public/data/users.json— mock users for loginpublic/data/employees.json— mock employees for org treesrc/context/AuthContext.tsx— auth state and actionssrc/context/ThemeContext.tsx— theme state and MUI themesrc/hooks/useAuth.ts,src/hooks/useTheme.ts— custom hookssrc/pages/Login.tsx— login pagesrc/pages/Dashboard.tsx— org chart pagesrc/components/EmployeeHierarchy.tsx— tree rendering + focussrc/components/EmployeeCard.tsx— memoized employee cardsrc/components/ProtectedRoute.tsx— route guardsrc/utils/employeeUtils.ts— hierarchy builder, search helpersrc/App.tsx— routing and providers