How stemmlerjs/ddd-forum works
Main Components
• Frontend Client: Represented by the “public/app” folder. This React.js application uses Redux for state management and Sass for styling. It interacts with the backend via API calls and may include routing (with components like AuthenticatedRoute/UnauthenticatedRoute).
• Backend Server: The backend code lives predominantly under “src” as well as additional modules under “public” (if any are meant to support server side rendering or API endpoints). This portion is subdivided by subdomains:
• Forum Subdomain: Contains the “forum” module with its own domain (models like Post, Comment, Member, Votes), use cases (createPost, upvotePost, replyToComment, etc.), repositories (both interface definitions and Sequelize implementations), DTOs, mappers, and subscriptions.
• Users Subdomain: Covers all user-related functionality (authentication, user creation, login, logout, token refreshing). It has similar layers: domain objects (User, EmailVerificationToken, events), use cases (createUser, login, logout, refreshAccessToken), and adapter/infrastructure components (including Redis based token management).
• Shared/Infrastructure Components: Under directories like “src/shared” (including core utilities, HTTP setup, database configuration, and Redux store configuration), plus Docker configurations (Dockerfile and docker-compose.yml) that orchestrate container-based deployment.
Relationships and Interactions
• The Frontend communicates with the Backend through REST APIs (and possibly GraphQL endpoints defined under “src/shared/infra/http/graphql”).
• The backend follows Clean Architecture: the outer layers (infrastructure and adapter) call into the inner application (use cases) and domain layers, while the domain remains ignorant of the implementation details.
• Within each subdomain, use cases coordinate domain logic using domain objects; they depend on abstract repository interfaces (or “ports”), with concrete implementations provided by the infrastructure (e.g., SequelizeRepo implementations).
• Shared utilities and configurations (from “src/shared”) provide cross-cutting concerns like error handling, middleware, and database configuration.
• Communication flows (e.g., user actions from the frontend trigger API calls to backend controllers that invoke respective use cases).
Architectural Patterns and Design Principles
• Clean Architecture: Separate layers where the domain (business logic) does not depend directly on the infrastructure. Show how application use cases in the “forum” and “users” subdomains are isolated from the specifics of Express, Sequelize, or Redis.
• Domain-Driven Design: Emphasize two main subdomains (“forum” and “users”), each with its own domain objects, events, and business rules.
• Repository Pattern: Illustrate interfaces like IUserRepo, ICommentRepo, and their concrete implementations in the infrastructure layer.
• SOLID Principles: Point out how single-responsibility is enforced in controllers, domain models, mappers, and utility classes.
Relevant Technologies and Frameworks
• Frontend: React, Redux, Sass.
• Backend: Express.js, Sequelize for ORM, Docker (using Dockerfile and docker-compose.yml), Redis for token management.
• Development/Testing Tools: Jest (as seen in jest.config.js), nodemon for development, CircleCI for CI/CD workflows.