Skip to content

Installation Guide

Backend Deployment

Important Prerequisites

Before deploying the backend service, you need to:

  1. Open Tencent Cloud Object Storage (COS) service.
  2. Open Tencent Cloud Cloud Infinite (CI) content moderation service.
  3. Obtain the COS SecretId, SecretKey, and bucket info.
  4. Configure content moderation policies (optional but recommended).

1. Clone Project

bash
git clone <repository-url>
cd backend

2. Configure Database

Create a database and execute the SQL script:

sql
CREATE DATABASE yuemupicture CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE yuemupicture;
-- Execute sql/create_table.sql script in the project

3. Configuration Files

Modify the configurations in src/main/resources/application.yml. The project uses multi-environment config supporting dev, test, and prod.

Main Config (application.yml)

yaml
spring:
  profiles:
    active: dev  # Activate dev/test/prod

# Upload path config
app:
  upload:
    path: ${user.dir}/upload/app  

# Recommendation score config
recommend:
  increment:
    max-size: 500  # Max batch size to prevent overload
  new:
    picture:
      hours: 24  # Pictures within 24h prioritized
  score:
    view: 0.10
    like: 0.10
    comment: 0.10
    share: 0.05
    time-weight: 0.55  # Boost time weight
    time-decay: 0.02   # Time decay rate
    smooth:
      alpha: 0.7       # Smoothing factor
    new-bonus: 1.8     # Bonus multiplier for new pics

# Netty WebSocket Config
netty:
  websocket:
    port: 8124
    boss-threads: 1
    worker-threads: 0
    max-frame-size: 65536
    use-epoll: false
    heartbeat:
      enabled: true
      interval: 30
      timeout: 60

# Knowledge base config
knowledge:
  txt:
    scan-path: classpath:knowledge/
    chunk-size: 500
    es-index: txt_knowledge_base
    init-record-index: txt_kb_init_record

# RAG config
rag:
  retrieval:
    top-k: 3
    similarity-threshold: 0.7
  augmentation:
    max-context-rounds: 8
    max-prompt-length: 3000
  generation:
    temperature: 0.6
    max-tokens: 3000

Dev Environment Config (application-dev.yml)

yaml
server:
  port: 8123
  servlet:
    context-path: /api
    session:
      cookie:
        max-age: 2592000

spring:
  ai:
    deepseek:
      apiKey: YOUR_DEEPSEEK_API_KEY  # Replace with DeepSeek API Key
      apiUrl: https://api.deepseek.com/v1/chat/completions
      model: deepseek-chat
  datasource:
    url: jdbc:mysql://localhost:3306/yuemu_picture?characterEncoding=utf8&useSSL=false
    username: root
    password: YOUR_MYSQL_PASSWORD  # Replace with your MySQL password
  redis:
    database: 10
    host: 127.0.0.1
    port: 6379
    password: YOUR_REDIS_PASSWORD  # Replace with your Redis password
  elasticsearch:
    uris: http://localhost:9201
  mail:
    from: YOUR_EMAIL_ADDRESS
    password: YOUR_EMAIL_PASSWORD
    host: smtp.qq.com

4. Start the Service

bash
mvn clean compile
mvn spring-boot:run

Frontend Deployment

1. Install Dependencies

Ensure you have Node.js 22+ installed.

bash
cd frontend
npm install

2. Environment Variables

Create .env.development or .env.production:

env
VITE_API_BASE_URL=http://localhost:8123/api
VITE_BASE_URL=http://localhost:8123
VITE_APP_TITLE=yuemutuku

3. Run and Build

bash
# Start development server
npm run dev

# Build for production
npm run build

Docker Deployment (Optional)

You can deploy using docker-compose:

yaml
version: '3'
services:
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: root
  redis:
    image: redis:7.0
  elasticsearch:
    image: elasticsearch:8.0.0
    environment:
      - discovery.type=single-node
  backend:
    build: ./backend
    ports:
      - "8123:8123"
  frontend:
    build: ./frontend
    ports:
      - "80:80"

Run docker-compose up -d.

Released under the MIT License.