Skip to content

Commit

Permalink
[205] Use Spring Modulith and JMolecules to detail the architecture o…
Browse files Browse the repository at this point in the history
…f the project

Bug: #205
Signed-off-by: Stéphane Bégaudeau <[email protected]>
  • Loading branch information
sbegaudeau committed Sep 13, 2023
1 parent 3ff12f3 commit 481ffb9
Show file tree
Hide file tree
Showing 114 changed files with 767 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.svalyn.studio.application.controllers.viewer;

import com.svalyn.studio.application.services.account.api.IAccountService;
import com.svalyn.studio.domain.authentication.IUser;
import com.svalyn.studio.domain.account.IUser;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package com.svalyn.studio.application.listeners.notification;

import com.svalyn.studio.domain.account.events.AccountModifiedEvent;
import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import com.svalyn.studio.domain.notification.Notification;
import com.svalyn.studio.domain.notification.repositories.INotificationRepository;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package com.svalyn.studio.application.listeners.notification;

import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import com.svalyn.studio.domain.notification.Notification;
import com.svalyn.studio.domain.notification.repositories.INotificationRepository;
import com.svalyn.studio.domain.organization.events.OrganizationCreatedEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package com.svalyn.studio.application.listeners.notification;

import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import com.svalyn.studio.domain.notification.Notification;
import com.svalyn.studio.domain.notification.repositories.INotificationRepository;
import com.svalyn.studio.domain.organization.Membership;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package com.svalyn.studio.application.listeners.notification;

import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import com.svalyn.studio.domain.notification.Notification;
import com.svalyn.studio.domain.notification.repositories.INotificationRepository;
import com.svalyn.studio.domain.organization.Membership;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package com.svalyn.studio.application.listeners.notification;

import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import com.svalyn.studio.domain.notification.Notification;
import com.svalyn.studio.domain.notification.repositories.INotificationRepository;
import com.svalyn.studio.domain.organization.Membership;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import com.svalyn.studio.domain.account.AuthenticationTokenCreated;
import com.svalyn.studio.domain.account.repositories.IAccountRepository;
import com.svalyn.studio.domain.account.services.api.IAccountUpdateService;
import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.svalyn.studio.domain.Failure;
import com.svalyn.studio.domain.Success;
import com.svalyn.studio.domain.account.repositories.IAccountRepository;
import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import com.svalyn.studio.domain.notification.Notification;
import com.svalyn.studio.domain.notification.NotificationStatus;
import com.svalyn.studio.domain.notification.repositories.INotificationRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import com.svalyn.studio.domain.Failure;
import com.svalyn.studio.domain.Success;
import com.svalyn.studio.domain.account.repositories.IAccountRepository;
import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import com.svalyn.studio.domain.message.api.IMessageService;
import com.svalyn.studio.domain.organization.Invitation;
import com.svalyn.studio.domain.organization.Organization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import com.svalyn.studio.domain.Failure;
import com.svalyn.studio.domain.Success;
import com.svalyn.studio.domain.account.repositories.IAccountRepository;
import com.svalyn.studio.domain.authentication.UserIdProvider;
import com.svalyn.studio.domain.account.UserIdProvider;
import com.svalyn.studio.domain.organization.Organization;
import com.svalyn.studio.domain.organization.repositories.IOrganizationRepository;
import com.svalyn.studio.domain.organization.services.api.IOrganizationCreationService;
Expand Down
43 changes: 43 additions & 0 deletions backend/svalyn-studio-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-bom</artifactId>
<version>1.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jmolecules</groupId>
<artifactId>jmolecules-bom</artifactId>
<version>2023.1.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -78,5 +97,29 @@
<artifactId>org.eclipse.emf.ecore.xmi</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-core</artifactId>
</dependency>
<dependency>
<groupId>org.jmolecules</groupId>
<artifactId>jmolecules-ddd</artifactId>
</dependency>
<dependency>
<groupId>org.jmolecules</groupId>
<artifactId>jmolecules-events</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-starter-test</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.svalyn.studio.domain.account.events.AuthenticationTokenCreatedEvent;
import com.svalyn.studio.domain.account.events.AuthenticationTokenModifiedEvent;
import com.svalyn.studio.domain.account.events.OAuth2MetadataCreatedEvent;
import com.svalyn.studio.domain.authentication.ProfileProvider;
import org.jmolecules.ddd.annotation.AggregateRoot;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.domain.Persistable;
Expand All @@ -48,6 +48,7 @@
*
* @author sbegaudeau
*/
@AggregateRoot
@Table(name = "account")
public class Account extends AbstractValidatingAggregateRoot<Account> implements Persistable<UUID> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.svalyn.studio.domain.account;

