Skip to content

EliKay1414/React-Admin-Dashboad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React Admin Dashboard

A modern, fully-featured admin dashboard application built with React and Vite. This project demonstrates advanced frontend development practices including authentication, protected routes, state management, responsive UI design, and data visualization.

React Vite Node License

πŸ“‹ Table of Contents

πŸ“Œ Overview

This React Admin Dashboard is a production-ready application that showcases modern frontend architecture and best practices. It includes a complete authentication system, user management, analytics dashboard, reporting tools, and user profile management. The application supports both real backend APIs and local mock data for development.

πŸ› οΈ Tech Stack

Frontend Framework

  • React 18 - UI library with hooks for state management
  • Vite - Lightning-fast build tool and dev server (Next-gen bundler)
  • React Router DOM v6 - Client-side routing with nested routes and protected navigation

State Management & Context

  • React Context API - Global state for authentication and user data
  • useReducer & useEffect Hooks - Advanced state management patterns

Data Visualization

  • Recharts - Composable charting library for React
    • Line charts for analytics
    • Bar charts for comparisons
    • Responsive and interactive visualizations

Styling

  • CSS3 - Modern responsive design with Flexbox and Grid
  • Mobile-first approach - Fully responsive across all devices
  • Custom CSS - No dependency bloat, pure CSS for performance

Development Tools

  • ESLint - Code quality and consistency
  • Babel - JavaScript transpilation
  • npm/yarn - Package management

Backend Integration

  • Fetch API - Modern HTTP client
  • Mock API Layer - Built-in development mock backend
  • Environment-based configuration - Easy switching between mock and real APIs

✨ Features

πŸ” Authentication & Authorization

  • User login and signup functionality
  • JWT-based token management
  • Persistent authentication (localStorage-based)
  • Protected routes with PrivateRoute component
  • Demo account for immediate testing (admin/password123)
  • Offline fallback support
  • Comprehensive error handling

πŸ“Š Dashboard Analytics

  • Real-time statistics display (Visitors, Sales, Conversion Rate, Revenue)
  • Interactive charts with Recharts
  • Data visualization with multiple chart types
  • Responsive dashboard layout
  • Mock data included for development

πŸ‘₯ User Management

  • View all users with table display
  • Add new users
  • Delete users with confirmation
  • User role management (admin, member)
  • Inline editing capabilities
  • Responsive user list

πŸ“ˆ Reports & Analytics

  • Activity reports with status tracking
  • Report generation interface
  • Historical data tracking
  • Date-based filtering
  • Export-ready report structure

πŸ‘€ User Profile

  • View user information
  • Edit profile details
  • Profile picture support
  • Email and contact management
  • Real-time profile updates

βš™οΈ Settings & Configuration

  • User preferences management
  • Application settings
  • LocalStorage persistence
  • Theme/UI preferences
  • Notification settings

🎨 UI/UX Features

  • Responsive sidebar navigation
  • Intuitive header with user info
  • Clean and modern design
  • Form validation
  • Error handling and user feedback
  • Loading states
  • Success/error notifications

πŸ“ Project Structure

