{"id":14977537,"url":"https://github.com/jabrena/spring-boot-user-beans","last_synced_at":"2025-10-28T04:31:34.754Z","repository":{"id":73644054,"uuid":"600804353","full_name":"jabrena/spring-boot-user-beans","owner":"jabrena","description":"A visual way to increase the developer awareness to minimize the number of Beans in memory.","archived":false,"fork":false,"pushed_at":"2023-08-11T09:27:12.000Z","size":3010,"stargazers_count":52,"open_issues_count":23,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-01T11:24:54.317Z","etag":null,"topics":["bard","beans","chatgpt","java","spring-boot","spring-framework"],"latest_commit_sha":null,"homepage":"https://jabrena.github.io/spring-boot-user-beans/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jabrena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-12T16:47:25.000Z","updated_at":"2024-08-09T09:29:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c5ec2a0-709c-4b3d-81ab-623f768b6e23","html_url":"https://github.com/jabrena/spring-boot-user-beans","commit_stats":{"total_commits":64,"total_committers":2,"mean_commits":32.0,"dds":0.03125,"last_synced_commit":"7af834fdebfc0339b1b9565c2ae32d3be258dc70"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Fspring-boot-user-beans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Fspring-boot-user-beans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Fspring-boot-user-beans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Fspring-boot-user-beans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabrena","download_url":"https://codeload.github.com/jabrena/spring-boot-user-beans/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238597386,"owners_count":19498396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bard","beans","chatgpt","java","spring-boot","spring-framework"],"created_at":"2024-09-24T13:55:50.521Z","updated_at":"2025-10-28T04:31:28.105Z","avatar_url":"https://github.com/jabrena.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring boot User Beans\n\n[![CI Builds](https://github.com/jabrena/spring-boot-user-beans/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/jabrena/spring-boot-user-beans/actions/workflows/build.yaml)\n\n[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-white.svg)](https://sonarcloud.io/summary/new_code?id=jabrena_spring-boot-user-beans)\n\n[![](https://jitpack.io/v/jabrena/spring-boot-user-beans.svg)](https://jitpack.io/#jabrena/spring-boot-user-beans)\n\nA visual way to increase the developer awareness to minimize the number of Beans in memory.\n\nThe library exposes operational information about\nyour Spring Beans running in the memory as another\nmetric included with `Spring Boot Actuator`.\n\n## Motivation\n\nUsing this project, you will be able to see your Beans developed in your project\nplus other Beans provided by the dependencies that you include\nin the **classpath** in a Graph representation. The project uses Graph theory to show the beans as a [Directed Graph](https://en.m.wikipedia.org/wiki/Directed_graph).\n\nThe user interfaces will allow you searching\nyour Beans by name or package and review the relations between them.\nAlso, you can filter by the main dependencies used in your Spring Boot project.\n\n![](docs/design/user-beans16.png)\n\nIf you click in a any Green node (A Spring Bean which returns a Java class),\nyou could navigate to a Detail page, in order receive an explanation from ChatGPT.\n\n## Getting Started\n\nAdd the following dependency in your build system:\n\n**Maven:**\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.jabrena.spring-boot-user-beans\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-starter-user-beans\u003c/artifactId\u003e\n    \u003cversion\u003ev0.2.0-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n**Gradle:**\n\n```kotlin\nallprojects {\n    repositories {\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\n```gradle\ndependencies {\n    implementation 'com.github.jabrena.spring-boot-user-beans:spring-boot-starter-user-beans:v0.2.0-SNAPSHOT'\n}\n```\n\nFurther information: https://jitpack.io/#jabrena/spring-boot-user-beans/\n\n\n**Note:** Coming soon on Maven Central with `JRELEASER`\n\n### Configuration:\n\nThis library require a bit of configuration in the section about\n`spring boot actuator`:\n\n```properties\nmanagement.endpoints.web.exposure.include=beans,userbeans\n```\n\nThe library has an optional feature to explain your Beans using the ChatGPT capabilities.\nIn order to use this feature, you need set a valid `OpenAI API Key`\n\n**Example:**\n\n```bash\nexport OPENAI_API_KEY=YOUR_API_KEY_VALUE\necho $OPENAI_API_KEY\n./mvnw spring-boot:run -Dspring-boot.run.arguments=\"--userbeans.openapi.apikey=$OPENAI_API_KEY\"\n```\n\n**Note:** If you don´t have a `OpenAI API Key`, you can use this library but the features from `ChatGPT`\nwill be disabled.\n\n**Requirements:**\n\nIn order to use this Dependency, you need to have in the classpath:\n\n- spring-boot-starter-web || spring-boot-starter-webflux\n- spring-boot-starter-actuator\n\n**Testing level:**\n\nThe project was tested with `Spring Boot 3.1.0`\n\n## Benefits\n\n### 1. Improve your Spring Beans composition\n\nBy leveraging the Graph representation,\nyou gain the ability to visualize all the Beans actively running\nwithin your Spring Boot application. Additionally, you have\nthe flexibility to filter Beans based on their dependencies.\nAnalyzing the Graph Shape can reveal valuable insights about\nthe structure and relationships within your Spring solution,\nenabling you to make informed decisions and discover intriguing patterns.\n\n![](docs/design/use-case1.png)\n\n### 2. Be Stateful or not\n\nBy reviewing your Beans in a broader perspective,\nyou have the opportunity to evaluate whether your Objects\nneed to maintain state or can be stateless.\nThis examination allows you to make informed decisions about\nthe design and architecture of your application,\nensuring that the statefulness of your Beans aligns\nwith the requirements and objectives of your system.\n\n### 3. Learn about how the different Spring Boot Starters were designed.\n\nWhen you visit https://start.spring.io/, you gain access to a wide range\nof Spring Boot Starters that can be incorporated into your project.\nBy exploring and utilizing this library, you have the opportunity\nto delve into the design principles behind each Starter and\nunderstand how they were specifically crafted to address various challenges.\nThis exploration enables you to gain valuable insights into\nthe decision-making process involved in designing these Starters,\nfostering a deeper understanding of Spring Boot and\nits versatile solutions.\n\n![](docs/design/user-beans14.png)\n\n### 4. Learn about the Beans that you are using under the hood.\n\nWhen examining the Graph, you may notice the presence of numerous Beans\nthat are unfamiliar to you. These Beans form a critical part of\nthe underlying Infrastructure required to run your\nSpring Boot application smoothly. By clicking on the Green nodes\nwithin the Graph, you can access concise descriptions that\nshed light on the purpose and functionality of each individual Bean.\n\n### 5. Improve the way to measure the Cognitive Load in your team.\n\nBy leveraging this educational tool, you can enhance\nyour ability to measure and manage your\n[Cognitive Load](https://en.wikipedia.org/wiki/Cognitive_load).\nCognitive Load refers to the mental effort required\nfor information processing.\n\n## Goals\n\n- [x] Visualize Beans running in the container\n- [x] List of user beans\n- [x] List of user dependencies (Jars)\n- [x] Review quality of results\n- [x] Filter by Java class, Package or dependency\n\n## Convention over configuration\n\n[Convention over configuration](https://en.wikipedia.org/wiki/Convention_over_configuration) (also known as coding by convention) is a software design paradigm used by software frameworks that attempts to decrease the number of decisions that a developer using the framework is required to make without necessarily losing flexibility and don't repeat yourself (DRY) principles.\n\n## How to build and test in local\n\n```bash\n./mvnw clean verify\n./mvnw clean verify -Ppipelines\n./mvnw clean spring-boot:run \\\n  -pl examples/hello-world-servlet/ -am \\\n  -Dspring-boot.run.arguments=\"--userbeans.openapi.apikey=$OPENAI_API_KEY\" \\\n  -Dmaven.repo.local=./local-m2\n\n./mvnw spring-boot:run -pl examples/hello-world-reactive/ -am -Puserbeans -Dspring-boot.run.arguments=\"--userbeans.openapi.apikey=$OPENAI_API_KEY\"\nopen http://localhost:8080/\n\n#UX\ncurl -v http://localhost:8080/actuator/userbeans/graph | json_pp\ncurl -v http://localhost:8080/actuator/userbeans/graph | json_pp \u003e ./docs/graph.json\ncurl -v http://localhost:8080/actuator/userbeans/graph-combo | json_pp\ncurl -v http://localhost:8080/actuator/userbeans/graph-combo | json_pp \u003e ./docs/graph-combo.json\ncurl -v \"http://localhost:8080/actuator/userbeans/graph?dependency=UNKNOWN\" | json_pp\n```\n\n# External tests\n\nThe project was tested with the classic project **Spring PetClinic**.\n\n```bash\n./mvnw spring-boot:run -pl external-tests/spring-petclinic -am\n```\n\n![](docs/design/spring-petclinic.png)\n\nGo for [external-tests](./external-tests/README.md) for further details.\n\n## How to show the coverage on Codespaces?\n\n```bash\n# Step 1: Launch the webserver with the JACOCO Report\n./mvnw clean verify\nsdk install java 20-tem\nsdk use java 20-tem\njwebserver -p 9000 -d \"$(pwd)/coverage-module/target/site/jacoco-aggregate/\"\n\n# Step 2: Stop the webserver \u0026 use the default Java version\nsdk env install\nsdk env\n```\n\n## Limitations\n\n**Graph Generation:**\n\nCurrently the D3.js graph is generated only using information from Edges\nand it is possible to be improved.\n\nExample: `curl -v \"http://localhost:8080/actuator/userbeans/graph?dependency=micrometer-observation-1.11.0.jar\" | json_pp`\n\n```json\n{\n   \"edges\" : [\n      {\n         \"source\" : {\n            \"beanName\" : \"SimpleObservationRegistry\",\n            \"beanPackage\" : \"io.micrometer.observation\",\n            \"dependency\" : \"micrometer-observation-1.11.0.jar\"\n         },\n         \"target\" : {\n            \"beanName\" : \"ObservationAutoConfiguration\",\n            \"beanPackage\" : \"UNKNOWN\",\n            \"dependency\" : \"UNKNOWN\"\n         }\n      }\n   ],\n   \"nodes\" : []\n}\n```\n\nThis data structure need to be evolved a better way:\n\n```js\nvar nodes = [\n    {name: 'A'},\n    {name: 'B'},\n    {name: 'C'},\n    {name: 'D'},\n    {name: 'E'},\n    {name: 'F'},\n    {name: 'G'},\n    {name: 'H'},\n]\n\nvar links = [\n    {source: 0, target: 1},\n    {source: 0, target: 2},\n    {source: 0, target: 3},\n    {source: 1, target: 6},\n    {source: 3, target: 4},\n    {source: 3, target: 7},\n    {source: 4, target: 5},\n    {source: 4, target: 7}\n]\n```\n\nhttps://codepen.io/jabrena/pen/zYMWpJw\n\nRelated issues:\n\n- https://github.com/jabrena/spring-boot-user-beans/issues/111\n- https://github.com/jabrena/spring-boot-user-beans/issues/85\n\n**Current limitation to get Class from deps:**\n\nThe Bean `BeansEndpoint` provides a way to retrieve\nall Beans and dependencies, but some dependencies are not easy\nto retrieve the class. I believe that I need to learn more about\n`Proxy Beans`.\n\n## Other commands\n\n```\n./mvnw prettier:write\n./mvnw versions:display-dependency-updates\n./mvnw versions:display-plugin-updates\n./mvnw versions:set -DnewVersion=0.3.0-SNAPSHOT\n./mvnw versions:commit -DprocessAllModules\n```\n\n## Source of inspiration\n\n- https://github.com/making/beansviz-spring-boot-actuator\n- https://github.com/spring-projects/spring-framework/issues/29973\n\n## References\n\n- https://en.m.wikipedia.org/wiki/Directed_graph\n- https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/package-summary.html\n- https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/package-summary.html\n- https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/actuate/beans/BeansEndpoint.html\n- https://github.com/spring-projects-experimental/spring-boot-thin-launcher\n- https://docs.spring.io/spring-boot/docs/current/reference/html/cli.html#cli.using-the-cli\n- https://jakarta.ee/specifications/cdi/3.0/\n- https://jakarta.ee/specifications/cdi/3.0/jakarta-cdi-spec-3.0.pdf\n- https://d3js.org/\n- https://www.webjars.org/all\n- https://www.eclemma.org/jacoco/trunk/doc/maven.html\n- https://platform.openai.com/docs/api-reference/\n- https://platform.openai.com/account/usage\n- https://platform.openai.com/account/api-keys\n- https://openai.com/pricing\n- https://jitpack.io/#jabrena/spring-boot-user-beans/\n\nMade with ❤️ from Madrid\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabrena%2Fspring-boot-user-beans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabrena%2Fspring-boot-user-beans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabrena%2Fspring-boot-user-beans/lists"}