Skip to content

TechFix Pro is a feature-rich laptop repair management system built with Next.js, TypeScript, MongoDB, React, and Tailwind CSS. It supports JWT-based secure authentication, real-time repair request tracking with priority and cost management, dashboard analytics, and responsive design

Notifications You must be signed in to change notification settings

thenitishmind/TechFix-Pro---Next-Gen-Laptop-Repair-Management-System

Repository files navigation

πŸ› οΈ TechFix Pro - Next-Gen Laptop Repair Management System

Next.js TypeScript MongoDB Tailwind CSS React

A comprehensive, professional laptop repair management system built with Next.js, TypeScript, MongoDB, and Tailwind CSS. This system provides complete tracking and management of laptop repair requests with authentication, status management, and resolution tracking.

πŸ“‹ Table of Contents

✨ Features

  • πŸ” Secure Authentication System: JWT-based authentication with protected routes
  • πŸ“ Query Management: Submit, track, and manage laptop repair requests
  • πŸ“Š Status Tracking: Real-time status updates (Pending, Resolved, Not Resolved)
  • 🎯 Priority System: Assign priorities (Low, Medium, High, Urgent)
  • πŸ’° Cost Management: Track estimated and actual repair costs
  • πŸ” Advanced Filtering: Filter queries by status, priority, and other criteria
  • πŸ“± Responsive Design: Mobile-first design with Tailwind CSS
  • πŸš€ Real-time Updates: Dynamic updates without page refresh
  • πŸ›‘οΈ Data Validation: Comprehensive server-side and client-side validation
  • πŸ“ˆ Dashboard Analytics: Overview of repair statistics and metrics

πŸ—οΈ Project Structure

laptop-repair-management/
β”œβ”€β”€ πŸ“ components/          # Reusable React components
β”‚   β”œβ”€β”€ AddLaptopQuery.tsx  # Form for submitting new repair requests
β”‚   β”œβ”€β”€ Layout.tsx          # Main layout wrapper
β”‚   β”œβ”€β”€ ListSection.tsx     # Display pending queries
β”‚   β”œβ”€β”€ Navigation.tsx      # Navigation component
β”‚   β”œβ”€β”€ ProtectedRoute.tsx  # Route protection wrapper
β”‚   └── ResolvedSection.tsx # Display resolved queries
β”œβ”€β”€ πŸ“ contexts/            # React context providers
β”‚   └── AuthContext.tsx     # Authentication context
β”œβ”€β”€ πŸ“ lib/                 # Utility libraries
β”‚   └── mongoose.ts         # MongoDB connection
β”œβ”€β”€ πŸ“ models/              # Database models
β”‚   β”œβ”€β”€ LaptopQuery.ts      # Laptop query schema
β”‚   └── User.ts             # User authentication schema
β”œβ”€β”€ πŸ“ pages/               # Next.js pages
β”‚   β”œβ”€β”€ πŸ“ api/             # API routes
β”‚   β”‚   β”œβ”€β”€ πŸ“ auth/        # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ backup-login.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ complete-reset.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ force-reset-users.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ init-users.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ login.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ logout.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ me.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ reset-users.ts
β”‚   β”‚   β”‚   └── simple-login.ts
β”‚   β”‚   β”œβ”€β”€ πŸ“ debug/       # Debug endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ db-status.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ detailed-users.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ env-check.ts
β”‚   β”‚   β”‚   └── test-login.ts
β”‚   β”‚   └── πŸ“ queries/     # Query management endpoints
β”‚   β”‚       β”œβ”€β”€ [id].ts     # Individual query operations
β”‚   β”‚       β”œβ”€β”€ index.ts    # Main query operations
β”‚   β”‚       β”œβ”€β”€ pending.ts  # Pending queries
β”‚   β”‚       └── resolved.ts # Resolved queries
β”‚   β”œβ”€β”€ _app.tsx            # App wrapper with providers
β”‚   β”œβ”€β”€ _error.tsx          # Error page
β”‚   β”œβ”€β”€ index.tsx           # Home page
β”‚   └── login.tsx           # Login page
β”œβ”€β”€ πŸ“ scripts/             # Utility scripts
β”‚   β”œβ”€β”€ check-mongodb-users.js
β”‚   β”œβ”€β”€ complete-fix.js
β”‚   β”œβ”€β”€ final-setup.js
β”‚   β”œβ”€β”€ fix-credentials.js
β”‚   β”œβ”€β”€ init-users.js
β”‚   β”œβ”€β”€ mongodb-status.js
β”‚   β”œβ”€β”€ quick-test.js
β”‚   β”œβ”€β”€ reset-users.js
β”‚   β”œβ”€β”€ setup-auth.js
β”‚   β”œβ”€β”€ test-credentials.js
β”‚   └── test-db.js
β”œβ”€β”€ πŸ“ styles/              # Global styles
β”‚   └── globals.css         # Tailwind CSS and global styles
β”œβ”€β”€ next.config.js          # Next.js configuration
β”œβ”€β”€ package.json            # Dependencies and scripts
β”œβ”€β”€ postcss.config.js       # PostCSS configuration
β”œβ”€β”€ tailwind.config.js      # Tailwind CSS configuration
β”œβ”€β”€ tsconfig.json           # TypeScript configuration
└── README.md               # Project documentation

