Setup and Configuration

Prerequisites

Environment Configuration

Required Environment Variables

export AZURE_FUNCTIONS_BASE_URL="http://localhost:7071/api"
export SPRING_SECURITY_USER_NAME="user"
export SPRING_SECURITY_USER_PASSWORD="myStrongPassword123"

Application Configuration

The application uses src/main/resources/application.yml for configuration:

server:
  port: 8080

spring:
  application:
    name: agranelos-bff

azure:
  functions:
    base-url: ${AZURE_FUNCTIONS_BASE_URL:http://localhost:7071/api}

logging:
  level:
    root: INFO
    org.springframework.web: INFO

management:
  endpoints:
    web:
      exposure:
        include: health,info

Local Development

Method 1: Direct Maven Execution

# Clone repository
git clone https://github.com/DiegoBarrosA/agranelos-bff.git
cd agranelos-bff

# Set environment variables
export AZURE_FUNCTIONS_BASE_URL="https://your-functions.azurewebsites.net/api"

# Run application
mvn spring-boot:run

Create a compose.yml file for local development:

version: '3.8'
services:
  agranelos-bff:
    build: .
    ports:
      - "8080:8080"
    environment:
      - AZURE_FUNCTIONS_BASE_URL=https://your-functions.azurewebsites.net/api
      - SPRING_SECURITY_USER_NAME=user
      - SPRING_SECURITY_USER_PASSWORD=myStrongPassword123
    networks:
      - agranelos-network

networks:
  agranelos-network:
    driver: bridge

Run with Podman:

podman compose up --build

Project Structure

agranelos-bff/
├── src/
│   ├── main/
│   │   ├── java/com/agranelos/bff/
│   │   │   ├── controller/          # REST Controllers
│   │   │   ├── dto/                 # Data Transfer Objects  
│   │   │   ├── config/              # Configuration classes
│   │   │   └── exception/           # Exception handlers
│   │   └── resources/
│   │       └── application.yml      # Application configuration
│   └── test/                        # Test classes
├── docs/                            # Documentation (Jekyll)
├── postman/                         # Postman environments
├── Dockerfile                       # Container definition
├── compose.yml                      # Podman/Docker compose
└── pom.xml                         # Maven configuration

Development Guidelines

Code Style

Testing

Configuration Management

IDE Setup

IntelliJ IDEA

  1. Import as Maven project
  2. Set JDK to Java 17+
  3. Enable Spring Boot support
  4. Configure code style to follow project conventions

VS Code

  1. Install Java Extension Pack
  2. Install Spring Boot Extension Pack
  3. Configure workspace settings for Maven
  4. Set up debugging configuration

Health Checks

The application exposes health endpoints:

Use these endpoints to verify the application is running correctly.

Troubleshooting

Common Issues

Connection to Azure Functions fails:

Authentication errors:

Port conflicts:

Debug Mode

Run with debug logging:

mvn spring-boot:run -Dspring.profiles.active=debug

Or set environment variable:

export LOGGING_LEVEL_ROOT=DEBUG