{"id":15019342,"url":"https://github.com/potatowhite/simply-starter","last_synced_at":"2025-10-24T09:30:53.023Z","repository":{"id":54382992,"uuid":"328596718","full_name":"PotatoWhite/simply-starter","owner":"PotatoWhite","description":"Simplify and automate web backend development","archived":false,"fork":false,"pushed_at":"2021-06-03T15:44:42.000Z","size":4220,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T00:42:25.683Z","etag":null,"topics":["event-driven","kafka","resful-api","springboot","webflux"],"latest_commit_sha":null,"homepage":"","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/PotatoWhite.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}},"created_at":"2021-01-11T08:30:15.000Z","updated_at":"2021-12-24T06:55:26.000Z","dependencies_parsed_at":"2022-08-13T14:00:53.303Z","dependency_job_id":null,"html_url":"https://github.com/PotatoWhite/simply-starter","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PotatoWhite%2Fsimply-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PotatoWhite%2Fsimply-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PotatoWhite%2Fsimply-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PotatoWhite%2Fsimply-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PotatoWhite","download_url":"https://codeload.github.com/PotatoWhite/simply-starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237944160,"owners_count":19391589,"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":["event-driven","kafka","resful-api","springboot","webflux"],"created_at":"2024-09-24T19:53:21.718Z","updated_at":"2025-10-24T09:30:47.654Z","avatar_url":"https://github.com/PotatoWhite.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simply - Serviceable, Controllable, Eventable, Clientable\n\nSimply은 Spring 기반의 Restful API, Event-Driven 개발시 중복적인 코드를 줄여 준다. 중복적인 코드를 줄임으로써 Application 개발자가 Project의 목적인 Business\nLogic에 더 집중할 수 있게 하는 것이 목적이다.\n\n* Quickstart 관련한 사용 예제는 https://github.com/PotatoWhite/simply-quickstart 를 참고하여 주세요.\n* Kafka Binder 관련한 사용 예제는 https://github.com/PotatoWhite/simply-messaging-producer , https://github.com/PotatoWhite/simply-messaging-consumer 를 참고하여 주세요.\n\n## Features\n\n- Serviceable : Jpa 기반 Entity의 기본적인 CRUD를 생성한다.\n- Controllable : Serviceable 기반의 Restful API를 생성한다.\n- Eventable : Kafka를 통해 Entity의 변경시 다른 서비스로 변경을 알린다.\n- Clientable : Kafka를 통해 Entity의 변경시 다른 서비스로 변경을 알린다.\n\n기본적으로 Simply은 spring framework을 이용한 Restful API 등을 개발 할 때 도움이 되고자 한다. 추상화하는 내역으로는 @Service로 대표되는 Service,\n@RestConroller로 대표되는 Controllable 마지막으로 Event Driven을 위한 Entity변경 시 필요로한 Service에서의 Event Listener를 제공한다. 또한 부가적으로\nClient모듈을 제공해 개발자가 마치 로컬 메소드를 호출하 듯 원격의 Restful API를 호출하여 사용할 수 있게 한다.\n\n## Build\n\nMaven 중앙 Repository로 부터 Library를 가져온다.\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n```\n\n## 사용방법\n\n- gradle 을 이용해 사용한다.\n\n```groovy\n[build.gradle]\n\nimplementation 'io.easywalk:simply-common:0.0.4.RELEASE'\nimplementation 'io.easywalk:simply-serviceable:0.0.4.RELEASE'\nimplementation 'io.easywalk:simply-controllable:0.0.4.RELEASE'\nimplementation 'io.easywalk:simply-eventable-kafka-binder:0.0.4.RELEASE'\nimplementation 'io.easywalk:simply-clientable:0.0.4.RELEASE'\n```\n\n## 설정\n\n* eventable에 한하여 별도의 설정이 필요하다.\n* entity-base-package는 Producer가 Kafka의 Topic을 생성하기 위해 Bean의 Scan 지점을 설정한다.\n* number-of-replicas는 Topic의 Replicas 갯수이다.\n* number-of-partitions는 Topic의 Partitions 갯수이다.\n\n```yaml\nsimply:\n  eventable:\n    entity-base-package: io.easywalk.demo.entities\n    topic-property:\n      number-of-replicas: 1\n      number-of-partitions: 10\n```\n\n## simply-common\n\n- simply 에서 제공하고자 하는 Spec 정의.\n\n### SimplySpec\n\n```java\npublic interface SimplySpec\u003cT, ID\u003e {\n    T create(T createForm) throws Throwable;\n\n    T replaceById(ID id, T replace) throws Throwable;\n\n    T updateById(ID id, Map\u003cString, Object\u003e fields) throws Throwable;\n\n    T get(ID id) throws Throwable;\n\n    List\u003cT\u003e getAll() throws Throwable;\n\n    void deleteById(ID id) throws Throwable;\n\n    void delete(T entity) throws Throwable;\n}  \n```\n\n## Serviceable\n\n- 특정 Entity의 관리를 목적으로하는 CRUD 기능을 자동화한다.\n\n### Serviceable Example\n\n- Serviceable을 사용하기 위해서는 'AbstractServiceable' 을 상속 받는다.\n- 상속받아 새로 만든 Class를 통해 Entity를 다루는 Repository를 주입한다.\n\n```java\n\n@Service\npublic class UserService extends AbstractServiceable\u003cUser, Long\u003e {\n    protected UserService(UserRepository repository) {\n        super(repository);\n    }\n}\n\n```\n\n### Serviceable의 확장\n\n- Simply에서 제공하는 기능외 확장이 가능하다.\n- 확장을 위해서 목적 실제 Service Class에서 Method를 정의한다.\n\n```java\n\n@Service\npublic class UserService extends AbstractServiceable\u003cUser, Long\u003e {\n    // Repository를 주입 받는다.\n    private final UserRepository repository;\n\n    protected UserService(UserRepository repository) {\n        super(repository);\n        this.repository = repository;\n    }\n\n    // 새로운 Method 를 작성한다.\n    public boolean isExist(Long id) {\n        return repository.existsById(id);\n    }\n}\n```\n\n## Controllable\n\n- Serviceable Bean을 기반으로 CRUD 기능을 RestfulAPI 형태로 expose 한다.\n\n### EnableSimplyControllable\n\n* Using \"@EnableSimplyControllable\" annotation, activate controllable features.\n\n```java\n\n@EnableSimplyControllable\n@SpringBootApplication\npublic class Application {\n\n    public static void main(String[] args) {\n        SpringApplication.run(Application.class, args);\n    }\n}\n```\n\n### Controllable Method\n\n- Restful API를 제공하는 Method는 다음과 같다.\n\n```java\npublic interface Controllable\u003cT1, T2\u003e {\n\n    T1 create(T1 createForm) throws Throwable;\n\n    T1 replaceById(T2 id, T1 replace) throws Throwable;\n\n    T1 updateById(T2 id, Map\u003cString, Object\u003e fields) throws Throwable;\n\n    T1 get(T2 id) throws Throwable;\n\n    List\u003cT1\u003e getAll() throws Throwable;\n\n    void deleteById(T2 id) throws Throwable;\n}\n```\n\n### Controllable Example\n\n- Controllable 을 사용하기 위해서는 'AbstractControllable' 을 상속 받는다.\n- 상속받아 새로 만든 Class의 생성자를 통해 Servieable Bean을 주입한다.\n- @SimplyControllableResponse 은 Controller Advice를 활성화한다. Advice에서 에러처리는 하기 Response Code를 참조한다.\n\n```java\n\n@RestController\n@SimplyControllableResponse\n@RequestMapping(\"/users\")\npublic class UserController extends AbstractControllable\u003cUser, Long\u003e {\n    public UserController(UserService service) {\n        super(service);\n    }\n\n}\n```\n\n### Controllable의 처리완료 Response Code\n\n|Method|ResponseCode|Reason|Comment|\n|---|---|---|---|\n|POST|201 Created|성공|\n|PUT|200 OK|성공|\n|PATCH|200 OK|성공|\n|DELETE|204 No Contents|성공||\n\n### Controllable의 처리실패 Response Code\n\n|Method|ResponseCode|Reason|Comment|\n|---|---|---|---|\n|POST|400 Bad Request|실패|규격 오류|\n|POST|409 Conflict|실패|이미 존재함|\n|PUT|404 Not Found|실패|컨텐츠 미존재|\n|PATCH|404 No Contents|실패|컨텐츠 미존재|\n|PATCH|400 Bad Request|실패|규격 오류|\n|undefined|500 Internal Server Error|실패|\n\n# Eventable\n\n* Eventable은 Application 간에 변경된 Entity를 Provisioning 및 Event Driven을 지원한다.\n* Application 간의 통신은 Kafka를 Broker로 사용한다.\n\n## Eventable 의 구성\n\n* Entity의 Entity의 Ownership이 있는 Producer Application은 '@EnableSimplyProducer' annotation을 통해 활성화한다.\n* Entity를 사용하는 Consumer Application은 'AbstractSimplyConsumer' 를 상속받아 사용한다.\n\n## Producer\n\n* Using \"@EnableSimplyProducer\" annotation, activate producer features.\n\n```java\n\n@EnableSimplyProducer\n@SpringBootApplication\npublic class Application {\n\n    public static void main(String[] args) {\n        SpringApplication.run(Application.class, args);\n    }\n}\n```\n\n### Entity의 정의\n\n* 일반적인 JPA Entity형식이지만 Event Driven이 필요한 Entity는 Eventable interface를 적용한다.\n\n```java\n\n@Getter\n@Setter\n@ToString\n@Entity\npublic class User implements SimplyEntity\u003cLong\u003e {\n    @Id\n    @GeneratedValue(strategy = GenerationType.AUTO)\n    private Long id;\n\n    private String name;\n\n    @NotNull\n    @Column(unique = true)\n    private String email;\n}\n```\n\n### @SimplyProducer Annotation\n\n* Simply Serviceable 을 시용하는 Service Class를 정의할 때 @SimplyProducer를 사용해 Event를 발행할 Service를 구현할 수 있다.\n* @SimplyProducer(\"user\") 발행될 Topic은 \"user\" 와 같이 지정한다.\n\n```java\n\n@SimplyProducer(\"user\")\n@Service\npublic class UserService extends AbstractServiceable\u003cUser, Long\u003e {\n\n    protected UserService(UserRepository repository) {\n        super(repository);\n    }\n}\n```\n\n## Consumer\n\n* Consumer는 동일한 상의 User를 전달 받기 위해, Producer에서 생성한 User Class를 사용한다. Gradle이나 Maven의 Module을 이용하는 것을 권장한다.\n\n### Entity의 정의\n\n* 일반적인 JPA Entity형식이지만 Event Driven이 필요한 Entity는 Eventable interface를 적용한다.\n\n```java\n\n@Getter\n@Setter\n@ToString\n@Entity\npublic class User implements SimplyEntity\u003cLong\u003e {\n    @Id\n    private Long id;\n\n    private String name;\n\n    @NotNull\n    @Column(unique = true)\n    private String email;\n}\n```\n\n## Listener의 구현\n\n* Producer가 발행하 event는 AbstractSimplyConsumer 통해 전달 받을 수 있다.\n\n### SimplyConsumer를 이용한 Entity 복제 예시\n```java\n@Slf4j\n@Component\npublic class UserListener extends AbstractSimplyConsumer\u003cUser, Long\u003e {\n    private static String         TOPIC = \"user\";\n    private final  UserRepository repository;\n\n    protected UserListener(UserRepository repository) {\n        super(TOPIC, User.class);\n        this.repository = repository;\n    }\n    \n    @SneakyThrows\n    @Override\n    public void on(SimplyEventableMessage\u003cUser\u003e message) {\n        switch (message.getEventType()) {\n            case \"CREATE\":\n            case \"UPDATE\":\n                User user = convertToEntity(message.getPayload(), User.class);\n                repository.save(user);\n                break;\n            case \"DELETE\":\n                repository.deleteById(Long.valueOf(message.getKey()));\n                break;\n            default:\n                log.error(\"messsage {}\", message);\n        }\n    }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpotatowhite%2Fsimply-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpotatowhite%2Fsimply-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpotatowhite%2Fsimply-starter/lists"}