{"id":15363782,"url":"https://github.com/javieraviles/spring-boot-redis-rest","last_synced_at":"2025-04-15T09:29:10.255Z","repository":{"id":82659645,"uuid":"145858932","full_name":"javieraviles/spring-boot-redis-rest","owner":"javieraviles","description":"API REST boilerplate using Spring Boot and Redis as database","archived":false,"fork":false,"pushed_at":"2018-12-26T18:33:50.000Z","size":13,"stargazers_count":13,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T18:51:50.703Z","etag":null,"topics":["boilerplate","docker","jedis","redis","rest-api","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/javieraviles.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":"2018-08-23T13:40:16.000Z","updated_at":"2023-04-17T19:04:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"5d913029-7c49-4c47-97e2-2dad5e2b8ac6","html_url":"https://github.com/javieraviles/spring-boot-redis-rest","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"978489a2e368531e468897eac6ae58e1cdc5d040"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javieraviles%2Fspring-boot-redis-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javieraviles%2Fspring-boot-redis-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javieraviles%2Fspring-boot-redis-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javieraviles%2Fspring-boot-redis-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javieraviles","download_url":"https://codeload.github.com/javieraviles/spring-boot-redis-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249042544,"owners_count":21203309,"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":["boilerplate","docker","jedis","redis","rest-api","spring-boot"],"created_at":"2024-10-01T13:08:27.897Z","updated_at":"2025-04-15T09:29:10.236Z","avatar_url":"https://github.com/javieraviles.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spring-boot-redis-rest\n\nAPI REST boilerplate with Spring Boot and Redis as database. No big motivation, just because is fun :)\n\n## TODO\n - Add Unit Tests\n\n## Getting started with Spring Boot\nThe [reference documentation](https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/) includes detailed [installation instructions](https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-installing-spring-boot)\nas well as a comprehensive [``getting\nstarted``](https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-first-application) guide. Documentation is published in [HTML](https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/), [PDF](https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/pdf/spring-boot-reference.pdf) and [EPUB](https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/epub/spring-boot-reference.epub) formats.\n\n## Rest Controller\nThe class `UserResource.java` contains every endpoint. The code is very self-descriptive.\n\n**AVAILABLE ENDPOINTS**\n\n| method            | resource          | description                                                                                   |\n|:------------------|:------------------|:----------------------------------------------------------------------------------------------|\n| `GET`\t\t\t| `/users`\t\t| get the collection of users -\u003e 200(OK)\t\t\t\t\t\t\t\t\t\t\t\t\t\t|\n| `GET`\t\t\t| `/users/:id`\t| get a user by Id -\u003e 200(OK), 400(wrong id format), 404(no user with such id)\t\t\t\t\t|\n| `POST`\t\t\t| `/users`\t\t| creates a user in the DB -\u003e 201(created)\t\t\t\t\t\t\t\t\t\t\t\t\t\t|\n| `PUT`\t\t\t| `/users/:id`\t| updates a user in the DB -\u003e 204(updated), 400(wrong id format), 404(no user with such id)\t\t|\n| `DELETE`\t\t| `/users/:id`\t| deletes a user from the DB -\u003e 204(deleted), 400(wrong id format), 404(no user with such id)\t|\n\n## Exception Handling\nAn Spring Boot advice `UserResourceAdvice.java` has been created for handling exceptions and convert them into desired responses. This way both the Rest Controller and the CRUD service are cleaner as they don't need to contain the error handling.\n\n| exception\t\t\t\t\t\t\t\t\t\t| response     \t\t\t\t   \t\t\t|\n|:----------------------------------------------|:--------------------------------------|\n| `NotFoundException`\t\t\t\t\t\t| `404 NOT FOUND`\t\t\t\t\t|\n| `RedisConnectionFailureException`\t| `500 INTERNAL SERVER ERROR`\t|\n| `IllegalArgumentException`\t\t\t\t| `400 BAD REQUEST`\t\t\t\t\t|\n\n## CRUD service\nThe CRUD is done in `UserService.java` through a **RedisTemplate\u003cString, User\u003e**, created as a @bean in `SpringRedisApplication.java`. A RedisTemplate should be created for each entity that will be persisted to Redis.\n\nRedis keys for stored users will follow the format `users:\u003cuuid of user\u003e`. That way, the whole collection of users can be fetched through the pattern `users:*`.  The code is dead simple and very self-descriptive.\n\n## Redis connection\nThe connection to Redis is established through a `Jedis client`. A `JedisConnectionFactory` is defined in `SpringRedisApplication.java`, taking Redis hostname and password from application properties.\n\nNotice that a `StringRedisSerializer` has been used for keys, otherwise the marshalling would be done through the default serializer (as happens with stored values since we are not specifying any serializer).\n\n## Local dev environment\n**Eclipse IDE** -\u003e Spring Tools for Eclipse IDE definitely useful.\n\nRun local **Redis server** in Docker:\n\tdocker pull redis\n\tdocker run -d --name redis -p 6379:6379 redis\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavieraviles%2Fspring-boot-redis-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavieraviles%2Fspring-boot-redis-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavieraviles%2Fspring-boot-redis-rest/lists"}