appointment_system/backend
2026-03-04 01:14:52 +08:00
..
src 细节优化 2026-03-04 01:14:52 +08:00
.dockerignore 1 2025-12-11 22:50:18 +08:00
.env 添加服务端 2025-12-20 18:04:10 +08:00
.env.example 添加服务端 2025-12-20 18:04:10 +08:00
.eslintrc.json 1 2025-12-11 22:50:18 +08:00
.gitignore 配置打包环境 2025-12-20 17:10:41 +08:00
.prettierrc.json 1 2025-12-11 22:50:18 +08:00
add-commission-rate-field.js 逻辑修改 2026-01-24 00:28:20 +08:00
add-cost-fields.js 管理后台 2026-03-04 00:17:21 +08:00
add-payment-proof-field.js 逻辑修改 2026-01-24 00:28:20 +08:00
add-withdrawal-payment-proof-field.js 逻辑修改 2026-01-24 00:28:20 +08:00
ADMIN_AUTH.md 1 2025-12-11 22:50:18 +08:00
create-config-table.js 1 2025-12-11 22:50:18 +08:00
Dockerfile back 2025-12-20 18:34:31 +08:00
jest.config.js 1 2025-12-11 22:50:18 +08:00
package.json back 2025-12-20 18:34:31 +08:00
README.md 1 2025-12-11 22:50:18 +08:00
REDIS_SETUP.md 1 2025-12-11 22:50:18 +08:00
RESPONSE_FORMAT.md 1 2025-12-11 22:50:18 +08:00
run-migration.js 默认头像 2025-12-22 14:52:35 +08:00
test-config-api.js 1 2025-12-11 22:50:18 +08:00
test-config-update.js 1 2025-12-11 22:50:18 +08:00
UPLOAD_FEATURE.md 1 2025-12-11 22:50:18 +08:00

Overseas Appointment Backend API

Backend API for the overseas appointment mini program system.

Tech Stack

  • Runtime: Node.js 18+
  • Framework: Express.js 4.x
  • Database: MySQL 8.0
  • Cache: Redis 7.0
  • ORM: Sequelize 6.x
  • Authentication: JWT
  • Testing: Jest + Supertest + fast-check

Project Structure

backend/
├── src/
│   ├── config/          # Configuration files
│   │   ├── database.js  # Sequelize database configuration
│   │   ├── env.js       # Environment variables
│   │   └── logger.js    # Winston logger configuration
│   ├── middleware/      # Express middleware
│   ├── models/          # Database models (Sequelize)
│   │   ├── index.js     # Model associations and exports
│   │   ├── User.js      # User model
│   │   ├── Category.js  # Service category model
│   │   ├── Service.js   # Service model
│   │   ├── Appointment.js # Appointment model
│   │   ├── Invitation.js  # Invitation model
│   │   ├── Withdrawal.js  # Withdrawal model
│   │   ├── Notification.js # Notification model
│   │   └── Admin.js     # Admin user model
│   ├── migrations/      # Database migrations
│   ├── seeders/         # Database seed files
│   ├── routes/          # API routes
│   ├── controllers/     # Route controllers
│   ├── services/        # Business logic
│   ├── utils/           # Utility functions
│   ├── tests/           # Test files
│   ├── app.js           # Express app setup
│   └── server.js        # Server entry point
├── logs/                # Application logs
├── uploads/             # Uploaded files
├── .env                 # Environment variables
├── .env.example         # Environment variables template
├── package.json         # Dependencies
└── README.md            # This file

Getting Started

Prerequisites

  • Node.js 18 or higher
  • MySQL 8.0
  • Redis 7.0

Installation

  1. Install dependencies:
npm install
  1. Copy environment variables:
cp .env.example .env
  1. Configure your .env file with your database and Redis credentials

  2. Create the database:

mysql -u root -p
CREATE DATABASE overseas_appointment;
  1. Start the development server:
npm run dev

The server will start on http://localhost:3000

Database Models

The system includes the following database models:

  • User: User accounts with WeChat authentication, language preferences, and invitation codes
  • Category: Service categories (airport, train, hotel, etc.) with multi-language support
  • Service: Appointment services with multi-language titles and descriptions
  • Appointment: User appointment bookings with status tracking
  • Invitation: Invitation relationships and reward tracking
  • Withdrawal: User withdrawal requests with admin review workflow
  • Notification: System notifications with multi-language content
  • Admin: Admin users for the management portal

All models support:

  • UUID primary keys
  • Automatic timestamps (created_at, updated_at)
  • Multi-language fields (Chinese, English, Portuguese) where applicable
  • Proper foreign key relationships and indexes

Available Scripts

  • npm start - Start production server
  • npm run dev - Start development server with auto-reload
  • npm test - Run tests
  • npm run test:watch - Run tests in watch mode
  • npm run lint - Check code style
  • npm run lint:fix - Fix code style issues
  • npm run format - Format code with Prettier

API Endpoints

Health Check

  • GET /health - Check server health status

API Documentation

API documentation will be available at /api-docs once implemented.

Testing

Run the test suite:

npm test

Run tests with coverage:

npm test -- --coverage

Security Features

  • Helmet: Security headers
  • CORS: Cross-origin resource sharing
  • Rate Limiting: 100 requests per minute per IP
  • Input Validation: Joi validation
  • JWT Authentication: Secure token-based auth
  • Request Logging: Winston logger

Environment Variables

See .env.example for all available configuration options.

License

ISC