This project is a robust social networking platform built using NestJS. It features a microservices architecture, integrating technologies Redis for caching. The platform includes modules for user management, article handling, profiles, tags, and media management, showcasing a scalable and modular design.
- NestJS
- TypeScript
- Redis
- PostgreSQL
- Docker
The application adopts a microservices architecture with distinct modules:
- User Module: Manages user registration, authentication, and profile operations.
- Article Module: Handles article creation, updates, deletion, and commenting features.
- Profile Module: Manages user profiles.
- Tag Module: Responsible for tag management associated with articles.
- Media Module: Handles uploading and retrieving media content.
- Persistence Module: Manages database connections and migrations.
- Redis Module: Handles cached user login.
Each module follows the CLEAN architecture, promoting separation of concerns and maintainability.
- Node.js
- Docker
- Redis server
- PostgreSQL server
- Kafka server
Clone the repository and install dependencies:
git clone https://github.com/anhtt2211/social-api.git
cd social-api
yarn install
Build images
docker-compose build
Run on docker
docker-compose up
Debezium is used in this project to enable near real-time data streaming from PostgreSQL to Elasticsearch.
Ensure that you have Kafka and Zookeeper running before proceeding.
To configure Debezium, follow these steps:
Run the shell scripts to set up Elasticsearch indexes and Debezium connectors.
bash cdc/es-indexes/indexes_mappings.sh
bash cdc/create_connectors.sh
cdc/es-indexes/indexes_mappings.sh
: Creates index mappings in Elasticsearch to store CDC data.cdc/create_connectors.sh
: Configures Debezium connectors to capture changes from PostgreSQL and stream them to Kafka.
To verify that the connectors are working correctly, you can check the status of registered connectors:
curl -s -X GET http://localhost:8083/connectors | jq .
yarn start
Auto-Generate migration
npm run migration:generate -c <orm_connection> -n <migration_name>
Swagger-based API documentation is available at http://localhost:8000/docs
.
Refer to the env.example file for necessary environment variables.