An open API service indexing awesome lists of open source software.

https://github.com/sazzadul1205/asset_tracker

A simple Office Asset Management System
https://github.com/sazzadul1205/asset_tracker

asset-management mongodb nextjs tailwindcss webapp

Last synced: 4 months ago
JSON representation

A simple Office Asset Management System

Awesome Lists containing this project

README

          

# ๐Ÿข Asset Tracker - Enterprise Asset Management System

A comprehensive asset tracking and management system built with Next.js 14, featuring role-based access control, real-time tracking, and complete asset lifecycle management.

## LIVE DEMO: [https://asset-tracker-gules.vercel.app/](https://asset-tracker-gules.vercel.app/)

# ๐Ÿš€ What's New in V1.1

Welcome to the latest update of our Asset Management System! Version 1.1 brings significant improvements, new features, and enhanced user experience. Here's what you can expect:

## โœจ **Major New Features**

### ๐Ÿ“ฑ **Complete Mobile Responsiveness**

- **All pages now fully responsive** - Works seamlessly on mobile, tablet, and desktop
- **Mobile-optimized navigation** - Touch-friendly buttons and menus
- **Responsive tables** that transform into cards on mobile devices
- **Adaptive layouts** that adjust based on screen size

### ๐ŸŽจ **Enhanced User Interface**

- **Modern dashboard design** with improved card layouts
- **Consistent color scheme** across all components
- **Better visual hierarchy** and spacing
- **Smooth animations** and transitions

## ๐ŸŒŸ Features

### **๐Ÿ” Authentication & Authorization**

- **Multi-role system** (Admin, Manager, Employee)
- **Secure login** with NextAuth.js
- **Protected routes** based on user roles
- **Session management** with JWT tokens

### **๐Ÿ“Š Dashboard & Analytics**

- **Role-specific dashboards** for each user type
- **Real-time statistics** and metrics
- **System activity logs**
- **Interactive charts** and data visualization

### **๐Ÿท๏ธ Asset Management**

- **Complete asset lifecycle tracking** (Acquisition to Disposal)
- **Barcode generation** and scanning support
- **Asset categorization** with custom fields
- **Asset assignment** to employees/departments
- **Depreciation tracking** and valuation

### **๐Ÿ‘ฅ Employee & Department Management**

- **Employee profiles** with asset assignments
- **Department hierarchy** management
- **Manager-employee relationships**
- **Bulk user operations**

### **๐Ÿ”„ Request & Workflow System**

- **8+ request types**: Assign, Transfer, Repair, Return, Dispose, Retire, Update, Request New
- **Approval workflows** with notifications
- **Request history** and tracking
- **Automatic email notifications**

### **๐Ÿ“ˆ Reporting & Transactions**

- **Transaction history** with audit trail
- **Custom reports** generation
- **Export functionality** (PDF, Excel)
- **Filtering and searching** capabilities

## ๐Ÿ—๏ธ Project Structure

