{"id":21,"date":"2025-08-20T17:37:42","date_gmt":"2025-08-20T09:37:42","guid":{"rendered":"https:\/\/www.ycxhl.top\/?p=21"},"modified":"2026-08-27T17:22:59","modified_gmt":"2026-08-27T09:22:59","slug":"17","status":"publish","type":"post","link":"https:\/\/www.ycxhl.top\/en\/archives\/17\/","title":{"rendered":"[\u9879\u76ee] \u4e00\u5957\u5b8c\u6574\u7684\u667a\u80fd\u5171\u4eab\u5355\u8f66\u7cfb\u7edf"},"content":{"rendered":"<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>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<\/strong><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Project Origin<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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:<strong>GPS positioning, accident detection and alarm, vehicle fault reporting, vehicle data cluster management, backend management dashboard, user-based data management, trip data recording and display<\/strong>Covering<strong>User-side APP, embedded smart lock, backend management system, and API service<\/strong>\u3002<br>This article will provide an in-depth analysis of the technical architecture and implementation highlights of this system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Team Division of Labor<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Me (XHL)<\/td><td>Server operations and maintenance, frontend and backend development, APP, all software parts, etc.<\/td><td><a href=\"https:\/\/www.ycxhl.top\/en\/\">Personal website<\/a><\/td><\/tr><tr><td>The Sandy<\/td><td>3D structural design and printing of the bike lock, hardware structure construction, assisting with ESP32 program development, etc.<\/td><td><a href=\"https:\/\/decades.top\">Personal website<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Overall Architecture: Layered Design<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The project's three-layer architecture:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Layer<\/th><th>Tech Stack<\/th><th>Function<\/th><\/tr><\/thead><tbody><tr><td>Client<\/td><td>Vue + Android + Amap SDK<\/td><td>Map display, scan-to-unlock, trip records, user center<\/td><\/tr><tr><td>Bike-side<\/td><td>MicroPython + ESP32 + GPS\/MPU6050<\/td><td>Positioning reporting, posture detection, unlock execution<\/td><\/tr><tr><td>API Service<\/td><td>Python Flask<\/td><td>Business logic processing, data interfaces<\/td><\/tr><tr><td>Data Layer<\/td><td>MySQL + connection pool<\/td><td>Data storage<\/td><\/tr><tr><td>Infrastructure<\/td><td>Docker + Nginx + Debian<\/td><td>Containerized deployment, load balancing<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"1024\" src=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-1-768x1024.webp\" alt=\"\" class=\"wp-image-64\" srcset=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-1-768x1024.webp 768w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-1-225x300.webp 225w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-1-1152x1536.webp 1152w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-1.webp 1279w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Server Highlights: High Performance and High Availability<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1 Connection Pool Design<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The server side is developed based on Python Flask. For the database, I encapsulated it myself <code>SQL<\/code> \u7c7b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from dbutils.pooled_db import PooledDB<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Measured data<\/strong>: The system can withstand approximately <strong>89 requests\/second<\/strong> of data requests, and the server never crashed during network attack tests.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2 Logging System<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">All API requests are recorded to the database through the <code>server_log()<\/code> function, and log types are divided into:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>USER<\/strong>: User login, registration, query, and other operations<\/li>\n\n\n\n<li><strong>BIKE<\/strong>: Bike unlock, lock, location update<\/li>\n\n\n\n<li><strong>ACCI<\/strong>: Accident alarm, anti-theft alarm<\/li>\n\n\n\n<li><strong>MAIN<\/strong>: Repair request, repair completed<\/li>\n\n\n\n<li><strong>PANEL<\/strong>: Backend data access<br>This not only facilitates problem tracing, but also provides a foundation for data analysis and operational decision-making.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3 DingTalk Alert Integration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Accident alarms and anti-theft alarms are pushed in real time via DingTalk bot:<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" data-id=\"65\" src=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-2-473x1024.webp\" alt=\"\" class=\"wp-image-65\" srcset=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-2-473x1024.webp 473w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-2-138x300.webp 138w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-2-768x1664.webp 768w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-2-709x1536.webp 709w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-2-945x2048.webp 945w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-2.webp 1080w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" data-id=\"66\" src=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-3-473x1024.webp\" alt=\"\" class=\"wp-image-66\" srcset=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-3-473x1024.webp 473w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-3-138x300.webp 138w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-3-768x1664.webp 768w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-3-709x1536.webp 709w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-3-945x2048.webp 945w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-3.webp 1080w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" data-id=\"67\" src=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-4-473x1024.webp\" alt=\"\" class=\"wp-image-67\" srcset=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-4-473x1024.webp 473w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-4-138x300.webp 138w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-4-768x1664.webp 768w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-4-709x1536.webp 709w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-4-945x2048.webp 945w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-4.webp 1080w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/figure>\n<\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">III. Smart Bike Lock: The Combination of Hardware and Algorithms<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1 Mechanical Structure Iteration<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Modeling design and 3D printing were completed by The Sandy (<a href=\"https:\/\/114514.com.cn\/\">Personal website<\/a>\uff09<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">The enclosure went through five generations of iteration:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Version<\/th><th>Material<\/th><th>Improvement<\/th><\/tr><\/thead><tbody><tr><td>First generation<\/td><td>PLA<\/td><td>Verified basic structural feasibility<\/td><\/tr><tr><td>Second generation<\/td><td>PLA<\/td><td>Optimized lubricant solution<\/td><\/tr><tr><td>Third generation<\/td><td>PLA<\/td><td>Optimized fixation solution<\/td><\/tr><tr><td>Fourth generation<\/td><td>PETG-CF<\/td><td>Significantly improved strength<\/td><\/tr><tr><td>Fourth+ generation<\/td><td>PETG-CF + PETG window<\/td><td>Resolved GPS signal shielding issue<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Technical details<\/strong>: Carbon fiber reinforced PETG shields GPS signals, so the antenna area specifically uses a PETG window design.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">2 Attitude Detection and Accident Alarm<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Pop up a prompt via the OLED screen, giving the user <strong>10 seconds to cancel<\/strong>(to prevent false alarms)<\/li>\n\n\n\n<li>After confirmation, call the <code>\/bike\/accident<\/code> API<\/li>\n\n\n\n<li>The server queries the user's pre-registered emergency contact<\/li>\n\n\n\n<li>The DingTalk bot automatically pushes the accident location and user information<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">3 Power Management and Photovoltaic Charging<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Solar panel \u2192 Charging IC \u2192 7.4V lithium battery<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Photovoltaic charging<\/strong>: 6V 3W solar panel continuously replenishes power<\/li>\n\n\n\n<li><strong>Low-power strategy<\/strong>: Automatically retries when GPS has no data; after the reed switch is abnormally triggered three times, it retries and then reports a fault<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">IV. Backend Management System: Data Visualization<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-5-1024x555.webp\" alt=\"\" class=\"wp-image-68\" srcset=\"https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-5-1024x555.webp 1024w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-5-300x163.webp 300w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-5-768x416.webp 768w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-5-1536x832.webp 1536w, https:\/\/www.ycxhl.top\/wp-content\/uploads\/2026\/08\/\u667a\u80fd\u5171\u4eab\u5355\u8f66-5.webp 1918w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The backend adopts <strong>Vue3 + ECharts + Amap API<\/strong> Built with, features include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Dashboard<\/strong>: Real-time refresh of total bikes, total users, and total requests<\/li>\n\n\n\n<li><strong>Bike Location Tracking<\/strong>: Real-time display of all vehicle distribution on the map<\/li>\n\n\n\n<li><strong>User Management<\/strong>: View all user information and operation records<\/li>\n\n\n\n<li><strong>Riding Records<\/strong>: Order details, trajectory playback<\/li>\n\n\n\n<li><strong>Maintenance Management<\/strong>: Repair\/fix status flow<\/li>\n\n\n\n<li><strong>Log Audit<\/strong>: Full query of server logs, bike logs, and user logs<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">V. API Interface Design Specification<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Client Interface Examples<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>API<\/th><th>Path<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>User Login<\/td><td>POST \/client\/login<\/td><td>Return nickname and status<\/td><\/tr><tr><td>Nearby Bikes<\/td><td>POST \/client\/nearby<\/td><td>Latitude and longitude range query<\/td><\/tr><tr><td>Unlock Bike<\/td><td>POST \/client\/unlock<\/td><td>Create riding record<\/td><\/tr><tr><td>Get Records<\/td><td>POST \/client\/getrecord<\/td><td>Historical orders<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Bike Device Interface<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>API<\/th><th>Path<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>Status Check<\/td><td>POST \/bike\/check<\/td><td>Return lock\/unlock<\/td><\/tr><tr><td>Location Update<\/td><td>POST \/bike\/update<\/td><td>Real-time trajectory reporting<\/td><\/tr><tr><td>Accident Alert<\/td><td>POST \/bike\/accident<\/td><td>Trigger DingTalk push<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Security Design<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Backend interfaces uniformly verify Token:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\"token\": \"AABBCC\"}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">VI. Deployment and Operations<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The project adopts <strong>Docker containerization<\/strong>Deployment, running on cloud servers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OpenResty<\/strong>: Port forwarding, load balancing<\/li>\n\n\n\n<li><strong>MySQL container<\/strong>: Data persistence<\/li>\n\n\n\n<li><strong>Python Flask container<\/strong>: API service<\/li>\n\n\n\n<li><strong>Docker Compose<\/strong>: One-click orchestration startup<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Project Highlights Summary<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Complete closed loop of tech stack<\/strong>: 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<\/li>\n\n\n\n<li><strong>Engineering practices in place<\/strong>: Connection pooling, log classification, Docker deployment, with production environment usability<\/li>\n\n\n\n<li><strong>Security and emergency mechanisms<\/strong>: Accident alarm + 10-second cancellation mechanism, anti-theft alarm, DingTalk real-time push<\/li>\n\n\n\n<li><strong>Excellent performance<\/strong>: Measured 89.7 concurrent requests per second, server remains stable and does not crash under attack testing<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><em>Welcome technical exchange. If you need the complete source code and hardware files, please<a href=\"\/en\/about.html\/\">contact<\/a><\/em><\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>\u4e00\u5957\u8986\u76d6\u7528\u6237APP\u3001\u667a\u80fd\u8f66\u9501\u3001\u7ba1\u7406\u540e\u53f0\u7684\u5b8c\u6574\u5171\u4eab\u5355\u8f66\u89e3\u51b3\u65b9\u6848\uff0c\u6280\u672f\u6808\u5168\u9762\uff0c\u5b9e\u6d4b\u6297\u538b 89.7 \u6b21\/\u79d2 \u9879\u76ee\u7f18\u8d77 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":64,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects"],"_links":{"self":[{"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":3,"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/posts\/21\/revisions\/119"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/media\/64"}],"wp:attachment":[{"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ycxhl.top\/en\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}