Project introduction
Sangong Fresh Matching is a collaborative system for the application, stocking, distribution and performance management of unit ingredients. It consists of Android App, administrator Web background, sub-unit Web portal and FastAPI server.
The project hopes to solve the problems brought about by relying on WeChat groups, paper lists and Excel tables in the traditional food procurement process, such as information dispersion, non-transparent order status, untimely inventory updates, easy confusion of data from different units, and lack of unified records in the distribution process.
Project motivation
In the actual procurement and distribution scenarios, sub-units need to quickly check the available ingredients, submit the application quantity and track the distribution status; the administrator needs to focus on maintaining the ingredients, inventory, price, unit account number and orders.
Therefore, I designed a complete business closed loop:
The administrator creates the unit, account number, distribution point and ingredient information.
Sub-units can apply for ingredients and submit orders through App browsing.
The administrator accepts orders, prepares goods, uploads delivery photos and updates the order status.
The sub-unit checks the progress of contract performance and confirms the receipt of goods.
Five. The system records orders, inventory changes, operation logs and delivery vouchers.
How do I build a project?
The Android client is developed using Kotlin and Jetpack Compose, and uses ViewModel, StateFlow, Room and DataStore to manage interface status, local data and login information.
The server uses FastAPI and native SQLite to realize interfaces such as account authentication, role permissions, unit data isolation, food management, inventory management, order status flow, picture upload, QR code login and App update.
The Web Terminal Is Built Using FastAPI Templates, HTML, CSS And JavaScript To Provide Administrators And Sub-Units With Operation Entrances Suitable For Desktop And Mobile Browsers Respectively.
The deployment layer uses Docker Compose and Nginx. SQLite turns on WAL, foreign key constraints and busy timeout, and improves concurrent security through atomic inventory updates, order and other keys and Outbox mode.
The project is also connected to aurora push basic channel. After the sub-unit submits the order, the administrator can receive a new order reminder; after the order status changes, the sub-unit can receive a progress notification. Push failure will not affect the order business, and the compensation mechanism will be provided through the front desk synchronization and the work manager.
Main challenges
Concurrency and data consistency
Order submission involves inventory advance, order main table, order details and inventory flow. In order to avoid duplicate orders and negative inventory, I used:
SQLite atomic condition update
BEGIN IMMEDIATESHORT BUSINESS"Isobation key"
Unique index
Inbox event queue
Data integrity check
Permissions and data isolation
The system includes administrators and multiple sub-unit accounts at the same time. All sensitive interfaces obtain roles and unit_id according to the server-side session, and do not trust the role or unit information submitted by the client, thus preventing cross-unit access.
Mobile reliability
I have dealt with network interruption, login failure, notification permission rejection, duplicate submission, App front and back office switching and account switching, etc. When the network fails, the local data or login status is not directly emptied, and the order push does not replace the real business records in the server.
Online and stability
I have established an independent stress test environment, database backup, recovery manual and environmental protection mechanism for the project.
Completed in an isolated environment:
20 users last for 10 minutes
30 users last for 15 minutes
30 users lasted a 30-minute stability test
40 users lasted a 5-minute peak test
There were no HTTP 5xx, unprocessed database locks, negative inventory, duplicate orders, container restarts or OOM during the test.
What did I learn?
This project makes me no longer just focus on pages and functions, but start to think systematically:
How to transform real business processes into software state machines
How to design role permissions and data isolation
How to ensure the consistency of orders and inventory
How to deal with weak mobile network and duplicate requests
How to carry out stress testing, backup, recovery and online acceptance
How to carry out low-risk optimization with limited server resources
The next step plan
We will continue to improve in the future:
Xiaomi, Huawei, Honor, OPPO and vivo manufacturers push channels
A more complete message center
More refined monitoring and police
Automated deployment and rollback process
Richer data statistics and resume analysis
Migrate to PostgreSQL or MySQL according to the business scale assessment
Log in or sign up for Devpost to join the conversation.