```
asset_tracker/
โ”œโ”€โ”€ src/app/ # Next.js App Router
โ”‚ โ”œโ”€โ”€ admin/ # Admin panel pages
โ”‚ โ”‚ โ”œโ”€โ”€ dashboard/ # Admin dashboard
โ”‚ โ”‚ โ”œโ”€โ”€ assets/ # Asset management
โ”‚ โ”‚ โ”œโ”€โ”€ employees/ # Employee management
โ”‚ โ”‚ โ”œโ”€โ”€ departments/ # Department management
โ”‚ โ”‚ โ”œโ”€โ”€ assetsCategories/ # Asset categories
โ”‚ โ”‚ โ”œโ”€โ”€ myAssets/ # Admin's assigned assets
โ”‚ โ”‚ โ”œโ”€โ”€ myRequests/ # Admin's requests
โ”‚ โ”‚ โ”œโ”€โ”€ transactions/ # All system transactions
โ”‚ โ”‚ โ”œโ”€โ”€ profile/ # Admin profile
โ”‚ โ”‚ โ””โ”€โ”€ companySettings/ # Company configuration
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ manager/ # Manager panel pages
โ”‚ โ”‚ โ”œโ”€โ”€ dashboard/ # Manager dashboard
โ”‚ โ”‚ โ”œโ”€โ”€ myAssets/ # Manager's assets
โ”‚ โ”‚ โ”œโ”€โ”€ myEmployees/ # Manager's team
โ”‚ โ”‚ โ”œโ”€โ”€ myRequests/ # Manager's requests
โ”‚ โ”‚ โ”œโ”€โ”€ transactions/ # Department transactions
โ”‚ โ”‚ โ””โ”€โ”€ profile/ # Manager profile
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ employee/ # Employee panel pages
โ”‚ โ”‚ โ”œโ”€โ”€ dashboard/ # Employee dashboard
โ”‚ โ”‚ โ”œโ”€โ”€ myAssets/ # Employee's assets
โ”‚ โ”‚ โ”œโ”€โ”€ myRequests/ # Employee's requests
โ”‚ โ”‚ โ””โ”€โ”€ profile/ # Employee profile
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ auth/ # Authentication pages
โ”‚ โ”‚ โ””โ”€โ”€ login/ # Login page
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ api/ # API Routes
โ”‚ โ”‚ โ”œโ”€โ”€ auth/ # Authentication endpoints
โ”‚ โ”‚ โ”œโ”€โ”€ assets/ # Asset CRUD operations
โ”‚ โ”‚ โ”œโ”€โ”€ users/ # User management
โ”‚ โ”‚ โ”œโ”€โ”€ department/ # Department operations
โ”‚ โ”‚ โ”œโ”€โ”€ requests/ # Request handling
โ”‚ โ”‚ โ”œโ”€โ”€ assetsCategories/ # Category operations
โ”‚ โ”‚ โ”œโ”€โ”€ company/ # Company settings
โ”‚ โ”‚ โ”œโ”€โ”€ allCounts/ # Dashboard statistics
โ”‚ โ”‚ โ””โ”€โ”€ requestLogs/ # Activity logs
โ”‚ โ”‚
โ”‚ โ””โ”€โ”€ layout.js # Root layout
โ”‚
โ”œโ”€โ”€ src/Shared/ # Reusable components
โ”‚ โ”œโ”€โ”€ Navbar/ # Navigation component
โ”‚ โ”œโ”€โ”€ Footer/ # Footer component
โ”‚ โ”œโ”€โ”€ Loading/ # Loading indicators
โ”‚ โ”œโ”€โ”€ Error/ # Error components
โ”‚ โ”œโ”€โ”€ Shared_Button/ # Custom buttons
โ”‚ โ”œโ”€โ”€ Shared_Input/ # Form inputs
โ”‚ โ””โ”€โ”€ Table_Pagination/ # Data table components
โ”‚
โ”œโ”€โ”€ src/hooks/ # Custom React hooks
โ”‚ โ”œโ”€โ”€ useAuth.js # Authentication hook
โ”‚ โ”œโ”€โ”€ useAxiosPublic.js # API client hook
โ”‚ โ”œโ”€โ”€ useImageUpload.js # Image upload hook
โ”‚ โ””โ”€โ”€ useToast.js # Notification hook
โ”‚
โ”œโ”€โ”€ src/Providers/ # Context providers
โ”‚ โ””โ”€โ”€ QueryProvider.js # React Query provider
โ”‚
โ”œโ”€โ”€ src/Utils/ # Utility functions
โ”‚ โ”œโ”€โ”€ formatCurrency.js # Currency formatting
โ”‚ โ””โ”€โ”€ formatStatus.js # Status formatting
โ”‚
โ”œโ”€โ”€ src/lib/ # Database and external libs
โ”‚ โ””โ”€โ”€ connectDB.js # Database connection
โ”‚
โ”œโ”€โ”€ public/ # Static assets
โ”‚ โ”œโ”€โ”€ Icons/ # Custom icons
โ”‚ โ”œโ”€โ”€ Logo/ # Brand logos
โ”‚ โ””โ”€โ”€ various SVG files
โ”‚
โ””โ”€โ”€ middleware.js # Route protection middleware
```

## ๐ŸŽฏ User Roles & Permissions

### **๐Ÿ‘‘ Admin**

- Full system access
- Manage all assets, users, departments
- Configure system settings
- View all transactions and logs
- Approve/reject all requests

### **๐Ÿ‘” Manager**

- Manage department assets
- View and manage team members
- Approve department requests
- Generate department reports
- Limited system configuration

### **๐Ÿ‘ค Employee**

