Skip to content

LearnDifferent/mtm

Repository files navigation

MTM

MTM is a social bookmarking site built with Spring Boot, MySQL, MyBatis, Redis, Elasticsearch, Vue and Docker

Table of Contents

Technology Stack

Backend

Frontend (mtm-ui)

Features

🔖 Bookmark
  • Bookmark and share web pages
  • Extract basic information of the bookmarked websites
  • Export bookmarks to HTML and import bookmarks from HTML file
  • Add websites shared by others to your bookmarks
  • Make bookmarks private in order to hide bookmarks
  • Count the number of views and comments of bookmarks
  • Filter bookmarked sites
🔍 Search
  • Search bookmarked sites (Support English, Chinese and Japanese)
  • Search all users and view their bookmarks
  • Search all tags using range query
  • Discover trending searches
  • Ingest data from MySQL into Elasticsearch
  • Check the status of data for search
🏠 Home Timeline
  • Displays a stream of paginated bookmarks
  • Choose between viewing the latest bookmarks, bookmarks shared by particular user and all bookmarks except those that are shared by specific user in timeline
  • Discover most-saved web pages within Home
💬 Comment
  • Leave comments on bookmarks shared by users
  • Reply to comments
  • Edit comments and replies
  • View edit history of comments
🏷️ Folksonomy (Social Tagging)
  • Apply public tags to bookmarks
  • View bookmarks associated with a chosen tag
  • View tags of a bookmarked website
  • Discover popular tags
🔔 Notification
  • Push a notification to a specific user when the user receives new replies or new comments
  • User will receive a notification if the user's account has been upgraded or downgraded
  • Push a notification to all users when a new user is created, or a new message is sent by users with admin privilege
  • System notifications that contains user activity
👨‍🔧 Administrative privileges
  • Upgrade or downgrade accounts
  • Push notifications to all users
  • List all visited bookmarks and hide the bookmarks
  • View system logs
  • Delete all data in Elasticsearch
👤 User
  • Token based authentication
  • User profile
  • Reset password
  • Remove an account and all data associated with the account
🍙 Others
  • Support caching
  • Scheduled task
  • Email service

API Documentation

See the API Docs:

More

This API Documentation is generated by smart-doc.

You can modify api-document-config.json to customize the configuration and use mvn -Dfile.encoding=UTF-8 smart-doc:markdown to perform document generation.

Deploy with docker-compose

Clone the repository into a local directory:

# Clone the repository
git clone git@github.com:LearnDifferent/mtm.git

Go into the repository:

cd mtm

Deploy with docker-compose:

docker-compose up -d

Deploy the Front End Application:

Go to mtm-ui and deploy the front end application.

Navigate to MTM:


Related files
More

Note that the Maven Docker Image in Dockerfile is Maven Docker Image with Aliyun Mirror, which will speed up the Maven Build.

You can replace it with the official image by using FROM maven:3.8.4-jdk-11-slim AS mtm-maven.

Run Locally

Pre-Requisites

Ensure pre-requisites are installed:

  • Java 8+
  • Maven 3+
  • MySQL 8.0.17
  • Redis 5.0.5
  • Elasticsearch 7.8.0

Clone the repository:

# Clone this repository into a local directory
git clone git@github.com:LearnDifferent/mtm.git

Basic Configuration

Database

  1. Import init.sql into MySQL
  2. Change the spring.datasource.password in application-dev.yml to your MySQL root user password. For example:
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/mtm?characterEncoding=UTF-8&useTimezone=true&serverTimezone=Asia/Shanghai
    username: root
    password: MyPassword # This means that your MySQL root user password is: MyPassword

Elasticsearch

Download and Install Elasticsearch Plugins:

  1. You can download IK Analysis and Kuromoji from here
  2. Install the Plugins
Installation Guides

Optional Configuration

Email Service

This application has a mail sending function that can send emails containing invitation codes to register admin accounts. However, it's easy to reach the sending limits if the application sends too many emails, so the email service is not configured.

You can configure your own SMTP server if you want to send real emails. You only need to ensure your SMTP server relay feature is turned on and configure application.yml as follows:

spring:
  mail:
    username: # Your Email Address. For Instance: abc@email.com
    password: # Your Email Password.
    host: # Your Email Host. For Instance: smtp.xxx.com

Cache Timeout

The default timeout value of Redis cache is 1 minute. You can set your desired TTL value by modifying RedisCacheConfiguration bean in RedisConfig.java.

You can also specify TTL to cached keys. For example, you can configure TTL values of 10 and 20 seconds for comment:count and empty:user:all respectively by configuring application.yml using the following:

custom-redis:
  cache-configs:
    "[comment:count]": 10 # TTL is 10 seconds
    "[empty:user:all]": 20 # TTL is 20 seconds

Run the Application

Please don't forget to start mtm-ui, MySQL, Redis and Elasticsearch before running the application

Run the backend service from Maven directly using the Spring Boot Maven plugin:

./mvnw spring-boot:run -P dev

The backend service is now running on localhost:8080 and the frontend client is running on localhost:80

License

Released under the Apache License 2.0.