Skip to content

Latest commit

Β 

History

History
465 lines (348 loc) Β· 7.27 KB

File metadata and controls

465 lines (348 loc) Β· 7.27 KB

DayFlow HRMS - Available Commands Reference

πŸ“‹ Quick Command Reference

Windows Users

Installation

# Automated installation (RECOMMENDED)
install.bat

# Manual installation
cd backend
npm install
cd ..\frontend
npm install

Starting the Application

# Automated startup (RECOMMENDED)
start-dayflow.bat

# Manual startup - Backend
cd backend
npm run dev

# Manual startup - Frontend (in separate terminal)
cd frontend
npm start

Mac/Linux Users

Installation

# Automated installation (RECOMMENDED)
chmod +x install.sh
./install.sh

# Manual installation
cd backend
npm install
cd ../frontend
npm install

Starting the Application

# Automated startup (RECOMMENDED)
chmod +x start-dayflow.sh
./start-dayflow.sh

# Manual startup - Backend
cd backend
npm run dev

# Manual startup - Frontend (in separate terminal)
cd frontend
npm start

πŸ› οΈ Development Commands

Backend Commands (from /backend directory)

# Start development server with auto-reload
npm run dev

# Start production server
npm start

# Install a new package
npm install <package-name>

# Update all packages
npm update

Frontend Commands (from /frontend directory)

# Start development server
npm start

# Create production build
npm run build

# Run tests
npm test

# Install a new package
npm install <package-name>

πŸ—„οΈ MongoDB Commands

Windows

# Start MongoDB
net start MongoDB

# Stop MongoDB
net stop MongoDB

# Check status - Go to Services (Win+R, type services.msc)

Mac/Linux

# Start MongoDB
sudo systemctl start mongod

# Stop MongoDB
sudo systemctl stop mongod

# Check status
sudo systemctl status mongod

# Restart MongoDB
sudo systemctl restart mongod

MongoDB Shell

# Connect to MongoDB
mongosh

# Show databases
show dbs

# Use DayFlow database
use dayflow

# Show collections
show collections

# View all employees
db.employees.find()

# Count documents
db.employees.countDocuments()

# Exit MongoDB shell
exit

🧹 Cleanup Commands

Clear node_modules and reinstall

Backend:

cd backend
rm -rf node_modules package-lock.json  # Mac/Linux
# OR
rmdir /s node_modules && del package-lock.json  # Windows
npm install

Frontend:

cd frontend
rm -rf node_modules package-lock.json  # Mac/Linux
# OR
rmdir /s node_modules && del package-lock.json  # Windows
npm install

Clear MongoDB database

mongosh
use dayflow
db.dropDatabase()
exit

πŸ”§ Environment Configuration

Backend Environment Variables (.env)

# Edit backend/.env file
notepad backend\.env  # Windows
nano backend/.env     # Mac/Linux

Required Variables:

PORT=5000
MONGODB_URI=mongodb://localhost:27017/dayflow
JWT_SECRET=your_secret_key_change_this
JWT_EXPIRE=7d
NODE_ENV=development

🌐 Access URLs

Service URL Description
Frontend http://localhost:3000 React app
Backend API http://localhost:5000 Express server
API Health http://localhost:5000/api/health Health check
MongoDB mongodb://localhost:27017 Database

πŸ“‘ Testing API Endpoints

Using curl

Check server health:

curl http://localhost:5000/api/health

Sign up:

curl -X POST http://localhost:5000/api/auth/signup \
  -H "Content-Type: application/json" \
  -d '{
    "employeeId": "EMP001",
    "email": "test@test.com",
    "password": "test123",
    "firstName": "Test",
    "lastName": "User",
    "role": "Employee"
  }'

Sign in:

curl -X POST http://localhost:5000/api/auth/signin \
  -H "Content-Type: application/json" \
  -d '{
    "email": "test@test.com",
    "password": "test123"
  }'

Using Postman or Thunder Client

Import the following base URL: http://localhost:5000/api

Headers for authenticated requests:

Authorization: Bearer <your-jwt-token>
Content-Type: application/json

πŸ› Debugging Commands

Check if ports are in use

Windows:

netstat -ano | findstr :5000
netstat -ano | findstr :3000

Mac/Linux:

lsof -i :5000
lsof -i :3000

Kill process on port

Windows:

# Find PID from netstat command, then:
taskkill /PID <PID> /F

Mac/Linux:

# Kill process on port 5000
kill -9 $(lsof -ti:5000)

# Kill process on port 3000
kill -9 $(lsof -ti:3000)

View logs

Backend logs:

cd backend
# Logs appear in the terminal running npm run dev

Frontend logs:

  • Open browser console (F12)
  • Or check terminal running npm start

πŸš€ Production Build

Build frontend for production

cd frontend
npm run build

# Files will be in frontend/build/

Run backend in production mode

cd backend
NODE_ENV=production npm start

πŸ“¦ Package Management

Check for outdated packages

Backend:

cd backend
npm outdated

Frontend:

cd frontend
npm outdated

Update packages

# Update all packages
npm update

# Update specific package
npm update <package-name>

# Install latest version
npm install <package-name>@latest

πŸ” Useful npm Commands

# View installed packages
npm list --depth=0

# Check npm version
npm --version

# Clear npm cache
npm cache clean --force

# Audit for vulnerabilities
npm audit

# Fix vulnerabilities
npm audit fix

🎯 Git Commands (If using version control)

# Initialize git repository
git init

# Add all files
git add .

# Commit changes
git commit -m "Initial commit"

# Create .gitignore (already provided)
# It excludes node_modules, .env, etc.

# Push to GitHub
git remote add origin <your-repo-url>
git push -u origin main

πŸ“Š Database Backup

Backup MongoDB database

mongodump --db dayflow --out ./backup

# Restore from backup
mongorestore --db dayflow ./backup/dayflow

πŸ”’ Security Commands

Generate new JWT secret

# Generate random string
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"

# Copy output and paste into backend/.env as JWT_SECRET

πŸ“± Mobile Testing

Access from mobile device (same network)

  1. Find your computer's IP address:

Windows:

ipconfig
# Look for IPv4 Address

Mac/Linux:

ifconfig
# Look for inet address
  1. On mobile browser, open: http://<your-ip>:3000

Example: http://192.168.1.100:3000


πŸ†˜ Emergency Commands

Complete reset (start fresh)

# Stop all servers (Ctrl+C in terminals)

# Delete all node_modules
cd backend
rm -rf node_modules package-lock.json
cd ../frontend
rm -rf node_modules package-lock.json

# Reinstall everything
cd ..
# Windows: install.bat
# Mac/Linux: ./install.sh

# Clear MongoDB database
mongosh
use dayflow
db.dropDatabase()
exit

# Restart everything
# Windows: start-dayflow.bat
# Mac/Linux: ./start-dayflow.sh

πŸ’‘ Pro Tips

  1. Always start MongoDB first before starting the backend
  2. Use separate terminals for backend and frontend
  3. Check logs if something doesn't work
  4. Clear browser cache if UI doesn't update
  5. Restart servers after changing .env files

Need more help? Check: