A high school student's personal blog

[Project] A Complete Smart Shared Bicycle System

Project Overview

A complete shared bike solution covering the user APP, smart bike lock, and management backend, with a comprehensive tech stack and a measured stress resistance of 89.7 requests/second

Project Origin

To participate in the finals of the 2025 National Youth Information Literacy Competition, we completed the basic lock/unlock function according to the given problem requirements, but to make it closer to real life and turn it into a complete and mature product, we developed more branches and innovative features, including but not limited to:GPS positioning, accident detection and alarm, vehicle fault reporting, vehicle data cluster management, backend management dashboard, user-based data management, trip data recording and displayCoveringUser-side APP, embedded smart lock, backend management system, and API service
This article will provide an in-depth analysis of the technical architecture and implementation highlights of this system.

Team Division of Labor

Me (XHL)Server operations and maintenance, frontend and backend development, APP, all software parts, etc.Personal website
The Sandy3D structural design and printing of the bike lock, hardware structure construction, assisting with ESP32 program development, etc.Personal website

Overall Architecture: Layered Design

The project's three-layer architecture:

LayerTech StackFunction
ClientVue + Android + Amap SDKMap display, scan-to-unlock, trip records, user center
Bike-sideMicroPython + ESP32 + GPS/MPU6050Positioning reporting, posture detection, unlock execution
API ServicePython FlaskBusiness logic processing, data interfaces
Data LayerMySQL + connection poolData storage
InfrastructureDocker + Nginx + DebianContainerized deployment, load balancing

Server Highlights: High Performance and High Availability

1 Connection Pool Design

The server side is developed based on Python Flask. For the database, I encapsulated it myself SQL

from dbutils.pooled_db import PooledDB

Measured data: The system can withstand approximately 89 requests/second of data requests, and the server never crashed during network attack tests.

2 Logging System

All API requests are recorded to the database through the server_log() function, and log types are divided into:

  • USER: User login, registration, query, and other operations
  • BIKE: Bike unlock, lock, location update
  • ACCI: Accident alarm, anti-theft alarm
  • MAIN: Repair request, repair completed
  • PANEL: Backend data access
    This not only facilitates problem tracing, but also provides a foundation for data analysis and operational decision-making.

3 DingTalk Alert Integration

Accident alarms and anti-theft alarms are pushed in real time via DingTalk bot:

III. Smart Bike Lock: The Combination of Hardware and Algorithms

1 Mechanical Structure Iteration

Modeling design and 3D printing were completed by The Sandy (Personal website

The enclosure went through five generations of iteration:

VersionMaterialImprovement
First generationPLAVerified basic structural feasibility
Second generationPLAOptimized lubricant solution
Third generationPLAOptimized fixation solution
Fourth generationPETG-CFSignificantly improved strength
Fourth+ generationPETG-CF + PETG windowResolved GPS signal shielding issue

Technical details: Carbon fiber reinforced PETG shields GPS signals, so the antenna area specifically uses a PETG window design.

2 Attitude Detection and Accident Alarm

Uses the MPU6050 six-axis sensor to detect vehicle attitude in real time. When an abnormal impact is detected (such as a fall), the system will:

  1. Pop up a prompt via the OLED screen, giving the user 10 seconds to cancel(to prevent false alarms)
  2. After confirmation, call the /bike/accident API
  3. The server queries the user's pre-registered emergency contact
  4. The DingTalk bot automatically pushes the accident location and user information

3 Power Management and Photovoltaic Charging

Solar panel → Charging IC → 7.4V lithium battery
  • Photovoltaic charging: 6V 3W solar panel continuously replenishes power
  • Low-power strategy: Automatically retries when GPS has no data; after the reed switch is abnormally triggered three times, it retries and then reports a fault

IV. Backend Management System: Data Visualization

The backend adopts Vue3 + ECharts + Amap API Built with, features include:

  • Dashboard: Real-time refresh of total bikes, total users, and total requests
  • Bike Location Tracking: Real-time display of all vehicle distribution on the map
  • User Management: View all user information and operation records
  • Riding Records: Order details, trajectory playback
  • Maintenance Management: Repair/fix status flow
  • Log Audit: Full query of server logs, bike logs, and user logs

V. API Interface Design Specification

Client Interface Examples

APIPathDescription
User LoginPOST /client/loginReturn nickname and status
Nearby BikesPOST /client/nearbyLatitude and longitude range query
Unlock BikePOST /client/unlockCreate riding record
Get RecordsPOST /client/getrecordHistorical orders

Bike Device Interface

APIPathDescription
Status CheckPOST /bike/checkReturn lock/unlock
Location UpdatePOST /bike/updateReal-time trajectory reporting
Accident AlertPOST /bike/accidentTrigger DingTalk push

Security Design

Backend interfaces uniformly verify Token:

{"token": "AABBCC"}

VI. Deployment and Operations

The project adopts Docker containerizationDeployment, running on cloud servers:

  • OpenResty: Port forwarding, load balancing
  • MySQL container: Data persistence
  • Python Flask container: API service
  • Docker Compose: One-click orchestration startup

Project Highlights Summary

  1. Complete closed loop of tech stack: From hardware (ESP32/MPU6050/GPS) to APP (Vue/Android), from server side (Flask) to database (MySQL), and then to dashboard (Vue3/ECharts), covering the full chain
  2. Engineering practices in place: Connection pooling, log classification, Docker deployment, with production environment usability
  3. Security and emergency mechanisms: Accident alarm + 10-second cancellation mechanism, anti-theft alarm, DingTalk real-time push
  4. Excellent performance: Measured 89.7 concurrent requests per second, server remains stable and does not crash under attack testing

Welcome technical exchange. If you need the complete source code and hardware files, pleasecontact