πŸ› οΈ Tech Stack

Frontend

  • Next.js 14.2.5: React framework with SSR and API routes
  • React 18: Frontend library
  • TypeScript 5: Type-safe JavaScript
  • Tailwind CSS 3.4.1: Utility-first CSS framework

Backend

  • Node.js: Runtime environment
  • Next.js API Routes: Server-side API endpoints
  • MongoDB 6.8.0: NoSQL database
  • Mongoose 8.5.2: MongoDB object modeling

Authentication & Security

  • JSON Web Tokens (JWT) 9.0.2: Secure authentication
  • bcryptjs 3.0.2: Password hashing
  • Protected Routes: Client-side route protection

Development Tools

  • ESLint: Code linting
  • PostCSS: CSS processing
  • Autoprefixer: CSS vendor prefixes

πŸ›οΈ System Architecture

The system follows a modern full-stack architecture:

  1. Frontend Layer: React components with TypeScript
  2. API Layer: Next.js API routes handling business logic
  3. Database Layer: MongoDB with Mongoose ODM
  4. Authentication Layer: JWT-based secure authentication
  5. State Management: React Context for global state

πŸ“¦ Project Modules

1. Authentication Module (contexts/AuthContext.tsx)

  • Purpose: Manages user authentication state
  • Features:
    • JWT token management
    • User session persistence
    • Login/logout functionality
    • Protected route handling
    • Auto-redirect on authentication failure

2. User Management Module (models/User.ts)

  • Purpose: User data model and authentication
  • Features:
    • User schema definition
    • Password hashing with bcrypt
    • Password comparison methods
    • Username uniqueness validation

3. Query Management Module (models/LaptopQuery.ts)

  • Purpose: Laptop repair request data model
  • Features:
    • Comprehensive query schema
    • Status tracking (pending, resolved, not_resolved)
    • Priority levels (low, medium, high, urgent)
    • Cost management (estimated vs actual)
    • Timestamp tracking

4. API Layer

Authentication APIs (pages/api/auth/)

  • login.ts: User authentication endpoint
  • logout.ts: User logout endpoint
  • me.ts: Current user information
  • init-users.ts: Initialize default users
  • reset-users.ts: Reset user database

Query APIs (pages/api/queries/)

  • index.ts: Main CRUD operations for queries
  • [id].ts: Individual query operations
  • pending.ts: Fetch pending queries
  • resolved.ts: Fetch resolved queries

Debug APIs (pages/api/debug/)

  • db-status.ts: Database connection status
  • env-check.ts: Environment variable validation
  • test-login.ts: Authentication testing

5. UI Components Module

Core Components (components/)

  • Layout.tsx: Main application layout wrapper
  • Navigation.tsx: Navigation bar with user actions
  • ProtectedRoute.tsx: Route protection wrapper

Feature Components

  • AddLaptopQuery.tsx: New repair request form
  • ListSection.tsx: Pending queries display
  • ResolvedSection.tsx: Resolved queries display

6. Database Module (lib/mongoose.ts)

  • Purpose: MongoDB connection management
  • Features:
    • Connection pooling
    • Error handling
    • Environment-based configuration

7. Utility Scripts (scripts/)

  • Database initialization and maintenance scripts
  • User management utilities
  • Connection testing tools

🧩 Component Structure

AddLaptopQuery Component

interface AddLaptopQueryProps {
  onQueryAdded: () => void
}
  • Purpose: Form for submitting new repair requests
  • Features: Real-time validation, success/error messaging, responsive design

ListSection Component

