Proof of concept of a scalable microservice architecture using DDD / CQRS / Repository pattern
Tech Stack: Nestjs, Typescript, Redis, gRPC, Socket.io, Nx, Pm2, RabbitMQ, MongoDB
yarn install
yarn global pm2 @nrwl/cli
docker run -d -p 6379:6379 redis
yarn start:build-all
yarn start:prod-all
After creating user, create chat room by using the username of the receiver as a route param. i.e. /chat/user1
- Client: using socket.io to communicate with the gateway
- Gateway: using gRPC to connect to the Chat Service
- Chat Service: using Redis as in-memory for storage only and connects through rabbitmq to Chat History Service for permanent storage
- Chat History Service: permanent storage using mongodb (or elasticsearch at some point)
- application
- commands
- controllers
- events
- queries
- sagas
- domain
- entities
- contracts
- infrastucture
- repositories
- core: configuration files for the 3rd party libs (apollo client, etc)
- components: react components. each component is structred as: components/index/styles
- pages: represents application pages. each page is independent from each other and is structed like a component. (also includes routes)
- store: state managment related files:
- redux:
- actions
- reducers
- middleware
- effects
- selectors
- types
- apollo:
- containers
- selectors
- redux:
- services: api calls, graphql queries/mutations
- utils
- constants
- context: hocs and context api
- hooks
- core: configuration files for the 3rd party libs (apollo client, etc)
- component lib: react components. each component is structred as: components/index/styles
- atoms
- molecules
- organisms (error handers etc)
- components: same as component lib, but for app specific components and
- organisms
- store: global state managment related files:
- redux:
- actions
- reducers
- middleware
- effects
- selectors
- types
- apollo:
- containers
- selectors
- redux:
- services: api calls, graphql queries/mutations
- utils: shared utils
- constants: shared constants
- context: hocs and context api
- hooks: shared hooks
- modules: in most cases represents application pages, also contains an app module which contains app logic (routes, themes, appbar). each page is independent from each other
- home
- store: state managment related files:
- redux:
- actions
- reducers
- middleware
- effects
- selectors
- types
- apollo:
- containers
- selectors
- redux:
- services: api calls, graphql queries/mutations
- utils
- constants
- context: hocs and context api
- hooks
- componentes: organisms, layouts are in component folder
- Component.ts: page is in top level
- index.ts
- store: state managment related files:
- routes.tsx
- index.ts
- home
NOTE: everything in top level (shared components, hooks, utils) must be well documented using storybook, jsdoc
NOTE: store, services, utils, constants, context, hooks can be split into shared lib if they are not app specific
NOTE: for component development follow atomic design for exmplanation atomic design
Library containing contract interfaces from each service
Library containing proto files and ts interfaces for grpc