import org.jmolecules.ddd.annotation.Entity;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;

Expand All @@ -31,6 +32,7 @@
*
* @author sbegaudeau
*/
@Entity
@Table(name = "authentication_token")
public class AuthenticationToken {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Stéphane Bégaudeau.
* Copyright (c) 2022-2023 Stéphane Bégaudeau.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -16,7 +16,7 @@
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.svalyn.studio.domain.authentication;
package com.svalyn.studio.domain.account;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.svalyn.studio.domain.account;

import org.jmolecules.ddd.annotation.Entity;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;

Expand All @@ -31,6 +32,7 @@
*
* @author sbegaudeau
*/
@Entity
@Table(name = "oauth2_metadata")
public class OAuth2Metadata {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.svalyn.studio.domain.account;

import org.jmolecules.ddd.annotation.Entity;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;

Expand All @@ -31,6 +32,7 @@
*
* @author sbegaudeau
*/
@Entity
@Table(name = "password_credentials")
public class PasswordCredentials {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.svalyn.studio.domain.authentication;
package com.svalyn.studio.domain.account;

import com.svalyn.studio.domain.Profile;
import org.springframework.security.core.Authentication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Stéphane Bégaudeau.
* Copyright (c) 2022-2023 Stéphane Bégaudeau.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -16,9 +16,8 @@
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.svalyn.studio.domain.authentication;
package com.svalyn.studio.domain.account;

import com.svalyn.studio.domain.account.Account;
import org.springframework.data.jdbc.core.mapping.AggregateReference;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.svalyn.studio.domain.Profile;
import com.svalyn.studio.domain.account.Account;
import jakarta.validation.constraints.NotNull;
import org.jmolecules.event.annotation.DomainEvent;

import java.time.Instant;
import java.util.UUID;
Expand All @@ -30,6 +31,7 @@
*
* @author sbegaudeau
*/
@DomainEvent
public record AccountCreatedEvent(
@NotNull UUID id,
@NotNull Instant createdOn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.svalyn.studio.domain.Profile;
import com.svalyn.studio.domain.account.Account;
import jakarta.validation.constraints.NotNull;
import org.jmolecules.event.annotation.DomainEvent;

import java.time.Instant;
import java.util.UUID;
Expand All @@ -31,6 +32,7 @@
*
* @author sbegaudeau
*/
@DomainEvent
public record AccountDeletedEvent(
@NotNull UUID id,
@NotNull Instant createdOn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.svalyn.studio.domain.Profile;
import com.svalyn.studio.domain.account.Account;
import jakarta.validation.constraints.NotNull;
import org.jmolecules.event.annotation.DomainEvent;

import java.time.Instant;
import java.util.UUID;
Expand All @@ -30,6 +31,7 @@
*
* @author sbegaudeau
*/
@DomainEvent
public record AccountModifiedEvent(
@NotNull UUID id,
@NotNull Instant createdOn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.svalyn.studio.domain.Profile;
import com.svalyn.studio.domain.account.Account;
import jakarta.validation.constraints.NotNull;
import org.jmolecules.event.annotation.DomainEvent;

import java.time.Instant;
import java.util.UUID;
Expand All @@ -31,6 +32,7 @@
*
* @author sbegaudeau
*/
@DomainEvent
public record AuthenticationTokenCreatedEvent(
@NotNull UUID id,
@NotNull Instant createdOn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.svalyn.studio.domain.Profile;
import com.svalyn.studio.domain.account.Account;
import jakarta.validation.constraints.NotNull;
import org.jmolecules.event.annotation.DomainEvent;

import java.time.Instant;
import java.util.UUID;
Expand All @@ -31,6 +32,7 @@
*
* @author sbegaudeau
*/
@DomainEvent
public record AuthenticationTokenModifiedEvent(
@NotNull UUID id,
@NotNull Instant createdOn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.svalyn.studio.domain.Profile;
import com.svalyn.studio.domain.account.Account;
import jakarta.validation.constraints.NotNull;
import org.jmolecules.event.annotation.DomainEvent;

import java.time.Instant;
import java.util.UUID;
Expand All @@ -31,6 +32,7 @@
*
* @author sbegaudeau
*/
@DomainEvent
public record OAuth2MetadataCreatedEvent(
@NotNull UUID id,
@NotNull Instant createdOn,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2023 Stéphane Bégaudeau.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/**
* The account bounded context.
*
* @author sbegaudeau
*/
@ApplicationModule(
allowedDependencies = { "message::api" }
)
package com.svalyn.studio.domain.account;

import org.springframework.modulith.ApplicationModule;
Loading

0 comments on commit 481ffb9

Please sign in to comment.