interface ListSectionProps {
  onQueryUpdated: () => void
}
  • Purpose: Display and manage pending queries
  • Features: Status updates, priority filtering, cost tracking

ResolvedSection Component

  • Purpose: Display completed repair requests
  • Features: Resolution details, cost analysis, completion statistics

Navigation Component

  • Purpose: Main navigation and user management
  • Features: User profile, logout functionality, responsive menu

πŸ”Œ API Endpoints

Authentication Endpoints

Method Endpoint Description
POST /api/auth/login User authentication
POST /api/auth/logout User logout
GET /api/auth/me Get current user
POST /api/auth/init-users Initialize users

Query Management Endpoints

Method Endpoint Description
GET /api/queries Get all queries
POST /api/queries Create new query
GET /api/queries/[id] Get specific query
PUT /api/queries/[id] Update query
DELETE /api/queries/[id] Delete query
GET /api/queries/pending Get pending queries
GET /api/queries/resolved Get resolved queries

Debug Endpoints

Method Endpoint Description
GET /api/debug/db-status Database status
GET /api/debug/env-check Environment check
POST /api/debug/test-login Test authentication

πŸ“Š Workflow Chart

graph TD
    A[πŸš€ Application Start] --> B{πŸ‘€ User Authenticated?}
    
    B -->|No| C[πŸ” Login Page]
    B -->|Yes| D[🏠 Dashboard]
    
    C --> E[πŸ“ Enter Credentials]
    E --> F{βœ… Valid Credentials?}
    F -->|No| G[❌ Show Error]
    G --> E
    F -->|Yes| H[🎯 Generate JWT Token]
    H --> I[πŸ’Ύ Store Auth State]
    I --> D
    
    D --> J[πŸ“‹ Main Navigation]
    J --> K{🎯 User Action}
    
    K -->|Add Query| L[πŸ“ Add Laptop Query Form]
    K -->|View Pending| M[πŸ“‹ List Pending Queries]
    K -->|View Resolved| N[βœ… Resolved Queries]
    K -->|Logout| O[πŸšͺ Logout Process]
    
    L --> P[πŸ“Š Form Validation]
    P --> Q{βœ”οΈ Valid Data?}
    Q -->|No| R[⚠️ Show Validation Error]
    R --> L
    Q -->|Yes| S[πŸ“€ Submit to API]
    S --> T[πŸ’Ύ Save to MongoDB]
    T --> U[πŸ”„ Update UI]
    U --> D
    
    M --> V[πŸ” Fetch Pending Queries]
    V --> W[πŸ“Š Display Query List]
    W --> X{πŸ› οΈ Update Query?}
    X -->|Yes| Y[✏️ Edit Query Form]
    X -->|No| D
    
    Y --> Z[πŸ“ Update Form]
    Z --> AA[πŸ“€ Submit Update]
    AA --> BB[πŸ’Ύ Update MongoDB]
    BB --> CC[πŸ”„ Refresh List]
    CC --> W
    
    N --> DD[πŸ” Fetch Resolved Queries]
    DD --> EE[πŸ“Š Display Resolved List]
    EE --> FF{πŸ“ˆ View Details?}
    FF -->|Yes| GG[πŸ“‹ Show Query Details]
    FF -->|No| D
    GG --> EE
    
    O --> HH[πŸ—‘οΈ Clear Auth Token]
    HH --> II[πŸ’Ύ Clear User State]
    II --> JJ[πŸ”„ Redirect to Login]
    JJ --> C
    
    style A fill:#e1f5fe
    style B fill:#fff3e0
    style C fill:#fce4ec
    style D fill:#e8f5e8
    style L fill:#f3e5f5
    style M fill:#e0f2f1
    style N fill:#e3f2fd
    style O fill:#fff8e1
Loading

Detailed Workflow Explanation

πŸ” Authentication Flow

  1. Application Start: User visits the application
  2. Authentication Check: System verifies if user has valid JWT token
  3. Login Process: If not authenticated, redirect to login page
  4. Credential Validation: Server validates username/password against MongoDB
  5. Token Generation: Create JWT token with user information
  6. State Management: Store authentication state in React context

πŸ“ Query Management Flow

  1. Query Submission:

    • User fills out repair request form
    • Client-side validation checks required fields
    • Data submitted to /api/queries endpoint
    • Server validates and saves to MongoDB
    • UI updates with success/error message
  2. Query Listing:

    • Fetch queries from database based on status filter
    • Display in organized list with search/filter capabilities
    • Real-time updates when queries are modified
  3. Query Updates:

    • Admin can update query status, priority, costs
    • Changes immediately reflected in database
    • UI updates without page refresh

