Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arkitik/radix

Provide the needed infrastructure to build clean Domain-Driven Design (DDD) apps in the Java ecosystem
https://github.com/arkitik/radix

Last synced: 12 days ago
JSON representation

Provide the needed infrastructure to build clean Domain-Driven Design (DDD) apps in the Java ecosystem

Awesome Lists containing this project

README

        

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]





Logo

Radix


Provide the needed infrastructure to build clean Domain-Driven Design (DDD) apps in the Java ecosystem


Explore the docs »




Report Bug
·
Request Feature


Table of Contents



  1. About The Project


  2. Getting Started


  3. Usage

  4. Roadmap

  5. Contributing

  6. License

  7. Contact

  8. Built With

## About The Project

Radix is a lightweight Kotlin framework that provides a blueprint to build clean, easy-to-maintain, and
highly-scalable server-side components. It emphasizes on the idea of isolating the bussiness logic of the app from 3rd
party dependencies (e.g. Spring) by keeping all core business logic in the usecases layer which makes it easy to expose
different kind of services and even port the app into a different framework.





(back to top)

## Getting Started

Add the below dependency to the project's dependency management:

```xml

io.arkitik.radix
radix-dependencies
v1.6.0
pom
import

```

### Prerequisites

* JDK version >= 1.8

## Usage

Let's build a simple `User` domain! To do so, we should start with the abstraction from the identity level and then move
to the implementation.

### 1. Identity:

The identity in simple terms is the abstraction of the entity, it
extends [Identity\][radix-identity-url] and specifies the value of the generic type ID.

```kotlin
interface User : Identity {
override val uuid: String
val username: String
val password: String
}
```

→ it's available through the below dependency:

```xml

io.arkitik.radix
radix-development-identity

```

### 2. Store:

The store is similar to the Data Access Object (DAO) pattern, it allows us to isolate the business layer
from the persistence layer which means you can swap different persistence layers or change the implementation without
affecting the core bussiness of the app! Aside from that, it also provides builders to create/update the entity.

To create our own `UserStore` we should extend from [Store\>][radix-store-url]

```kotlin
interface UserStore : Store {
override fun UserIdentity.save(): UserIdentity
override val storeQuery: StoreQuery
override fun identityCreator(): StoreIdentityCreator
override fun UserIdentity.identityUpdater(): StoreIdentityUpdater
}
```

→ it's available through the below dependency:

```xml

io.arkitik.radix
radix-development-store

```

### 3. Usecase Factory:

The usecase factory allows the consumer to create usecase objects without having to know the details about their
implementation, dependencies, or how they get created.

As a consumer, all you need to know is the signature of the usecase which is basically:

1. What does the usecase do (interpreted from the usecase name).
2. The usecase request.
3. The usecase response.

Let's create our own `UserUsecaseFactory` and add `findUserByUuidUseCase` usecase to it:

```kotlin
interface UserUseCaseFactory : UseCaseFactory {
val findUserByUuidUseCase: FunctionalUseCase
}
```

and the request/response as follows:

```kotlin
data class FindUserRequest(val uuid: String) : UseCaseRequest

data class FindUserResponse(val identity: UserIdentity?) : UseCaseResponse
```

→ it's available through the below dependency:

```xml

io.arkitik.radix
radix-development-usecase

```

### 4. Usecase:

The usecase layer is the brains of the app, the core business logic that your app needs to run and is defined through
contract abstraction in the usecase-factory.

In our case, we have only one factory with one usecase which is `findUserByUuidUseCase`, to implement it we have to
inject the `StoreQuery` available from the `UserStore`.

```kotlin
class FindUserByUuidUseCase(
private val storeQuery: StoreQuery,
) : FunctionalUseCase {
override fun FindUserRequest.process() = FindUserResponse(storeQuery.find(uuid))
}
```

and finally the usecase-factory implementation:
```kotlin
class UserUseCaseFactoryImpl(
userStore: UserStore,
) : BankUseCaseFactory {
override val findUserByUuidUseCase = FindUserByUuidUseCase(userStore.storeQuery)
}
```
----
Of course, don't forget to provide the implementation for the identity (i.e. entity) and the store (i.e. adapter).
For more examples, please refer to the [Documentation][radix-documentation-url].

(back to top)

## Roadmap

- [ ] Complete the [Documentation][radix-documentation-url] files
- [ ] Business Layer
- [ ] Implementation Layer
- [ ] Application Layer

See the [open issues](https://github.com/arkitik/radix/issues) for a full list of proposed features (and known issues).

(back to top)

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any
contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also
simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

(back to top)

## License

Distributed under the Apache License 2.0. See [LICENSE][license-url] for more information.

(back to top)

## Contact

[Ibrahim Al-Tamimi](https://github.com/ibm-iloom) - [email protected]

Project Link: [https://github.com/arkitik/radix](https://github.com/arkitik/radix)

(back to top)

### Built With

[![Kotlin][Kotlin-shield]][kotlin-url]
[![Maven][maven-shield]][maven-url]

(back to top)

[contributors-shield]: https://img.shields.io/github/contributors/arkitik/radix.svg?style=for-the-badge

[contributors-url]: https://github.com/arkitik/radix/graphs/contributors

[forks-shield]: https://img.shields.io/github/forks/arkitik/radix.svg?style=for-the-badge

[forks-url]: https://github.com/arkitik/radix/network/members

[stars-shield]: https://img.shields.io/github/stars/arkitik/radix.svg?style=for-the-badge

[stars-url]: https://github.com/arkitik/radix/stargazers

[issues-shield]: https://img.shields.io/github/issues/arkitik/radix.svg?style=for-the-badge

[issues-url]: https://github.com/arkitik/radix/issues

[license-shield]: https://img.shields.io/github/license/arkitik/radix.svg?style=for-the-badge

[license-url]: https://github.com/arkitik/radix/blob/master/LICENSE

[Kotlin-shield]: https://img.shields.io/badge/kotlin-000000?style=for-the-badge&logo=kotlin&logoColor=purple

[kotlin-url]: https://kotlinlang.org/

[maven-shield]: https://img.shields.io/badge/maven-000000?style=for-the-badge&logo=apachemaven&logoColor=red

[maven-url]: https://maven.apache.org/

[radix-documentation-url]: https://github.com/arkitik/radix/docs/documentation.md

[radix-identity-url]: ./radix-development/radix-development-identity/src/main/java/io/arkitik/radix/develop/identity/Identity.kt

[radix-store-url]: ./radix-development/radix-development-store/src/main/java/io/arkitik/radix/develop/store/Store.kt