Dashboard-App/
β”œβ”€β”€ public/                          # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ Card.jsx                # Reusable card component
β”‚   β”‚   β”œβ”€β”€ Header.jsx              # Dashboard header with user info
β”‚   β”‚   β”œβ”€β”€ Layout.jsx              # Main layout wrapper
β”‚   β”‚   β”œβ”€β”€ Sidebar.jsx             # Navigation sidebar
β”‚   β”‚   β”œβ”€β”€ PrivateRoute.jsx        # Protected route wrapper
β”‚   β”‚   └── ProtectedRoute.jsx      # Alternative route protection
β”‚   β”œβ”€β”€ context/
β”‚   β”‚   └── AuthContext.jsx         # Authentication context provider
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── api.js                  # API endpoints and fetch helpers
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx           # Main dashboard layout
β”‚   β”‚   β”œβ”€β”€ Home.jsx                # Dashboard home with stats
β”‚   β”‚   β”œβ”€β”€ Users.jsx               # User management page
β”‚   β”‚   β”œβ”€β”€ Reports.jsx             # Reports page
β”‚   β”‚   β”œβ”€β”€ Profile.jsx             # User profile page
β”‚   β”‚   β”œβ”€β”€ Settings.jsx            # Settings page
β”‚   β”‚   β”œβ”€β”€ Login.jsx               # Login page
β”‚   β”‚   └── Signup.jsx              # Registration page
β”‚   β”œβ”€β”€ Layout/
β”‚   β”‚   └── DashboardLayout.jsx     # Dashboard layout structure
β”‚   β”œβ”€β”€ Routes/
β”‚   β”‚   └── PrivateRoute.jsx        # Route protection logic
β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   β”œβ”€β”€ dashboard.css           # Dashboard styling
β”‚   β”‚   β”œβ”€β”€ header.css              # Header styling
β”‚   β”‚   β”œβ”€β”€ login.css               # Authentication styling
β”‚   β”‚   └── sidebar.css             # Sidebar styling
β”‚   β”œβ”€β”€ App.jsx                     # Main app component with routes
β”‚   β”œβ”€β”€ main.jsx                    # React entry point
β”‚   └── assets/                     # Images and media
β”œβ”€β”€ .env                            # Environment variables (local)
β”œβ”€β”€ .env.example                    # Environment template
β”œβ”€β”€ .gitignore                      # Git ignore rules
β”œβ”€β”€ eslint.config.js               # ESLint configuration
β”œβ”€β”€ vite.config.js                 # Vite configuration
β”œβ”€β”€ package.json                   # Dependencies and scripts
└── README.md                      # This file

πŸš€ Installation

Prerequisites

  • Node.js 18+ installed
  • npm or yarn package manager
  • Git installed

Step 1: Clone the Repository

git clone https://github.com/EliKay1414/React-Admin-Dashboad.git
cd Dashboard-App

Step 2: Install Dependencies

npm install
# or
yarn install

Step 3: Configure Environment

# Copy the example env file
cp .env.example .env

# The default configuration uses mock API
# To use a real backend, change .env:
# VITE_USE_MOCK_API=false
# VITE_API_URL=http://your-backend-url:port

🎯 Getting Started

Development Server

npm run dev
# Starts Vite dev server at http://localhost:5173

Build for Production

npm run build
# Creates optimized build in dist/ folder

Preview Production Build

npm run preview
# Serves the production build locally

Lint Code

npm run lint
# Checks code quality with ESLint

πŸ”Œ API Integration

Architecture

The application uses a centralized API layer in src/config/api.js:

// API_ENDPOINTS - Organized by feature
API_ENDPOINTS.AUTH.LOGIN
API_ENDPOINTS.DASHBOARD.STATS
API_ENDPOINTS.USERS.GET_ALL
API_ENDPOINTS.PROFILE.UPDATE

Mock API (Development)

When VITE_USE_MOCK_API=true, the app uses in-memory mock data:

  • No external dependencies required
  • Instant responses
  • Perfect for UI development
  • Simulates real API behavior

Real API (Production)

Set VITE_USE_MOCK_API=false to connect to a backend:

  • Standard REST endpoints
  • Bearer token authentication
  • Timeout handling (configurable)
  • Error handling with fallbacks

Fetch Helper

import { fetchWithTimeout, API_ENDPOINTS } from "../config/api";

const response = await fetchWithTimeout(API_ENDPOINTS.USERS.GET_ALL, {
  method: 'GET',
  headers: getAuthHeader(token),
});
const data = await response.json();

πŸ” Authentication

Flow

  1. User submits login form with username and password
  2. AuthContext validates and sends request
  3. Backend returns JWT token or mock demo token
  4. Token stored in localStorage
  5. PrivateRoute checks token before rendering protected pages

Demo Account

Username: admin
Password: password123

Features

  • Automatic token persistence
  • Logout functionality
  • Error state management
  • Network error handling
  • Demo fallback when backend unavailable

Code Example

const { login, logout, user, token } = useAuth();

// Login
await login(username, password);

// Logout
logout();

// Check auth status
if (user?.authenticated) {
  // User is logged in
}

πŸ’» Development

Key Technologies Used

React 18 Features:

  • Functional components with hooks
  • Context API for state management
  • useEffect for side effects
  • useState for local state
  • useReducer for complex state logic

