This guide will help you set up FocusMaster locally for development.
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher) - Download
- npm (comes with Node.js)
- MongoDB - Either:
- Local MongoDB installation, OR
- MongoDB Atlas account (free tier) - Sign up
- Git - Download
- Spotify Developer Account - For music integration
- Google Cloud Console Project - For Google OAuth
git clone https://github.com/codxbrexx/FocusMaster.git
cd FocusMasternpm installcd backend
npm installCreate a .env file in the backend directory:
PORT=5000
MONGO_URI=mongodb://localhost:27017/focusmaster
NODE_ENV=development
JWT_SECRET=your_super_secret_jwt_key_here
GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
FRONTEND_URL=http://localhost:5173
# Optional: Spotify Integration
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=http://localhost:5000/api/spotify/callbackOpen a new terminal window:
cd frontend
npm installCreate a .env file in the frontend directory:
VITE_API_URL=http://localhost:5000/api
VITE_GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com# Install MongoDB (Ubuntu/Debian)
sudo apt-get install mongodb
# Start MongoDB service
sudo systemctl start mongodb
# Verify it's running
sudo systemctl status mongodbYour connection string: mongodb://localhost:27017/focusmaster
- Go to MongoDB Atlas
- Create a free cluster
- Click "Connect" → "Connect your application"
- Copy the connection string
- Replace
<password>with your database password - Use this string in
MONGO_URI
Example: mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/focusmaster?retryWrites=true&w=majority
- Go to Google Cloud Console
- Create a new project or select existing
- Enable "Google+ API"
- Go to "Credentials" → "Create Credentials" → "OAuth client ID"
- Configure OAuth consent screen
- Set authorized redirect URIs:
http://localhost:5173http://localhost:5000
- Copy the Client ID
- Add to both backend and frontend
.envfiles
- Go to Spotify Developer Dashboard
- Create a new app
- Set redirect URI:
http://localhost:5000/api/spotify/callback - Copy Client ID and Client Secret
- Add to backend
.envfile
You need to run both backend and frontend servers.
cd backend
npm run devThe backend will start on http://localhost:5000
cd frontend
npm run devThe frontend will start on http://localhost:5173
Open your browser and navigate to:
http://localhost:5173
To access the admin panel, you'll need an admin account.
cd backend
node src/scripts/createAdmin.jsFollow the prompts to create an admin user.
- Register a normal user account
- Connect to MongoDB
- Update the user's role:
// In MongoDB shell or Compass
db.users.updateOne(
{ email: "your@email.com" },
{ $set: { role: "admin" } }
)cd backend
npm testcd frontend
npm testnpm test -- --watchFocusMaster/
├── backend/ # Node.js + Express API
│ ├── src/
│ │ ├── controllers/ # Request handlers
│ │ ├── models/ # Database schemas
│ │ ├── routes/ # API routes
│ │ ├── middleware/ # Express middleware
│ │ └── server.js # Entry point
│ └── package.json
│
├── frontend/ # React + TypeScript app
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── store/ # Zustand stores
│ │ ├── services/ # API services
│ │ └── App.tsx # Root component
│ └── package.json
│
└── docs/ # Documentation
# Check if port 5000 is already in use
lsof -i :5000
# Kill the process if needed
kill -9 <PID>
# Check MongoDB connection
mongosh # or mongo# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Check for port conflicts
lsof -i :5173- Verify MongoDB is running:
sudo systemctl status mongodb - Check
MONGO_URIin.envfile - Ensure network access in MongoDB Atlas if using cloud
- Ensure
.envfiles are in the correct directories - Don't commit
.envfiles (they're in.gitignore) - Restart the dev servers after changing
.envfiles
Now that you have FocusMaster running:
- Explore the API Documentation
- Read the Development Workflow
- Check out the Architecture Overview
- Review Testing Guide
- Start contributing! See Contributing Guidelines
- Issues: Open an issue on GitHub
- Documentation: Check the docs folder
- Troubleshooting: See Troubleshooting Guide
**Happy Coding! **