- View assigned assets
- Submit asset requests
- Track personal requests
- Update personal profile
- View department assets

## ๐Ÿ“‹ Request Types

The system supports 8 types of asset requests:

1. **๐Ÿ“ฆ Assign Asset** - Assign asset to employee
2. **๐Ÿ”„ Transfer Asset** - Transfer between employees/departments
3. **๐Ÿ”ง Repair Asset** - Request maintenance/repair
4. **โ†ฉ๏ธ Return Asset** - Return assigned asset
5. **๐Ÿ—‘๏ธ Dispose Asset** - Dispose of damaged assets
6. **๐Ÿ Retire Asset** - Retire obsolete assets
7. **โœ๏ธ Update Asset** - Modify asset information
8. **๐Ÿ†• Request Asset** - Request new asset acquisition

## ๐Ÿš€ Getting Started

### Prerequisites

- Node.js 18+
- MongoDB database
- npm or yarn

### Installation

1. **Clone the repository**

```bash
git clone
cd asset_tracker
```

2. **Install dependencies**

```bash
npm install
# or
yarn install
# or
pnpm install
```

3. **Environment Configuration**

```bash
cp .env.example .env.local
```

Edit `.env.local` with your configuration:

```env
MONGODB_URI=your_mongodb_connection_string
NEXTAUTH_SECRET=your_secret_key
NEXTAUTH_URL=http://localhost:3000
```

4. **Database Setup**

- Ensure MongoDB is running
- The system will create necessary collections automatically

5. **Run the development server**

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```

6. **Access the application**

- Open [http://localhost:3000](http://localhost:3000)
- Login with default admin credentials (setup required)

## ๐Ÿ› ๏ธ Technology Stack

### **Frontend**

- **Next.js 14** - React framework with App Router
- **React 18** - UI library
- **Tailwind CSS** - Styling framework
- **React Icons** - Icon library
- **React Hook Form** - Form handling
- **React Query** - Data fetching and caching

### **Backend**

- **Next.js API Routes** - Serverless functions
- **NextAuth.js** - Authentication
- **Mongoose** - MongoDB ODM
- **Axios** - HTTP client
- **JWT** - Token-based authentication

### **Database**

- **MongoDB** - NoSQL database
- **Mongoose** - Data modeling

### **Development Tools**

- **ESLint** - Code linting
- **Prettier** - Code formatting
- **Turbopack** - Fast builds

## ๐Ÿ“Š Database Models

### **User Model**

```javascript
{
name: String,
email: String,
password: String,
role: ['admin', 'manager', 'employee'],
department: ObjectId,
manager: ObjectId,
status: ['active', 'inactive'],
profileImage: String,
contactInfo: Object
}
```

### **Asset Model**

```javascript
{
tag: String, // Unique identifier
serialNumber: String,
name: String,
category: ObjectId,
status: ['available', 'assigned', 'maintenance', 'retired'],
assignedTo: ObjectId,
department: ObjectId,
purchaseDate: Date,
purchaseValue: Number,
currentValue: Number,
location: String,
specifications: Object
}
```

### **Request Model**

```javascript
{
type: String, // 8 request types
asset: ObjectId,
requestedBy: ObjectId,
assignedTo: ObjectId,
department: ObjectId,
status: ['pending', 'approved', 'rejected', 'completed'],
priority: ['low', 'medium', 'high'],
description: String,
attachments: Array,
comments: Array,
approvedBy: ObjectId,
approvalDate: Date
}
```

## ๐Ÿ”ง API Endpoints

### **Authentication**

- `POST /api/auth/[...nextauth]` - Login/Logout
- `POST /api/auth/UpdatePassword/[userId]` - Password update

### **Users**

- `GET /api/users` - List all users
- `POST /api/users` - Create user
- `GET /api/users/[userId]` - Get user details
- `PUT /api/users/[userId]` - Update user
- `GET /api/users/EmployeeManager` - Get managers
- `GET /api/users/MyEmployees/[userId]` - Get manager's employees

### **Assets**

- `GET /api/assets` - List all assets
- `POST /api/assets` - Create asset
- `GET /api/assets/[tag]` - Get asset by tag
- `PUT /api/assets/[tag]` - Update asset
- `DELETE /api/assets/[tag]` - Delete asset
- `GET /api/assets/AssetOption` - Asset options for dropdowns

### **Requests**

- `GET /api/requests` - List all requests
- `POST /api/requests` - Create request
- `GET /api/requests/[requestedBy]` - Get user's requests
- `PUT /api/requests/Accepted/[id]` - Approve request
- `PUT /api/requests/Rejected/[id]` - Reject request

### **Departments**

- `GET /api/department` - List departments
- `POST /api/department` - Create department
- `GET /api/department/[departmentId]` - Get department
- `PUT /api/department/[departmentId]` - Update department
- `GET /api/department/DepartmentOptions` - Department options

## ๐ŸŽจ Customization

### **Adding New Asset Categories**

1. Navigate to `/admin/assetsCategories`
2. Click "Add New Category"
3. Define category fields and validation rules

### **Configuring Company Settings**

1. Navigate to `/admin/companySettings`
2. Update company information
3. Configure system preferences

### **Customizing Email Templates**

- Email templates are located in the API routes
- Modify request approval/rejection emails in `/api/requests/`

## ๐Ÿ“ฑ Mobile Responsiveness

The application is fully responsive across:

- **Desktop** (โ‰ฅ1024px) - Full feature access
- **Tablet** (768px-1023px) - Optimized layouts
- **Mobile** (<768px) - Touch-friendly interfaces

## ๐Ÿ”’ Security Features

- **Role-based access control** (RBAC)
- **Password hashing** with bcrypt
- **JWT token authentication**
- **CSRF protection**
- **Input validation** and sanitization
- **SQL/NoSQL injection prevention**
- **Rate limiting** on authentication endpoints

## ๐Ÿ“ˆ Performance Optimizations

- **Server-side rendering** for critical pages
- **Client-side caching** with React Query
- **Image optimization** with Next.js Image
- **Code splitting** and lazy loading
- **Database indexing** for frequent queries
- **Compressed assets** and minified code

## ๐Ÿšข Deployment

### **Vercel (Recommended)**

```bash
npm i -g vercel
vercel
```

### **Docker Deployment**

```dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
```

### **Environment Variables for Production**

```env
MONGODB_URI=your_production_mongodb_uri
NEXTAUTH_SECRET=strong_random_secret
NEXTAUTH_URL=https://yourdomain.com
NEXT_PUBLIC_API_URL=https://api.yourdomain.com
```

## ๐Ÿงช Testing

### **Run Tests**

```bash
# Unit tests
npm test

