This project demonstrates a microfrontend architecture using web fragments, a central shell app, and Keycloak for authentication and authorization.
The goal is to develop multiple frontends and backends modularly, deploy them independently, and integrate them dynamically within a shared shell.
- Node.js (v20 or newer)
- pnpm (preferred package manager)
- Docker
- Docker Compose
- containerization/
keycloak-realm/→ Keycloak configurationcompose.yml→ Compose setupdefault.env→ Environment file
- fragment/
backend/→ Fragment backend (API and BFF)frontend/→ Fragment frontend (Angular)
- shell/
backend/→ Shell backendfrontend/→ Shell frontend (Angular)
- README.md
Go to fragment and install dependencies for backend and frontend.
cd fragment/frontend
pnpm install
cd fragment/backend
pnpm installGo to shell and install dependencies for backend and frontend.
cd shell/frontend
pnpm install
cd shell/backend
pnpm installCreate an environment file .env in containerization.
cd containerization
cp default.env .envcd containerization
docker compose up -dGo to fragment to build and start app.
cd fragment/frontend
pnpm build
cd fragment/backend
pnpm start
# reachable on http://localhost:8000/Open a new/extra or second terminal. Go to shell to build and start app.
cd shell/frontend
pnpm build
cd shell/backend
pnpm start
# reachable on http://localhost:3000/Open in browser http://localhost:8081/admin to login to admin console of keycloak.
Use as user = password = admin.
Open in browser http://localhost:3000/ to login to shell.
Use as user = password = webfragements.
You should see the shell and the fragment loaded with a button.
Clicking the button calls a request to load text Hello World.
But this works not in current situation, but should.
This is because we use in the fragment keycloak onLoad Option with 'check-sso'.
It works with the value undefined but that is not desired.
The following commands are for exporting changes in keycloak realms and save them for later. You need to stop the compose before running the commands.
The realms will be imported on startup of the compose file.
cd containerization
# export realms
docker compose run --rm keycloak export --dir /opt/keycloak/data/import