A fully-featured backend system for a pet social application, supporting user management, pet management, lost pet publishing, social features, and more.
- Java 17+
- Maven 3.6+
- Docker & Docker Compose
- Git
# 1. Clone the project
git clone <your-repo-url>
cd bk
# 2. Start the local development environment
./start-local.sh
# 3. Wait for startup to complete, then run tests
./quick-test.sh
- API Service: http://localhost:8080
- Database Management: http://localhost:8082 (Adminer)
- Redis Management: http://localhost:8081 (Redis Commander)
- β Email registration and login
- β SMS verification code login
- β Third-party login (Facebook, Google)
- β JWT dual token authentication
- β User information management
- β Password reset
- β Pet profile management
- β Multi-pet support
- β Pet photo upload
- β Pet breed classification
- β Pet status management
- β Lost pet publishing
- β GPS location support
- β Nearby lost pet search
- β Favorite lost pets
- β Image upload
- β Device registration
- β FCM push notifications
- β Device status management
- β User configuration management
- β System parameter configuration
- β Multi-language support
- β Request signature verification
- β JWT token authentication
- β Anti-replay attack protection
- β Encrypted data transmission
- Mock Mode Enabled: Email and SMS verification codes are fixed to
123456
- Signature Verification Disabled: For development testing convenience
- Automatic Database Migration: Auto-create table structure on first startup
- Hot Reload Support: Auto-restart after code modifications
- Complete Management Interface: Database and Redis management
Local development uses the application-local.yml
configuration file:
spring:
profiles:
active: local
# All cloud services have mock alternatives
verification:
code:
mock-enabled: true # Enable mock verification codes
signature:
enabled: false # Disable signature verification
# β οΈ Sensitive information (such as database, email, keys, etc.) should not be committed to public repositories, removed, need to be filled in manually!
Use the provided testing tools:
# Quick test of main features
./quick-test.sh
# Or use HTTP file testing
# Open FurTrax-V1-API.http in VS Code
Gmail Configuration:
- Enable two-factor authentication
- Generate app password
- Update
application-prod.yml
:
spring:
mail:
username: your-email@gmail.com
password: your-16-digit-app-password
Facebook Login:
- Create Facebook application
- Get App ID and App Secret
Google Login:
- Create Google Cloud project
- Configure OAuth 2.0
Create .env
file:
# Database configuration
DB_PASSWORD=γPlease fill in database passwordγ
# Redis configuration
REDIS_PASSWORD=γRedis passwordγ
# JWT configuration
JWT_SECRET=γJWT secretγ
# Cloud service configuration
ALIYUN_SMS_ACCESS_KEY_ID=γAccessKeyIdγ
ALIYUN_SMS_ACCESS_KEY_SECRET=γAccessKeySecretγ
MAIL_USERNAME=γEmail accountγ
MAIL_PASSWORD=γEmail passwordγ
# Build image
cd furtrax-backend-java
docker build -t furtrax-api:latest .
# Run container
docker run -d --name furtrax-api \
-p 8080:8080 \
-e SPRING_PROFILES_ACTIVE=prod \
furtrax-api:latest
User Management:
POST /v1/register
- User registrationPOST /v1/login
- User loginPOST /v1/login/vcode
- Verification code loginGET /v1/user/{id}
- Get user information
Pet Management:
POST /v1/pet
- Add petGET /v1/pets/{userid}
- Get user petsPUT /v1/pet/{id}
- Update pet information
Lost Pets:
POST /v1/lost
- Publish lost petGET /v1/neighbours/lost_pets
- Get nearby lost pets
# Check application status
curl http://localhost:8080/actuator/health
# Check metrics
curl http://localhost:8080/actuator/metrics
# View application logs
tail -f logs/furtrax.log
# View Docker logs
docker logs furtrax-api
Database Backup:
pg_dump -h localhost -U furtrax_user furtrax > backup.sql
File Backup:
tar -czf uploads_backup.tar.gz uploads/
- Layered Architecture: Controller β Service β Repository
- Dependency Injection: Spring IoC container management
- Transaction Management: Spring @Transactional
- Caching Strategy: Redis cache for hot data
- Security Design: JWT + signature verification
furtrax-backend-java/
βββ src/main/java/com/furtrax/
β βββ controller/ # Controller layer
β βββ service/ # Service layer
β βββ repository/ # Data access layer
β βββ entity/ # Entity classes
β βββ dto/ # Data transfer objects
β βββ config/ # Configuration classes
β βββ security/ # Security configuration
β βββ util/ # Utility classes
βββ src/main/resources/
βββ application.yml # Default configuration
βββ application-local.yml # Local development configuration
βββ application-prod.yml # Production environment configuration
1. Database Connection Failed
# Check database status
docker logs furtrax-postgres
2. Redis Connection Failed
# Test Redis connection
redis-cli ping
3. Application Startup Failed
# View detailed logs
mvn spring-boot:run -Dspring-boot.run.profiles=local -X
4. Verification Code Not Received
- Check email configuration
- Confirm app password is correct
- View application logs
This project uses GNU 3.0 License. See the LICENSE
file for details.
Welcome to submit Issues and Pull Requests! If you find this project helpful, welcome to star support.