A full-stack demonstration application showcasing Unleash feature flags with a Spring Boot backend and Angular frontend. This project demonstrates advanced feature flag patterns including kill switches, A/B testing with variants, and context-based targeting.
- Backend: Spring Boot 4.0.0 with Java 21, Unleash Java SDK 9.2.4
- Frontend: Angular 21 with standalone components, Unleash JavaScript SDK
- Styling: Tailwind CSS v3 with dark mode support
- Build Tools: Gradle (backend), npm (frontend)
- Java 21 or higher
- Node.js 22.12+
- An Unleash account/instance
git clone https://github.com/Unleash/demo-java-angular.git
cd demo-java-angularThis repository includes an unleash-export.json file with all feature flags preconfigured. This is the quickest way to set up your Unleash instance with all the flags, strategies, variants, and constraints needed for this demo.
To import the configuration:
- Log in to your Unleash instance
- Go to Configure > Context fields. Create or edit the context field
countryand add the legal valuesUS,UK,AUS, andIN. Click Save. - Create a new project or select an existing one.
- Go to Project Overview and click Import.
- Select the
unleash-export.jsonfile from this repository and your target environment to import the flags to. - Validate the import and confirm.
If you encounter any issues, check out our Import/Export docs.
What gets imported:
- 4 feature flags:
dark-mode,disable-slow-reports,movie-recommendations,pricing-experiment - All variants (control, promo_v1, promo_v2, v1-simple, v2-ml)
- Rollout strategies and constraints (including country-based targeting)
Alternative: You can manually create these flags in Unleash, but importing saves time and ensures the exact configuration matches the demo application.
Create the configuration file from the template:
cd src/main/resources
cp application.properties.example application.propertiesEdit application.properties and configure your Unleash API token and instance URL:
unleash.api.url=https://YOUR_UNLEASH_INSTANCE_URL/api
unleash.api.token=YOUR_UNLEASH_API_TOKEN_HEREWhere to find your token:
- Log in to Unleash.
- Go to Admin settings > API Access.
- Create or copy a Backend API token. The token should have access to the environment where you created or imported your feature flag configurations.
Note: This project is configured for Java 21 by default. If you have a higher Java version installed, you need to update the build.gradle file:
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21) // Change 21 to your version
}
}Create the configuration file from the template:
cd frontend/src/app/config
cp unleash.config.example.ts unleash.config.tsEdit unleash.config.ts and configure your Unleash frontend key and instance URL:
url: 'https://YOUR_UNLEASH_INSTANCE_URL/api/frontend',
clientKey: 'YOUR_UNLEASH_CLIENT_KEY_HERE',Where to find your frontend token:
- Log in to Unleash.
- Go to Admin settings > Access control > API access.
- Create or copy a Frontend API token. The token should have access to the environment where you created or imported your feature flag configurations.
cd frontend
npm installFor more frontend-specific details, see the Frontend README
From the project root directory:
./gradlew bootRunOr use your IDE's debug/run configuration. The backend will start on http://localhost:8080
In a separate terminal:
cd frontend
npm startThe Angular dev server will start on http://localhost:4200
Open your browser and navigate to:
- Frontend: http://localhost:4200
- Backend API:
- Reports endpoint: http://localhost:8080/api/reports
- Recommendations endpoint: http://localhost:8080/api/recommendations
This demo includes four interactive pages, each showcasing different feature flag patterns and best practices:
Client-side only feature flag demonstration.
Feature Flag: dark-mode
- Type: Release toggle
- Use Case: Frontend-only feature without backend dependency
- Features:
- Toggle between light and dark themes
- Persistent preference in localStorage
- No backend API calls required
- Demonstrates pure client-side feature control
Demonstrates graceful degradation when services are experiencing issues.
Feature Flag: disable-slow-reports
- Type: Kill switch
- Use Case: Emergency circuit breaker to disable slow report generation
- Backend: Bypasses slow processing and returns cached results when enabled
- Frontend: Shows cache indicator when kill switch is active
Personalized movie recommendations using A/B testing to compare algorithms.
Feature Flag: movie-recommendations
- Type: Experiment
- Variants:
v1-simple: Basic recommendation algorithm (10 popular movies)v2-ml: ML-based recommendation algorithm (10 personalized movies)
- Features:
- Movie carousel with TMDB poster images
- Real movie data with IMDb IDs, ratings, and years
- Backend: Different movie datasets per variant with unique IMDb IDs
- Frontend: Loads recommendations only when flag is enabled
A/B testing with three variants and context-based targeting.
Feature Flag: pricing-experiment
- Type: Experiment
- Variants:
control(30%): Standard pricing layoutpromo_v1(35%): Discount banner with promotional messagingpromo_v2(35%): Emphasized yearly plan with "Best Value" badge
- Context Targeting: Only enabled for specific countries (UK and US)
- Features:
- Dynamic country selector to test different contexts
- User simulation to see different variant assignments
- Real-time variant display in configuration panel
| Flag Name | Type | Backend | Frontend | Description |
|---|---|---|---|---|
dark-mode |
Release | - | ✓ | Theme toggle (UI-only) |
disable-slow-reports |
Kill Switch | ✓ | ✓ | Emergency circuit breaker for slow operations |
movie-recommendations |
Experiment | ✓ | ✓ | Compare recommendation algorithms |
pricing-experiment |
Experiment | - | ✓ | A/B test with 3 variants + context targeting |
demo/
├── src/main/java/ # Spring Boot backend
│ └── io/getunleash/demo/
│ ├── DemoApplication.java # Main app + REST controllers
│ ├── config/ # Configuration classes
│ │ ├── GlobalExceptionHandler.java
│ │ ├── UnleashConfiguration.java
│ │ └── UnleashProperties.java
│ └── model/
│ └── Movie.java # Movie entity with IMDb IDs
├── src/main/resources/
│ ├── application.properties.example # Configuration template
│ └── application.properties # Your actual config (gitignored)
├── frontend/
│ └── src/
│ └── app/
│ ├── components/ # Angular components (standalone)
│ │ ├── kill-switch.component.ts
│ │ ├── pricing-experiment.component.ts
│ │ ├── recommendations.component.ts
│ │ ├── ui-only.component.ts
│ │ └── navigation.component.ts
│ ├── services/ # Angular services
│ │ ├── api.service.ts
│ │ ├── unleash.service.ts
│ │ └── dark-mode.service.ts
│ ├── config/ # Configuration files
│ │ ├── unleash.config.example.ts # Template (committed)
│ │ └── unleash.config.ts # Actual config (gitignored)
│ ├── app.routes.ts
│ ├── app.config.ts
│ └── app.ts
├── build.gradle # Gradle configuration
├── README.md # This file
└── frontend/README.md # Frontend-specific docs
- Real-world Patterns: Kill switches, A/B testing, context targeting, and personalized content
- Rich Demo Data: Real movie data with TMDB posters and IMDb IDs
- Modern UI: Tailwind CSS with dark mode support, responsive design optimized for laptop screens
- Live Updates: Real-time feature flag updates without page refresh
- Variant Testing: Three-way A/B tests with control groups
- Context Targeting: Geographic and user-based targeting
- User Simulation: Test different user contexts and variant assignments
- Interactive Panel: Collapsible feature flags configuration panel on every page
application.properties and unleash.config.ts) are excluded from Git via .gitignore to prevent accidentally committing sensitive API tokens.
Always use the .example template files as reference and never commit files containing real API tokens or secrets.
When contributing, ensure you:
- Never commit real API tokens or secrets
- Update the
.examplefiles if you add new configuration parameters - Test with your own Unleash account credentials
Apache 2