Installation guide
This guide provides comprehensive instructions for installing and configuring SmartShelf in development and production environments.System requirements
Minimum requirements
- Node.js: Version 18.0.0 or higher
- MongoDB: Version 6.0 or higher
- RAM: 4GB minimum (8GB recommended)
- Storage: 500MB for application files, additional space for database
- Operating System: Windows 10+, macOS 10.15+, or Linux (Ubuntu 20.04+)
Development tools
- Git: For version control
- npm or yarn: Package manager (npm comes with Node.js)
- Code editor: VS Code, WebStorm, or similar
- MongoDB Compass: (Optional) GUI for database management
- Postman: (Optional) For API testing
For production deployments, consider using PM2 for process management and NGINX as a reverse proxy.
MongoDB setup
You can use either a local MongoDB installation or MongoDB Atlas (cloud-hosted).Option 1: Local MongoDB installation
Download MongoDB
Download MongoDB Community Server from mongodb.com/try/download/community
Option 2: MongoDB Atlas (cloud)
Create Atlas account
Sign up for a free account at mongodb.com/cloud/atlas
Create a cluster
- Click “Build a Cluster”
- Choose the free tier (M0)
- Select your preferred cloud provider and region
- Click “Create Cluster”
Create database user
- Navigate to “Database Access”
- Click “Add New Database User”
- Choose “Password” authentication
- Set username and password
- Grant “Read and write to any database” privilege
Whitelist IP address
- Navigate to “Network Access”
- Click “Add IP Address”
- For development, click “Allow Access from Anywhere” (0.0.0.0/0)
- For production, add your specific IP addresses
Backend installation
Install dependencies
express@^4.18.2- Web frameworkmongoose@^8.0.0- MongoDB ODMbcryptjs@^2.4.3- Password hashingjsonwebtoken@^9.0.2- JWT authenticationdotenv@^16.3.1- Environment variable managementcors@^2.8.5- Cross-origin resource sharinghelmet@^7.1.0- Security headersexpress-validator@^7.0.1- Input validationexpress-rate-limit@^7.1.5- Rate limitingcookie-parser@^1.4.6- Cookie parsing
Configure environment variables
Edit the
.env file with your configuration:JWT_SECRET: Generate a strong secret using
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Frontend installation
Install dependencies
react@^19.1.1- UI libraryreact-dom@^19.1.1- React DOM renderingtypescript@~5.8.2- Type safetyvite@^6.2.0- Build tool@vitejs/plugin-react@^5.0.0- React plugin for Vite- Tailwind CSS (configured in the project)
Verification steps
Verify your installation is working correctly:Check frontend access
Navigate to
http://localhost:5173 in your browser. You should see the SmartShelf login page.Test user registration
- Click “Register”
- Fill in the registration form
- Submit and verify you’re redirected to the dashboard
Troubleshooting
Backend issues
Port 5000 already in use
Port 5000 already in use
Change the
PORT variable in your backend .env file to a different port (e.g., 5001), and update the frontend VITE_API_URL accordingly.MongoDB connection failed
MongoDB connection failed
For local MongoDB:
- Verify MongoDB service is running
- Check if MongoDB is listening on port 27017:
netstat -an | grep 27017 - Try connecting with
mongoshto verify MongoDB is accessible
- Verify your IP address is whitelisted
- Check username and password in connection string
- Ensure special characters in password are URL-encoded
JWT errors
JWT errors
- Ensure
JWT_SECRETis at least 32 characters long - Clear browser cookies and try logging in again
- Verify the secret hasn’t changed between backend restarts
CORS errors
CORS errors
- Verify
CLIENT_URLin backend.envmatches your frontend URL - Check for typos in the URL (trailing slashes matter)
- Clear browser cache and reload
Frontend issues
API requests failing
API requests failing
- Verify
VITE_API_URLin.envis correct - Check backend is running and accessible
- Open browser DevTools Network tab to see specific errors
- Ensure you’re using
/apisuffix in the URL
Build errors
Build errors
- Delete
node_modulesand runnpm installagain - Clear Vite cache:
rm -rf node_modules/.vite - Check for TypeScript errors:
npm run build
Blank page or white screen
Blank page or white screen
- Check browser console for JavaScript errors
- Verify all environment variables are set
- Try clearing browser cache and cookies
- Ensure you’re using a modern browser (Chrome, Firefox, Safari, Edge)
Database issues
MongoDB won't start
MongoDB won't start
Windows:
- Run services.msc and check MongoDB service status
- Try starting manually:
net start MongoDB
- Check status:
brew services list - View logs:
tail -f /usr/local/var/log/mongodb/mongo.log
- Check status:
sudo systemctl status mongod - View logs:
sudo journalctl -u mongod
Cannot connect to MongoDB Atlas
Cannot connect to MongoDB Atlas
- Verify cluster is running (not paused)
- Check Network Access IP whitelist
- Ensure database user has correct permissions
- Test connection string with MongoDB Compass
Production deployment
For production deployment, consider:- Use PM2 for process management:
npm install -g pm2 - Set
NODE_ENV=productionin backend.env - Use a reverse proxy like NGINX
- Enable HTTPS with SSL certificates
- Use a proper MongoDB cluster with replica sets
- Implement monitoring and logging (e.g., Winston, Morgan)
- Set up automated backups for MongoDB
- Use environment-specific configuration
Next steps
Now that SmartShelf is installed:User management
Learn how to create and manage users
Inventory management
Start adding and tracking inventory items
API reference
Explore the REST API endpoints
Environment variables
Customize SmartShelf for your needs