A full-stack application for managing device inventory, assignments, and team members with OTP-based device verification.
techtrack/
├── techtrack/ # Next.js Frontend
│ ├── app/
│ │ ├── (auth)/ # Authentication pages (login, register)
│ │ ├── (dashboard)/ # Protected dashboard pages
│ │ │ ├── dashboard/ # Main dashboard
│ │ │ ├── devices/ # Device management
│ │ │ ├── assignments/ # Assignment management
│ │ │ ├── members/ # Team member management
│ │ │ └── audit/ # Audit log
│ │ ├── portal/ # Public OTP verification portal
│ │ └── accept-invite/ # Invite acceptance page
│ ├── components/ # Reusable React components
│ ├── lib/ # Utilities and API client
│ └── middleware.ts # Route protection
│
└── techtrack-api/ # Node.js + Express Backend
├── src/
│ ├── models/ # Mongoose schemas
│ ├── routes/ # API route handlers
│ ├── middleware/ # Auth & role middleware
│ └── lib/ # Database & auth utilities
└── .env # Environment variables
- Node.js 18+ and pnpm
- MongoDB (local or cloud instance)
- Navigate to the backend directory:
cd techtrack-api- Install dependencies:
pnpm install- Configure environment variables in
.env:
MONGODB_URI=mongodb://localhost:27017/laptoptracker
JWT_SECRET=your-secret-key-change-this-in-production
PORT=5000
FRONTEND_URL=http://localhost:3000- Start the development server:
pnpm devThe API will be available at http://localhost:5000
- Navigate to the frontend directory:
cd techtrack- Install dependencies:
pnpm install- Configure environment variables in
.env.local:
NEXT_PUBLIC_API_URL=http://localhost:5000/api- Start the development server:
pnpm devThe frontend will be available at http://localhost:3000
The device assignment process uses a secure OTP-based verification system:
- Admin navigates to a device detail page
- Clicks "Assign Device" button
- Selects a staff member from the dropdown
- Clicks "Generate OTP"
- Backend generates a 6-digit OTP
- OTP is hashed with bcrypt and stored in database
- OTP expires in 15 minutes
- Admin sees the OTP and portal URL
- Staff member receives OTP from admin (via email, chat, etc.)
- Opens the portal URL on the device being assigned
- Enters the 6-digit OTP code
- Portal automatically collects system information:
- Operating system and version
- RAM (if available)
- Screen resolution
- Hostname
- Backend verifies OTP and creates assignment with status
pending_admin - Device status remains
available - Auto-detected specs are stored with the assignment
- Admin sees pending assignment notification
- Reviews auto-detected information
- Adds accessories, condition notes, and admin notes
- Confirms assignment
- Device status changes to
assigned - Assignment status changes to
confirmed
- Admin clicks "Return Device" on assignment
- Assignment is marked as inactive with return date
- Device status changes back to
available
- Full system access
- Can manage all devices, assignments, and members
- Can change user roles
- Can deactivate users
- Can view audit logs
- Can manage devices and assignments
- Can invite new members
- Can view audit logs
- Cannot change user roles or deactivate users
- Can view devices
- Can view their own assignments
- Cannot manage devices or members
- Cannot view audit logs
- Organization details and branding
- Unique slug for identification
- Team members with roles
- Email/password authentication
- Invite token system for onboarding
- Hardware inventory tracking
- Specifications and purchase information
- Status tracking (available, assigned, maintenance, retired)
- Links devices to users
- Tracks assignment lifecycle
- Stores auto-detected device information
- Status: pending_admin, confirmed, returned
- One-time passwords for device verification
- 15-minute expiration
- Linked to specific device and user
- Comprehensive activity tracking
- All system changes logged
- Actor, action, target, and details
- Next.js 14 - React framework with App Router
- TypeScript - Type safety
- Tailwind CSS - Styling
- Axios - HTTP client
- date-fns - Date formatting
- lucide-react - Icons
- Node.js - Runtime
- Express - Web framework
- TypeScript - Type safety
- MongoDB - Database
- Mongoose - ODM
- bcryptjs - Password hashing
- jsonwebtoken - JWT authentication
- nanoid - ID generation
POST /api/auth/register- Create organization and super adminPOST /api/auth/login- Login with email/passwordPOST /api/auth/logout- Logout and clear cookieGET /api/auth/me- Get current userPOST /api/auth/accept-invite- Accept team invitation
GET /api/devices- List devices (paginated, filterable)POST /api/devices- Create device (admin+)GET /api/devices/:id- Get device detailsPATCH /api/devices/:id- Update device (admin+)DELETE /api/devices/:id- Retire device (super admin)GET /api/devices/:id/history- Get assignment historyPOST /api/devices/:id/generate-otp- Generate OTP (admin+)
POST /api/portal/verify-otp- Verify OTP codePOST /api/portal/submit- Submit device information
GET /api/assignments- List assignments (paginated)GET /api/assignments/pending- Get pending confirmationsGET /api/assignments/:id- Get assignment detailsPATCH /api/assignments/:id/confirm- Confirm assignment (admin+)POST /api/assignments/:id/return- Return device (admin+)
GET /api/members- List team membersPOST /api/members/invite- Invite new member (admin+)GET /api/members/:id- Get member detailsPATCH /api/members/:id/role- Change role (super admin)DELETE /api/members/:id- Deactivate member (super admin)
GET /api/dashboard/stats- Get dashboard statistics
GET /api/audit- List audit logs (admin+, paginated)
- JWT-based authentication with httpOnly cookies
- Password hashing with bcrypt (10 rounds)
- OTP hashing for secure verification
- Role-based access control
- Rate limiting on public portal (20 requests per IP per 15 minutes)
- CORS configuration
- Input validation and sanitization
MIT
For issues or questions, please open an issue on the repository. "# TechTrack"