# harshsrivastava1323/ems architecture

> Architecture diagram of the GitHub repository harshsrivastava1323/ems, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harshsrivastava1323/ems
- Repository: https://github.com/harshsrivastava1323/ems

## Overview

##### 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/

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Build / Tooling"
        VITE["vite.config.js"]:::build
        TAILWIND["tailwind.config.js"]:::build
        POSTCSS["postcss.config.js"]:::build
    end

    Browser["Browser"]:::uiComp
    Browser --> indexhtml["index.html"]:::uiComp
    indexhtml --> VITE

    VITE --> main["main.jsx"]:::uiComp
    main --> indexcss["index.css"]:::uiComp
    main --> appcomp["App Router (App.jsx)"]:::uiComp

    appcomp --> AuthProv["AuthProvider (Context)"]:::uiComp
    AuthProv --> localstore[(localStorage)]:::persistence
    AuthProv --> AuthAPI["Auth API"]:::backend

    appcomp --> Login["Login Component"]:::uiComp
    Login -->|login request| AuthProv
    AuthProv -->|store token| localstore

    AuthProv -->|auth check| appcomp

    appcomp --> AdminDash["AdminDashboard"]:::uiComp
    appcomp --> EmpDash["EmployeeDashboard"]:::uiComp

    AdminDash --> Header["Header"]:::uiComp
    EmpDash --> Header

    AdminDash --> TaskListContainer["TaskList Container"]:::uiComp
    EmpDash --> TaskListContainer

    subgraph "TaskList Components"
        TaskListContainer
        NewTask["NewTask"]:::uiComp
        AcceptTask["AcceptTask"]:::uiComp
        CompleteTask["CompleteTask"]:::uiComp
        FailedTask["FailedTask"]:::uiComp
    end

    TaskListContainer --> NewTask
    TaskListContainer --> AcceptTask
    TaskListContainer --> CompleteTask
    TaskListContainer --> FailedTask

    TaskListContainer -->|fetch tasks| TaskAPI["Task API"]:::backend
    NewTask -->|create task| TaskAPI
    AcceptTask -->|accept task| TaskAPI
    CompleteTask -->|complete task| TaskAPI
    FailedTask -->|fail task| TaskAPI

    subgraph "Shared UI Elements"
        AllTask["AllTask"]:::uiComp
        CreateTask["CreateTask"]:::uiComp
        TaskListNumber["TaskListNumber"]:::uiComp
    end

    TaskListContainer --> AllTask
    TaskListContainer --> CreateTask
    TaskListContainer --> TaskListNumber

    AuthAPI --> DB[(Database)]:::persistence
    TaskAPI --> DB

    classDef uiComp fill:#ADD8E6,stroke:#000
    classDef persistence fill:#90EE90,stroke:#000
    classDef backend fill:#FFA500,stroke:#000
    classDef build fill:#D3D3D3,stroke:#000

    click indexhtml "https://github.com/harshsrivastava1323/ems/blob/main/index.html"
    click VITE "https://github.com/harshsrivastava1323/ems/blob/main/vite.config.js"
    click TAILWIND "https://github.com/harshsrivastava1323/ems/blob/main/tailwind.config.js"
    click POSTCSS "https://github.com/harshsrivastava1323/ems/blob/main/postcss.config.js"
    click main "https://github.com/harshsrivastava1323/ems/blob/main/src/main.jsx"
    click indexcss "https://github.com/harshsrivastava1323/ems/blob/main/src/index.css"
    click appcomp "https://github.com/harshsrivastava1323/ems/blob/main/src/App.jsx"
    click AuthProv "https://github.com/harshsrivastava1323/ems/blob/main/src/context/AuthProvider.jsx"
    click localstore "https://github.com/harshsrivastava1323/ems/blob/main/src/utils/localStorage.jsx"
    click Login "https://github.com/harshsrivastava1323/ems/blob/main/src/components/Auth/Login.jsx"
    click AdminDash "https://github.com/harshsrivastava1323/ems/blob/main/src/components/Dashboard/AdminDashboard.jsx"
    click EmpDash "https://github.com/harshsrivastava1323/ems/blob/main/src/components/Dashboard/EmployeeDashboard.jsx"
    click TaskListContainer "https://github.com/harshsrivastava1323/ems/blob/main/src/components/TaskList/TaskList.jsx"
    click NewTask "https://github.com/harshsrivastava1323/ems/blob/main/src/components/TaskList/NewTask.jsx"
    click AcceptTask "https://github.com/harshsrivastava1323/ems/blob/main/src/components/TaskList/AcceptTask.jsx"
    click CompleteTask "https://github.com/harshsrivastava1323/ems/blob/main/src/components/TaskList/CompleteTask.jsx"
    click FailedTask "https://github.com/harshsrivastava1323/ems/blob/main/src/components/TaskList/Failedtask.jsx"
    click Header "https://github.com/harshsrivastava1323/ems/blob/main/src/components/others/Header.jsx"
    click AllTask "https://github.com/harshsrivastava1323/ems/blob/main/src/components/others/AllTask.jsx"
    click CreateTask "https://github.com/harshsrivastava1323/ems/blob/main/src/components/others/CreateTask.jsx"
    click TaskListNumber "https://github.com/harshsrivastava1323/ems/blob/main/src/components/others/TaskListNumber.jsx"
```
