• Stars
    star
    1,931
  • Rank 24,002 (Top 0.5 %)
  • Language
    TypeScript
  • License
    ISC License
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hacker news-inspired forum app built with TypeScript using DDD practices from solidbook.io.

DDDForum.com

A SOLID hackernews-inspired forum site built with TypeScript using the clean architecture and DDD best practices.

DDDForum

About

DDDForum.com is the application that we build in solidbook.io - The Software Design and Architecture Handbook.

Running the project

  1. Install and start Docker if you haven't already.
  2. Copy the .env template file. Feel free to change passwords and app secrets.
cp .env.template .env
  1. Build and run the image to run the backend services.
docker-compose up
  1. Open up an additional console and then run:
npm run setup:dev
npm run start:both

You can visit the app by going to http://localhost:3000.

Demo

You can visit the site here.

Note: It's currently deployed on free tier Heroku, which has some undesirable side-effects like shutting off the server during periods of inactivity. So if it's down for you, refresh a couple of times. Thinking about migrating this to a serverless architecture later on.

Built with

Backend

  • Sequelize - The ORM for Node.js
  • Express.js - Lightweight webserver
  • Redis - For holding onto JWT tokens and refresh tokens

Frontend

Architecture

We built this based on the Clean Architecture, SOLID principles, and Domain-Driven Design best practices using TypeScript.

Clean architecture

There's obviously a lot that went into building this from front to back.

The Clean Architecture is a way to reason about where different types of application logic belongs.

Frame 8 (1)

There's a lot more to learn about the clean architecture, but for now- just know that it's a way to really separate the concerns of everything that goes into building complex enterprise applications. You'll never see any infrastructure-related code alongside domain layer code.

The clean architecture, when combined with Domain-Driven Design, is very powerful :)

In DDD, we build applications on top of a number of subdomains.

Subdomains

A subdomain is a cohesive unit of code that represents exactly one core concept and is responsible for a specific set of concerns in an application architecture. For example, every appliciation has a users subdomain. That's responsible for users, identity & access management, authentication, authorization, etc. Sometimes you don't want to build that yourself. Sometimes you can go with an off-the-shelf solution like Auth0. But there are subdomains in your application that you cannot simply outsource. These are the family jewels; the thing that's actually novel about your app. This is the subdomain that no one (except you) can code. Know why? Because only you have the domain knowledge to build it exactly the way that it should be built. You understand the domain.

In DDDForum, we have 2 subdomains: The users subdomain and the forum subdomain.

Frame 3 (1)

Each subdomain has a:

  • domain layer: where the highest-level policy, domain objects, and domain rules belong (user, email, etc)
  • application layer: where the use cases / features that utilize domain objects belong (createUser, login, etc)
  • adapter layer: where we define abstractions so that application layer code can interact with infrastructure layer concepts, without actually requiring on infrastructure (because that would break the dependency rule). Here we write things like IUserRepo - repository adapter, IJWTTokenService - an abstraction of a cache (redis) that manages tokens, etc.
  • infrastructure layer: where we create concrete implementations of the abstractions from the adapter layer so that they can be spun up at runtime thanks to the power of polymorhpism :) (more on this later).

If you haven't already, I recommend you read this article on use cases and subdomains.

Let's identify some of the actual concepts that exist in each subdomain.

users subdomain

In the users subdomain, we're only concerned with concepts that are related to authentication, roles, etc. Here are a few examples of classes and concepts that exist at each layer.

forum subdomain

In the forum subdomain, we're only concerned with concepts that have to do with building a forum. You won't see any domain concepts from the user in forum. In the forum subdomain, the concept most equivalent to a user, is a member.

Here are a few examples of concepts from the forum subdomain.

  • domain layer: member, comment, post, postVote, commentVote, commentVotesChanged
  • application layer: replyToComment, getMemberByUserName, upvotePost, downvotePost
  • adapter layer: ICommentRepo, IPostRepo, IMemberRepo
  • infrastructure layer: SequelizeCommentRepo, SequelizePostRepo, SequelizeMemberRepo

Project visualization

Here's a large-scale visualization of the repo. As I put more time into the front-end, it may change a little bit.

Visualization of this repo

Contributing

DDDForum is an open source project, and contributions of any kind are welcome! Open issues, bugs, and enhancements are all listed on the issues tab and labeled accordingly. Feel free to open bug tickets and make feature requests. Easy bugs and features will be tagged with the good first issue label.