# Integration tests
npm run test:integration

# E2E tests
npm run test:e2e
```

### **Test Coverage**

- **Unit tests**: Components and utilities
- **Integration tests**: API endpoints
- **E2E tests**: User workflows
- **Security tests**: Authentication and authorization

## ๐Ÿ› Troubleshooting

### **Common Issues**

1. **MongoDB Connection Failed**

- Verify MongoDB is running
- Check connection string in `.env.local`
- Ensure network access is allowed

2. **Authentication Issues**

- Clear browser cookies
- Check JWT secret in environment variables
- Verify user exists in database

3. **Build Errors**
- Clear `.next` cache: `rm -rf .next`
- Reinstall dependencies: `npm ci`
- Check Node.js version compatibility

### **Logs**

- Application logs are available in the console
- Database queries can be logged by enabling Mongoose debug
- API request logs are stored in the database

## ๐Ÿ“„ License

This project is proprietary software. All rights reserved.

## ๐Ÿ‘ฅ Support

For support, please contact:

- **System Administrator**: admin@company.com
- **Technical Support**: support@company.com
- **Documentation**: [Internal Wiki Link]

## ๐Ÿ”„ Changelog

### **Version 1.0.0** (Current)

- Initial release with core features
- Multi-role system implementation
- Complete asset lifecycle management
- Request and approval workflows
- Comprehensive reporting

---

## ๐Ÿš€ Quick Start Commands

```bash
# Development
npm run dev

# Production build
npm run build
npm start

# Linting
npm run lint

# Formatting
npm run format

# Type checking (if using TypeScript)
npm run type-check
```

---

**โœจ System Ready!** Your asset tracking system is configured and ready for deployment. Remember to:

1. Set up initial admin user
2. Configure company settings
3. Import existing assets (if any)
4. Train users on the system
5. Set up regular backups

For detailed implementation guides, refer to the internal documentation or contact the development team.