πŸ”„ Data Flow Architecture

  1. Frontend β†’ API: User interactions trigger API calls
  2. API β†’ Database: API routes handle business logic and database operations
  3. Database β†’ API: MongoDB returns requested data
  4. API β†’ Frontend: Formatted response sent to client
  5. Frontend Update: React components re-render with new data

πŸ›‘οΈ Security Flow

  1. Request Intercepting: All protected routes check for valid JWT
  2. Token Validation: Server validates token signature and expiration
  3. User Context: Authenticated user data available throughout app
  4. Auto-logout: Invalid/expired tokens trigger automatic logout

πŸš€ Installation

Prerequisites

  • Node.js 18+ installed
  • MongoDB database (local or cloud)
  • Git for version control

Steps

  1. Clone the repository:
git clone https://github.com/techbizloanindia/TechFix-Pro---Next-Gen-Laptop-Repair-Management.git
cd laptop-repair-management
  1. Install dependencies:
npm install
  1. Environment setup:
cp .env.example .env.local
  1. Configure environment variables (see Environment Variables)

  2. Initialize database:

npm run init-db
  1. Start development server:
npm run dev
  1. Open application: Visit http://localhost:3000

πŸ“– Usage

Default Login Credentials

  • Username: admin
  • Password: admin123

Creating New Repair Requests

  1. Navigate to "Add Query" tab
  2. Fill out the repair request form:
    • Customer name
    • Laptop brand/model
    • Issue description
    • Contact information (optional)
  3. Submit the form
  4. Query will appear in "Pending" section

Managing Queries

  1. View pending queries in "List" tab
  2. Update status, priority, or costs as needed
  3. Mark queries as resolved with resolution details
  4. View completed repairs in "Resolved" tab

Admin Functions

  • User management through API endpoints
  • Database maintenance scripts
  • System status monitoring

πŸ”§ Environment Variables

Create a .env.local file in the root directory:

# Database Configuration
MONGODB_URI=mongodb://localhost:27017/laptop-repair-db
# or for MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:[email protected]/laptop-repair-db

# Authentication
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRES_IN=7d

# Application
NEXT_PUBLIC_APP_URL=http://localhost:3000
NODE_ENV=development

# Optional: For production deployment
NEXTAUTH_URL=https://your-domain.com
NEXTAUTH_SECRET=your-nextauth-secret

Environment Variable Descriptions

  • MONGODB_URI: MongoDB connection string
  • JWT_SECRET: Secret key for JWT token signing
  • JWT_EXPIRES_IN: JWT token expiration time
  • NEXT_PUBLIC_APP_URL: Application URL for client-side requests
  • NODE_ENV: Environment mode (development/production)

πŸ“œ Scripts

Available npm scripts:

# Development
npm run dev          # Start development server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint

# Database Management
npm run init-db      # Initialize database with default users
npm run reset-db     # Reset database (caution: deletes all data)
npm run check-db     # Check database connection

# Testing
npm run test-auth    # Test authentication endpoints
npm run test-db      # Test database connection

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes with proper TypeScript types
  4. Test your changes thoroughly
  5. Commit with descriptive messages: git commit -m 'Add amazing feature'
  6. Push to your branch: git push origin feature/amazing-feature
  7. Create a Pull Request

Code Standards

  • Use TypeScript for all new code
  • Follow ESLint configuration
  • Write meaningful component and function names
  • Add proper error handling
  • Include JSDoc comments for complex functions
  • Ensure responsive design with Tailwind CSS

Testing Guidelines

  • Test all API endpoints with various input scenarios
  • Verify authentication flows work correctly
  • Check responsive design on multiple screen sizes
  • Validate form inputs and error handling

πŸ“ License

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

πŸ™ Acknowledgments

  • Next.js team for the amazing framework
  • MongoDB team for the robust database solution
  • Tailwind CSS for the utility-first CSS framework
  • React team for the powerful frontend library
  • All contributors who help improve this project

Built with ❀️ by Nitish Singh

Transform your laptop repair business with professional management tools.

About

TechFix Pro is a feature-rich laptop repair management system built with Next.js, TypeScript, MongoDB, React, and Tailwind CSS. It supports JWT-based secure authentication, real-time repair request tracking with priority and cost management, dashboard analytics, and responsive design

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •