Athena — mahmoud-consultancy/archive/old-docs/setup/DEVELOPMENT_SETUP.md

Development Setup Guide

Prerequisites

Required Software

Recommended Tools

  • IntelliJ IDEA or VS Code with Java extensions
  • Postman or Insomnia for API testing
  • DBeaver or H2 Console for database management
  • Docker Desktop (optional, for containerization)

Quick Start

1. Clone the Repository

git clone https://github.com/glorylabs/recruitment-platform.git
cd recruitment-platform

2. Start Backend (Spring Boot)

cd backend
mvn clean install
mvn spring-boot:run

Backend will run on: http://localhost:8080/api

3. Start Frontend (Angular)

cd frontend/recruitment-portal
npm install
npm start

Frontend will run on: http://localhost:4200

4. Start CMS (Astro.js)

cd website/website
npm install
npm run dev

CMS will run on: http://localhost:4321


Detailed Backend Setup

1. Configure Environment Variables

Create .env file in backend root:

# Firecrawl API
FIRECRAWL_API_KEY=your-firecrawl-api-key-here

# Database (for production)
DB_HOST=localhost
DB_PORT=5432
DB_NAME=recruitment
DB_USER=your-db-user
DB_PASSWORD=your-db-password

# JWT Secret (generate a secure key)
JWT_SECRET=your-very-secure-jwt-secret-key-here

# Application
SERVER_PORT=8080
SPRING_PROFILES_ACTIVE=dev

2. Install Dependencies

cd backend
mvn clean install

3. Database Setup

Development (H2 - Default)

No setup required. H2 runs in-memory automatically. Access H2 Console: http://localhost:8080/api/h2-console

  • JDBC URL: jdbc:h2:mem:testdb
  • Username: sa
  • Password: (leave empty)

Production (PostgreSQL)

-- Create database
CREATE DATABASE recruitment;

-- Create user
CREATE USER recruitment_user WITH PASSWORD 'secure_password';

-- Grant privileges
GRANT ALL PRIVILEGES ON DATABASE recruitment TO recruitment_user;

Update application.yml:

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/recruitment
    username: recruitment_user
    password: secure_password

4. Run Tests

mvn test

5. Build for Production

mvn clean package
java -jar target/recruitment-backend-0.0.1-SNAPSHOT.jar

Detailed Frontend Setup (Angular)

1. Install Dependencies

cd frontend/recruitment-portal
npm install

2. Configure Environment

Edit src/environments/environment.ts:

export const environment = {
  production: false,
  apiUrl: 'http://localhost:8080/api',
  firecrawlEnabled: true
};

Edit src/environments/environment.prod.ts:

export const environment = {
  production: true,
  apiUrl: 'https://api.glorylabs.nl/api',
  firecrawlEnabled: true
};

3. Development Server

npm start
# or
ng serve

4. Build for Production

npm run build
# or
ng build --configuration production

5. Run Tests

# Unit tests
npm test

# E2E tests
npm run e2e

6. Code Generation

# Generate component
ng generate component components/job-list

# Generate service
ng generate service services/job

# Generate module
ng generate module features/jobs

CMS Setup (Astro.js)

1. Install Dependencies

cd website/website
npm install

2. Development Server

npm run dev

3. Build for Production

npm run build

4. Preview Production Build

npm run preview

API Testing

Using cURL

# Test if backend is running
curl http://localhost:8080/api/jobs

# Search jobs
curl "http://localhost:8080/api/jobs/search?query=developer"

# Get job details
curl http://localhost:8080/api/jobs/1

Using Postman

  1. Import the collection from /docs/postman-collection.json
  2. Set environment variable base_url to http://localhost:8080/api
  3. Run the test suite

Database Management

H2 Console (Development)

  1. Navigate to: http://localhost:8080/api/h2-console
  2. JDBC URL: jdbc:h2:mem:testdb
  3. Username: sa
  4. Password: (empty)

Sample Data

-- Insert sample jobs
INSERT INTO jobs (title, company, location, type, category, level, description, active, created_at, published_at, expires_at)
VALUES
('Senior Java Developer', 'Tech Corp', 'Amsterdam', 'Full-time', 'IT', 'Senior', 'Great opportunity for experienced Java developer', true, NOW(), NOW(), NOW() + INTERVAL '30 days'),
('Marketing Manager', 'Marketing Pro', 'Rotterdam', 'Full-time', 'Marketing', 'Manager', 'Lead our marketing team', true, NOW(), NOW(), NOW() + INTERVAL '30 days'),
('Data Analyst', 'Data Company', 'Remote', 'Contract', 'Data', 'Mid-level', 'Analyze business data and create insights', true, NOW(), NOW(), NOW() + INTERVAL '30 days');