Contributors

Thanks goes to these wonderful people (emoji key):


Anthony Denneulin

💻

Khalil Stemmler

💻 🐛 📖 🚇 🤔

Faisol Chehumar

💻

Trung Tran

🚇

This project follows the all-contributors specification. Contributions of any kind welcome!

License

This project is licensed under the ISC License - see the LICENSE.md file for details

More Repositories

1

software-design-and-architecture-roadmap

🧱 The software design and architecture roadmap for any developer
2,841
star
2

white-label

A Vinyl-Trading enterprise app built with Node.js + TypeScript using Domain-Driven Design
TypeScript
1,282
star
3

simple-typescript-starter

The most basic TypeScript starter I could think of
TypeScript
851
star
4

solid-email-microservice

Learn the SOLID design principles by building a robust email microservice
TypeScript
139
star
5

the-software-essentialist

The official course repo for The Software Essentialist course students
TypeScript
66
star
6

how-to-test-code-reliant-on-apis

TypeScript
61
star
7

dddforumv2

TypeScript
40
star
8

solidbook-tdd-examples

TDD examples and solutions from solidbook.io - The Software Design and Architecture Handbook
38
star
9

developer-list

My personal list of developer and designer links and tools.
37
star
10

stemmlerjs-graph

🛰️ My personal GraphQL Data Graph
TypeScript
28
star
11

serverless-graphql-netlify-starter

⚡A serverless GraphQL API deployed on Netlify
JavaScript
25
star
12

ac3-todos-tutorial

Learn Apollo Client 3 by building a todos app
TypeScript
22
star
13

serverless-typescript-graphql-netlify-starter

⚡A serverless TypeScript GraphQL API deployed on Netlify
TypeScript
19
star
14

apollo-cloud-file-uploads

☝️ Uploading files to S3, Cloudinary, and other cloud services using Apollo Server and Apollo Client (Hooks).
TypeScript
19
star
15

design-patterns

Classical design patterns cheat sheet in JavaScript
JavaScript
19
star
16

apollo-examples

A collection of Apollo Client examples for blog posts and demonstration purposes
TypeScript
14
star
17

checkers

TypeScript
13
star
18

khalilstemmler.com

🔥 2018 - Professional portfolio and blog.
JavaScript
11
star
19

music-metadata

Get album / artist artwork and metadata for use in music apps
JavaScript
10
star
20

Asterisk-Twilio

Send SMS to mobile phone on missed VoIP calls.
JavaScript
7
star
21

UnitGraphTS

Lightweight Typescript Graph Library
TypeScript
6
star
22

badfaith

🗿 A goth-pop EP about Existentialism & Absurdism. Influenced by Jean-Paul Sartre, Albert Camus, and recording techniques of the 1980s.
CSS
5
star
23

mail-microservice

📧 Simple mail microservice using AWS SES.
JavaScript
4
star
24

tdd-essentials

TypeScript
4
star
25

course-repo

JavaScript
3
star
26

os-design-assign-2

Assignment #2 - SYST44288 - Operating Systems Design And Systems Programming
Java
3
star
27

shopify-node-starter

Embedded Shopify starter app
JavaScript
3
star
28

studyspots

JavaScript
3
star
29

react-quant-breakdown

A React component to visualize the quantitative breakdown of a process
JavaScript
3
star
30

code-samples

Selected code samples / interesting snippets of my work from professional projects
JavaScript
3
star
31

software-essentialist

TypeScript
2
star
32

react-joi-forms

Model-based React form validation with Joi
TypeScript
2
star
33

should-i-use-typescript

Interactive website to answer the burning question, "should I use TypeScript?"
JavaScript
2
star
34

aws-realtime-network-monitor

Node.js + AngularJS + AWS Cloudwatch
JavaScript
2
star
35

glitchie.js

JavaScript library for creating glitch art
JavaScript
1
star
36

react-exit-modal

A modal that triggers upon exit
CSS
1
star
37

os-design-assign-1

SYST 44288 - Operating System Design and Implementation
C
1
star
38

Basic-Node-Auth

Passport.JS + MongoDB Authentication
JavaScript
1
star
39

glitchie

🖼️ A small GUI application written in Java that allows you to databend photos and undo databends
Java
1
star