| .. | ||
| src | ||
| .dockerignore | ||
| .env.example | ||
| .eslintrc.json | ||
| .gitignore | ||
| .prettierrc.json | ||
| ADMIN_AUTH.md | ||
| create-config-table.js | ||
| Dockerfile | ||
| jest.config.js | ||
| package.json | ||
| README.md | ||
| REDIS_SETUP.md | ||
| RESPONSE_FORMAT.md | ||
| test-config-api.js | ||
| test-config-update.js | ||
| UPLOAD_FEATURE.md | ||
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
- Install dependencies:
npm install
- Copy environment variables:
cp .env.example .env
-
Configure your
.envfile with your database and Redis credentials -
Create the database:
mysql -u root -p
CREATE DATABASE overseas_appointment;
- 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 servernpm run dev- Start development server with auto-reloadnpm test- Run testsnpm run test:watch- Run tests in watch modenpm run lint- Check code stylenpm run lint:fix- Fix code style issuesnpm 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