-- Insert sample users
INSERT INTO users (username, email, password, first_name, last_name, role, enabled, created_at)
VALUES
('admin', 'admin@glorylabs.nl', '$2a$10$encrypted_password_here', 'Admin', 'User', 'ADMIN', true, NOW()),
('recruiter', 'recruiter@glorylabs.nl', '$2a$10$encrypted_password_here', 'Recruiter', 'User', 'RECRUITER', true, NOW());

Troubleshooting

Backend Issues

Port Already in Use

# Find process using port 8080
lsof -i :8080  # Mac/Linux
netstat -ano | findstr :8080  # Windows

# Kill the process or change port in application.yml
server:
  port: 8081

Maven Dependencies Not Downloading

# Clear Maven cache
rm -rf ~/.m2/repository
mvn clean install -U

Database Connection Issues

  • Check PostgreSQL is running: pg_isready
  • Verify credentials in application.yml
  • Check firewall settings

Frontend Issues

Angular CLI Not Found

npm install -g @angular/cli

Node Version Issues

# Use Node Version Manager (nvm)
nvm install 18
nvm use 18

CORS Errors

Ensure backend CORS configuration includes frontend URL:

cors:
  allowed-origins: http://localhost:4200

Common Issues

Firecrawl API Not Working

  1. Check API key is set correctly
  2. Verify Firecrawl service status
  3. Check network connectivity
  4. Review logs for error messages

Build Failures

# Backend
mvn clean install -X  # Verbose output

# Frontend
npm ci  # Clean install
npm run build -- --verbose

Development Workflow

1. Feature Development

# Create feature branch
git checkout -b feature/job-recommendations

# Make changes
# Test locally
# Commit changes
git add .
git commit -m "Add job recommendation feature"

# Push to remote
git push origin feature/job-recommendations

2. Code Quality

Backend

# Run linter
mvn checkstyle:check

# Run tests with coverage
mvn test jacoco:report

Frontend

# Run linter
npm run lint

# Run tests with coverage
npm test -- --code-coverage

3. Database Migrations (Future)

When Flyway is configured:

# Create migration
touch src/main/resources/db/migration/V1__Create_jobs_table.sql

# Run migrations
mvn flyway:migrate

IDE Setup

IntelliJ IDEA

  1. Open project root directory
  2. Import as Maven project
  3. Set SDK to Java 17
  4. Enable annotation processing for Lombok
  5. Install plugins: Spring Boot, Angular

VS Code

  1. Install extensions:

    • Java Extension Pack
    • Spring Boot Extension Pack
    • Angular Language Service
    • ESLint
    • Prettier
  2. Configure settings.json:

{
  "java.configuration.updateBuildConfiguration": "automatic",
  "java.home": "/path/to/java17",
  "editor.formatOnSave": true,
  "prettier.singleQuote": true
}

Docker Setup (Optional)

Backend Dockerfile

FROM openjdk:17-jdk-slim
COPY target/recruitment-backend-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

Frontend Dockerfile

FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=build /app/dist/recruitment-portal /usr/share/nginx/html

Docker Compose

version: '3.8'
services:
  backend:
    build: ./backend
    ports:
      - "8080:8080"
    environment:
      - SPRING_PROFILES_ACTIVE=docker
      - FIRECRAWL_API_KEY=${FIRECRAWL_API_KEY}
    depends_on:
      - postgres

  frontend:
    build: ./frontend/recruitment-portal
    ports:
      - "4200:80"
    depends_on:
      - backend

  postgres:
    image: postgres:14
    environment:
      - POSTGRES_DB=recruitment
      - POSTGRES_USER=recruitment_user
      - POSTGRES_PASSWORD=secure_password
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Monitoring & Logging

Application Logs

# Backend logs
tail -f backend/logs/application.log

# Frontend build logs
npm run build -- --verbose

Performance Monitoring

  • Backend: Spring Boot Actuator endpoints at /actuator/*
  • Frontend: Angular DevTools Chrome extension

Security Considerations

  1. Never commit sensitive data

    • Use environment variables
    • Add .env to .gitignore
  2. Update dependencies regularly

# Backend
mvn versions:display-dependency-updates

# Frontend
npm audit
npm audit fix
  1. Use HTTPS in production
  2. Implement rate limiting
  3. Validate all inputs
  4. Use prepared statements for database queries

Additional Resources


Support

For issues or questions:

  1. Check the troubleshooting section
  2. Review logs for error messages
  3. Create an issue in the GitHub repository
  4. Contact the development team

Reacties

Nog geen reacties