I started this project as a way to make myself more familiar with the backend side of Full Stack using Nestjs, Postgres and TypeORM. Later on (currently) this has become my Final Year Project for BCA.
The frontend part of this project can be found in this repository.
There may be a lot of things I have made mistake and a lot of things that I may be able to improve. I will leave it to future Rameshwor.
RecBlog uses Nestjs a framework of Nodejs to serve as a backend. Postgres has been used as database and TypeORM for the query.
There are main four parts in this project User, Admin, Posts, and Tags. Likewise three main tables in database user
, post
and tags
. As many-to-many relationship has been used to relate these tables. there are pivot tables as well.
The user authentication is based on roles and the Admin is called SUPER_ADMIN
.
This system uses content-based filtering to recommend blog posts based on user preferences.
Each post and user is represented as a vector of tags. Instead of flat binary values, tag weights are computed using Inverse Tag Frequency (ITF):
This ensures that rarer tags contribute more to the similarity calculation.
To compare user and post vectors, we use cosine similarity:
Final Formula will look something like this:
Only posts above a certain threshold are returned as recommendations. Currently that is 0.33
.
To run this project, you will need to add the following environment variables to your .env file
DATABASE_TYPE = postgres
DATABASE_HOST = <user_hostname>
DATABASE_PORT = <user_port_number>
DATABASE_NAME = <your_database_name>
DATABASE_USER = <user_postgres_username>
DATABASE_PASSWORD = <user_postgres_password>
APP_PORT = 8080
APP_ENV = <env>
DATABASE_SYNCHRONIZE = false
JWT_SECRET = secret_key
RECOMMENDATION_SIMILARITY_THRESHOLD = 0.33
RECOMMENDATION_MIN_RESULTS = 6
# install dependencies
$ yarn install
Clone the project
# development
$ yarn run start
# watch mode
$ yarn dev
# production mode
$ yarn run start:prod