React Router v6:

  • Nested route structure
  • Route parameters
  • Programmatic navigation
  • Protected route patterns
  • Layout routes

Performance Considerations:

  • Code splitting with lazy routes
  • Optimized re-renders with Context
  • Minimal dependencies
  • Fast Vite bundler
  • CSS modules approach

Component Patterns

Protected Route:

<PrivateRoute>
  <Dashboard />
</PrivateRoute>

Context Hook:

const { user, login, logout } = useAuth();

Data Fetching:

useEffect(() => {
  fetchData();
}, [dependency]);

πŸ—οΈ Build & Deployment

Production Build

npm run build

Creates optimized dist folder ready for deployment.

Deployment Options

  • Vercel - Recommended for Next-gen React apps
  • Netlify - Excellent Vite support
  • GitHub Pages - Static hosting
  • AWS Amplify - Full-stack deployment
  • Docker - Containerized deployment

Environment Variables for Production

VITE_API_URL=https://api.production.com
VITE_API_TIMEOUT=15000
VITE_USE_MOCK_API=false

πŸŽ“ Demo Credentials

Test Account

  • Username: admin
  • Password: password123

Use these credentials to explore all dashboard features without needing a real backend.

🧩 Key Components

AuthContext.jsx

Manages global authentication state including:

  • User login/logout
  • Token management
  • Error handling
  • Network error detection
  • Demo fallback

PrivateRoute.jsx

Guards routes requiring authentication:

  • Checks if user is authenticated
  • Redirects to login if not
  • Persists attempted route

Sidebar.jsx

Navigation component with:

  • Menu items
  • Active route highlighting
  • Responsive mobile menu
  • User logout option

Dashboard.jsx

Main dashboard layout featuring:

  • Sidebar navigation
  • Header with user info
  • Nested routes for pages
  • Responsive layout

Home.jsx

Dashboard home page with:

  • Statistics cards
  • Analytics charts
  • Reports list
  • Data visualization

πŸŽͺ State Management

Context API Architecture

AuthProvider (Global)
β”œβ”€β”€ user (authentication state)
β”œβ”€β”€ token (JWT token)
β”œβ”€β”€ loading (request state)
β”œβ”€β”€ error (error messages)
└── Methods: login, logout, signup

Local Component State

  • Form inputs
  • UI state (loading, errors)
  • Modal visibility
  • Pagination state

🎨 Styling

CSS Architecture

  • Global styles - Base component styling
  • Component-specific CSS - Modular styles per component
  • Responsive design - Mobile-first approach
  • CSS Grid & Flexbox - Modern layout techniques

CSS Files

  • dashboard.css - Dashboard layout and components
  • header.css - Header and navigation styling
  • login.css - Authentication pages styling
  • sidebar.css - Sidebar navigation styling

Responsive Breakpoints

Desktop: 1024px and above
Tablet: 768px - 1023px
Mobile: 320px - 767px

⚑ Performance Optimizations

  1. Vite Bundler - Ultra-fast builds and HMR
  2. Lazy Route Loading - Load pages on demand
  3. Context API - Efficient state management
  4. CSS Optimization - Minimal CSS payload
  5. No Build Bloat - Only essential dependencies
  6. Browser Caching - LocalStorage for persistence
  7. Mock API - Instant development without backend

πŸš€ Future Enhancements

  • TypeScript integration for type safety
  • Advanced analytics with more chart types
  • Real-time data with WebSockets
  • User permissions and role-based access
  • Dark mode theme toggle
  • Data export functionality (CSV, PDF)
  • Advanced filtering and search
  • User activity logging
  • Email notifications
  • API documentation (Swagger/OpenAPI)
  • Unit and integration tests
  • E2E testing with Cypress

πŸ“š Learning Resources

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’Ό Author

Created as a demonstration of modern React development practices and full-stack dashboard application development.

πŸ“§ Support

For issues, questions, or suggestions, please open an issue on GitHub or contact the development team.


Note: This project uses a mock API layer for development. To integrate with a real backend, update the environment variables and ensure your backend API is running on the configured URL.

About

A dashboard displaying key performance indicators (KPIs) through interactive charts and graphs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors