Thread Service
I will fast forward for this service. Since the pattern will similar with previous service (User Service). You may check this changes:
Please, directly download/continue from this branch.
Notes:
- I also change other services to add CORS, we need this since the Frontend and our microservices have a different domains.
Testing from Front End
We will need docker-compose.yml
. We build the microservices into docker. This is my setup.
version: '3.9'
services:
redis:
image: redis/redis-stack:6.2.2-v4
restart: always
ports:
- 6379:6379
- 8001:8001
volumes:
- redis-data:/data
networks:
- backend
mongodb:
image: mongo:5
restart: always
networks:
- backend
ports:
- 27017:27017
volumes:
- mongo-data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: secretpass
mongo-express:
image: mongo-express:latest
restart: always
networks:
- backend
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: secretpass
ME_CONFIG_MONGODB_URL: mongodb://root:secretpass@mongodb:27017/
user-services:
build: ./app/user-service
networks:
- backend
ports:
- 9000:80
environment:
ForumApiDatabase__ConnectionString: mongodb://root:secretpass@mongodb:27017
RedisConnectionString: redis://redis:6379
AuthServiceSettings__AuthServiceVerify: http://auth-services:5000/auth/verify
auth-services:
build: ./app/auth-service
networks:
- backend
environment:
NODE_ENV: production
REDIS_CONNECTION_STRING: redis://redis:6379
MONGO_CONNECTION_STRING: mongodb://root:secretpass@mongodb:27017
PORT: 5000
ports:
- 9001:5000
thread-services:
build: ./app/thread-service
networks:
- backend
environment:
ForumApiDatabase__ConnectionString: mongodb://root:secretpass@mongodb:27017
RedisConnectionString: redis://redis:6379
AuthServiceSettings__AuthServiceVerify: http://auth-services:5000/auth/verify
ports:
- 9002:80
volumes:
redis-data:
mongo-data:
networks:
backend:
name: custom_backend
You may run this command to build and turn on our services:
docker compose build # build our images (optional if you've built it)
docker compose up -d # turn on our services
Front End
Initialize Project
npx create-react-app . --template typescript
Populate Your Project
Since the step-by-step will be complex. You may try find out the changes using this PR (Pull Request).
Please, directly download from this branch.
Screenshot
- Home Page
- Home Page (Not Login)
- Create Thread
- Update Profile
This post is in collaboration with Redis.
References (Additional Resources)
- Try Redis Cloud for free
- Watch this video on the benefits of Redis Cloud over other Redis providers
- Redis Developer Hub - tools, guides, and tutorials about Redis
- RedisInsight Desktop GUI
There are many rooms of improvement. As example: Searching Thread using Redis, Searching Popular Thread using Redis (count by upvote and comments), etc.
Thank you
Thanks for reading. I will do some improvement to complete our projects. Here is the list:
- Comment Sections
- User Upvote
- Search Threads (using Redis)
- Popular Threads (using Redis)
- (Bonus) Deployment to AWS
So, please stay tune!
Top comments (0)