Starting Development
This guide will walk you through setting up your development environment and getting Byte Bandit running locally on your machine.
Prerequisites Check
Before proceeding, ensure you have all the required tools installed:
# Check Java version (should be 17+)
java -version
# Check Maven version (should be 3.6+)
mvn --version
# Check Node.js version (should be 18+)
node --version
npm --version
# Check Docker version
docker --version
docker-compose --version
# Check Git version
git --version
If any of these commands fail, please refer to the Before You Start guide for installation instructions.
Initial Setup
1. Fork and Clone the Repository
- Fork the repository on GitHub:
- Go to https://github.com/Learnathon-By-Geeky-Solutions/byte-bandit
-
Click the "Fork" button to create your copy
-
Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/byte-bandit.git cd byte-bandit
-
Add upstream remote for syncing with the main repository:
git remote add upstream https://github.com/Learnathon-By-Geeky-Solutions/byte-bandit.git
2. Environment Configuration
-
Create environment file:
cp .env.example .env
-
Edit
.env
file with your configuration:# Required: Database Configuration POSTGRES_PASSWORD=postgres POSTGRES_USER=postgres POSTGRES_DB=postgres # Required: JWT Configuration JWT_SECRET=your-super-secret-jwt-key-here # Required: CORS Configuration CORS_ALLOWED_ORIGINS=http://localhost:3000 # Optional: Email Configuration (for development) MAIL_USER_NAME=user@example.com MAIL_PASSWORD=securepassword # Optional: Google OAuth (if implementing OAuth) GOOGLE_OAUTH_CLIENT_ID=[Your Google Client ID] GOOGLE_OAUTH_CLIENT_SECRET=[Your Google Client Secret] GOOGLE_OAUTH_REDIRECT_URI=http://localhost:8084/api/v1/auth/google/callback # Optional: AWS S3 (for file storage) AWS_ACCESS_KEY_ID=[Your AWS Access Key ID] AWS_SECRET_ACCESS_KEY=[Your AWS Secret Access Key] AWS_REGION=[Your AWS Region] BUCKET_NAME=[Your AWS Bucket Name]
Note: For local development, you can use the default values for database and JWT. The other configurations are optional and can be added later.
Backend Development Setup
1. Build Backend Services
-
Navigate to backend directory:
cd apps/backend
-
Build all services:
mvn clean install
This command will: - Download all dependencies - Compile all services - Run tests - Install artifacts to local Maven repository
- Verify build success:
# Check if all services built successfully ls -la */target/*.jar
2. Configure IntelliJ IDEA (Recommended)
- Open the project in IntelliJ IDEA:
- File → Open → Select the
byte-bandit
folder -
Wait for project indexing to complete
-
Install CheckStyle plugin:
- Go to Preferences → Plugins
- Search for "CheckStyle-IDEA"
-
Install and restart IntelliJ
-
Configure CheckStyle:
- Go to Preferences → Tools → CheckStyle
- Add new configuration: Select
checkstyle.xml
fromapps/backend/
-
Name it "checkstyle" and set as active
-
Import code style:
- Go to Preferences → Editor → Code Style
- Click gear icon → Import Scheme → IntelliJ IDEA code style XML
- Select
IdeaJavaCodeStyle.xml
from.idea/codeStyles/
3. Run Backend Services Locally
Option A: Using Docker Compose (Recommended)
-
Start infrastructure services:
cd ../../ # Return to project root docker-compose -f docker-compose.apps.yml up -d discovery-server config-server user-dev-db file-dev-db mailhog kafka zookeeper
-
Wait for services to be ready:
# Check service status docker-compose -f docker-compose.apps.yml ps # Check logs for any errors docker-compose -f docker-compose.apps.yml logs discovery-server
-
Start backend services:
docker-compose -f docker-compose.apps.yml up -d gateway user-service file-service
Option B: Running Services Individually
-
Start Discovery Server:
cd apps/backend/discovery-server mvn spring-boot:run
-
Start Config Server (in new terminal):
cd apps/backend/config-server mvn spring-boot:run
-
Start User Service (in new terminal):
cd apps/backend/user-service mvn spring-boot:run
-
Start File Service (in new terminal):
cd apps/backend/file-service mvn spring-boot:run
-
Start Gateway (in new terminal):
cd apps/backend/gateway mvn spring-boot:run
4. Verify Backend Services
- Check service health:
- Discovery Server: http://localhost:8761
- Config Server: http://localhost:8071
- User Service: http://localhost:8083
- File Service: http://localhost:8081
-
Gateway: http://localhost:8084
-
Test API endpoints:
# Test gateway health curl http://localhost:8084/actuator/health # Test user service curl http://localhost:8083/actuator/health # Test file service curl http://localhost:8081/actuator/health
Frontend Development Setup
1. Install Dependencies
-
Navigate to web directory:
cd apps/web
-
Install Node.js dependencies:
npm install
-
Verify installation:
npm list --depth=0
2. Configure Development Environment
-
Create frontend environment file (if needed):
cp .env.example .env.local
-
Update environment variables:
# API Gateway URL NEXT_PUBLIC_API_URL=http://localhost:8084 # Development server port PORT=3000
3. Start Frontend Development Server
-
Start development server:
npm run dev
-
Verify frontend is running:
- Open http://localhost:3000 in your browser
- You should see the Byte Bandit application
Using the Service Management Script
For convenience, use the provided run-services.sh
script:
1. Make it executable:
chmod +x run-services.sh
2. Available commands:
# Start all services
./run-services.sh start all
# Start only backend services
./run-services.sh start backend
# Start only infrastructure
./run-services.sh start infra
# Check service status
./run-services.sh ps
# Stop all services
./run-services.sh stop
# Restart specific service
./run-services.sh restart gateway
# View logs
./run-services.sh logs gateway
# Get help
./run-services.sh -h
Development Workflow
1. Daily Development Routine
-
Sync with upstream:
git fetch upstream git checkout develop git merge upstream/develop
-
Create feature branch:
git checkout -b feature/your-feature-name
-
Make changes and test:
# Backend changes cd apps/backend mvn test # Frontend changes cd apps/web npm test
-
Commit and push:
git add . git commit -m "feat(scope): description of changes" git push origin feature/your-feature-name
2. Running Tests
Backend Tests
cd apps/backend
# Run all tests
mvn test
# Run specific service tests
cd user-service
mvn test
# Run with coverage
mvn jacoco:report
Frontend Tests
cd apps/web
# Run unit tests
npm test
# Run tests in watch mode
npm test -- --watch
# Run tests with coverage
npm test -- --coverage
3. Code Quality Checks
Backend Quality
cd apps/backend
# Run Checkstyle
mvn checkstyle:check
# Run SonarQube analysis
mvn sonar:sonar
Frontend Quality
cd apps/web
# Run ESLint
npm run lint
# Run type checking
npm run type-check
# Format code
npm run format
Troubleshooting
Common Issues and Solutions
1. Port Already in Use
# Find process using port
lsof -i :8084
# Kill process
kill -9 <PID>
2. Database Connection Issues
# Check if PostgreSQL is running
docker ps | grep postgres
# Restart database
docker-compose -f docker-compose.apps.yml restart user-dev-db file-dev-db
3. Maven Build Failures
# Clean and rebuild
mvn clean install -U
# Check Java version compatibility
java -version
4. Node.js Issues
# Clear npm cache
npm cache clean --force
# Remove node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
5. Docker Issues
# Clean Docker environment
docker system prune -a
# Rebuild images
docker-compose -f docker-compose.apps.yml build --no-cache
Getting Help
-
Check service logs:
docker-compose -f docker-compose.apps.yml logs [service-name]
-
Verify service health:
- Check individual service health endpoints
-
Review Eureka dashboard at http://localhost:8761
-
Check configuration:
- Verify
.env
file settings - Check
bootstrap.yaml
configurations - Review Docker Compose service definitions
Next Steps
- Explore the codebase using the Project Structure guide
- Follow coding standards from the Code Style guide
- Understand Git workflow from the Branching Strategy guide
- Start with a small issue to get familiar with the development process
- Join team discussions and code reviews
Development Tips
- Use IntelliJ IDEA with CheckStyle plugin for consistent Java code
- Run tests frequently to catch issues early
- Follow the branching strategy for organized development
- Update documentation when making significant changes
- Ask questions during code reviews - it's how we all learn