A modern, full-stack inventory management application built with Next.js, Express.js, and MySQL. Track products in real-time with an intuitive dashboard and secure admin authentication.
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Installation
- Environment Configuration
- Running the Application
- API Endpoints
- Project Pages
- Contributing
- License
- π¦ Real-time Inventory Tracking - Monitor product stock levels instantly
- π Secure Admin Authentication - JWT-based authentication with password hashing
- π Interactive Dashboard - Admin dashboard for managing products
- ποΈ Product Management - Add, update, and delete products
- π Modern UI - Beautiful Next.js frontend with Tailwind CSS
- π RESTful API - Comprehensive backend API for all operations
- π± Responsive Design - Works seamlessly on desktop and mobile devices
- Next.js 14.2 - React framework with file-based routing
- React 18.3 - UI library
- Tailwind CSS 3.4 - Utility-first CSS framework
- Axios - HTTP client for API calls
- ESLint - Code quality and style
- Express.js 5.2 - Node.js web framework
- MySQL2 - MySQL database driver
- JWT (jsonwebtoken) - Token-based authentication
- Bcrypt - Password hashing
- CORS - Cross-origin resource sharing
- Dotenv - Environment variable management
- MySQL 8.0+ - Relational database
ShopHub/
βββ backend/
β βββ middleware/
β β βββ auth.js # JWT authentication middleware
β βββ routes/
β β βββ auth.js # Authentication endpoints
β β βββ products.js # Product management endpoints
β βββ db.js # Database connection
β βββ server.js # Express server setup
β βββ seed.js # Database seeding script
β βββ prisma.config.ts # Prisma configuration
β βββ package.json # Backend dependencies
β βββ .gitignore # Git ignore file
β
βββ inventory-app/
β βββ app/
β β βββ dashboard/
β β β βββ page.js # Admin dashboard page
β β βββ login/
β β β βββ page.js # Login page
β β βββ products/
β β β βββ page.js # Products listing page
β β βββ layout.js # Root layout
β β βββ page.js # Home page
β β βββ globals.css # Global styles
β βββ lib/
β β βββ api.js # API client functions
β βββ public/ # Static assets
β βββ package.json # Frontend dependencies
β βββ next.config.mjs # Next.js configuration
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ jsconfig.json # JavaScript config
β
βββ .gitignore # Root git ignore
βββ README.md # This file
Before you begin, ensure you have the following installed:
- Node.js (v18.0 or higher) - Download
- npm or yarn - Comes with Node.js
- MySQL (v8.0 or higher) - Download
- Git - Download
git clone https://github.com/its-harsh-here/ShopHub.git
cd ShopHubNavigate to backend directory and install dependencies:
cd backend
npm installNavigate to inventory-app directory and install dependencies:
cd ../inventory-app
npm installCreate a .env file in the backend/ directory:
# Database Configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=shopHub
# JWT Configuration
JWT_SECRET=your_super_secret_jwt_key_here
# Server Configuration
PORT=5000Note: Keep your .env file secure and never commit it to version control.
Create a .env.local file in the inventory-app/ directory:
NEXT_PUBLIC_API_URL=http://localhost:5000/apicd backend
npm startThe backend server will start on http://localhost:5000
Expected output:
Server running on port 5000
In a new terminal, navigate to the frontend directory:
cd inventory-app
npm run devThe frontend will start on http://localhost:3000
Open http://localhost:3000 in your browser.
Before running the application, ensure your MySQL database is set up:
# Using MySQL command line
mysql -u root -p
# Create database
CREATE DATABASE shopHub;
USE shopHub;
# Create tables (run the schema from seed.js or create manually)
# Refer to the schema in backend/seed.js for table structure| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/login |
Admin login | β No |
| POST | /api/auth/register |
Admin registration | β No |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/products |
Get all products | β No |
| POST | /api/products |
Add new product | β Yes |
| PUT | /api/products/:id |
Update product | β Yes |
| DELETE | /api/products/:id |
Delete product | β Yes |
Login
POST /api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "password123"
}
Response: 200 OK
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Get Products
GET /api/products
Response: 200 OK
[
{
"id": 1,
"name": "Product Name",
"description": "Product description",
"price": 29.99,
"quantity": 50
}
]- Home (
/) - Landing page with ShopHub intro and navigation - Login (
/login) - Admin authentication page - Products (
/products) - Public product listing - Dashboard (
/dashboard) - Admin dashboard for product management
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
For issues, questions, or suggestions, please open an issue on the GitHub repository.
Happy coding! π
Built with β€οΈ using modern web technologies.