Accord Mobile Server is the standalone Go backend for the mobile workflow on top of ERPNext. It runs independently from the Telegram bot and serves the mobile app directly.
Main flow:
mobile_app -> mobile_server -> ERPNext
This backend is responsible for:
- authenticating
Supplier,Werka,Customer, andAdmin - translating mobile actions into ERPNext document operations
- maintaining mobile-facing workflow state
- managing push tokens and FCM notifications
- keeping ERP comments and ERP custom fields aligned with business actions
The server is intentionally the main business layer for mobile behavior. The app should stay relatively thin and defer business truth to this backend and ERPNext.
On 2026-05-14, this Go service was benchmarked as the legacy baseline against
the primary Rust mobile backend on the same fedora server, using copied
runtime state and read-only mobile endpoints. All tested Go endpoints returned
200 with zero ApacheBench failures. The Rust service matched the tested
responses successfully and showed lower latency on most read-heavy routes.
Full benchmark notes are available in docs/benchmarks/2026-05-14-go-vs-rust.md.
These rules reflect the current intended behavior:
- supplier dispatch creates a
Purchase Receipt - werka customer issue creates and submits a
Delivery Note - werka single-submit now uses the explicit app payload directly on the hot path
- werka batch-submit is available through
/v1/mobile/werka/customer-issue/batch-create - customer confirm updates the original
Delivery Note - customer reject creates and submits a real return
Delivery Note - customer reject is not treated as a UI-only status flip
- comments are discussion/audit history only
- ERP fields remain the source of business state
- Werka auth is code-driven and should not be blocked by phone format drift
Customer delivery state is tracked on top of ERPNext Delivery Note.
Current fields used:
accord_flow_stateaccord_customer_stateaccord_customer_reasonaccord_delivery_actoraccord_ui_status
Current state expectations:
accord_flow_state1= submitted
accord_customer_state1= pending2= rejected3= confirmed
accord_ui_statuspendingconfirmpartialrejected
Important rule:
confirmmust not create a return documentrejectmust create a real returnDelivery Notewithis_return = 1andreturn_against = <original DN>
- login
- fetch summary/history/items
- create dispatch
- backend writes
Purchase Receipt
Relevant backend logic:
- login
- fetch summary/history/pending
- create single customer issue
- create batch customer issue
- backend writes submitted
Delivery Note - direct DB read is only for supported picker/read flows
- create/submit flows still write through ERPNext HTTP APIs
Relevant backend logic:
- fetch summary/history/detail
- approve or reject an existing
Delivery Note
Current behavior:
- approve updates original DN state
- reject creates a real return DN and updates original DN state
Relevant backend logic:
- settings
- supplier/customer management
- item assignment
- activity feed
The HTTP layer is intentionally thin and delegates to ERPAuthenticator.
Core entrypoint:
HTTP router:
Business layer:
ERP adapter:
This backend includes fallback logic to ensure delivery-note workflow fields exist in ERPNext.
Relevant file:
Related ERP custom app:
/home/wikki/storage/local.git/erpnext_n1/erp/apps/accord_state_core
The ERP app is still the cleaner long-term home for field management, but backend fallback exists so mobile operations do not fail when field setup drifts.
The backend stores mobile push tokens and sends FCM notifications for role-specific events.
Relevant files:
Operational notes:
- stale FCM tokens are dropped automatically
- push routing is role/ref based
- request-level logging was added for
Delivery Notecustomer issue creation
ERP_DIRECT_READ_ENABLED=1only affects supported read-heavy Werka picker and summary flowsDelivery Notecreate and submit flows still go through ERPNext HTTP APIs- single Werka customer issue submit now uses the selected
customer_ref,item_code, andqtydirectly - batch Werka customer issue submit is exposed through
/v1/mobile/werka/customer-issue/batch-create - batch lines are processed in parallel in the backend so multi-item submit stays close to single-item submit latency
By default the backend uses local JSON files for mobile state:
data/mobile_profile_prefs.jsondata/mobile_admin_suppliers.jsondata/mobile_push_tokens.jsondata/mobile_sessions.json
These are suitable for local/single-instance operation, but not a strong multi-instance persistence strategy.
Session behavior:
- login sessions survive backend restart when
data/mobile_sessions.jsonis preserved - default session TTL is
720hours (30days) - set
MOBILE_API_SESSION_TTL_HOURS=0to disable expiry
make runThe server starts on :8081 by default and loads .env automatically.
Werka AI image search now runs through mobile_server, not the mobile app
binary. Set these env vars on the server when you want the scan button to work:
GEMINI_API_KEY=<your gemini api key>GEMINI_VISION_MODEL=gemini-flash-lite-latest(optional)
Health check:
curl http://127.0.0.1:8081/healthzExpected response:
{"ok":true}make stopgo test ./...When debugging mobile delivery flows, check these in order:
mobile_server/.core.log- whether
/v1/mobile/werka/customer-issue/createwas hit - whether ERPNext received a new
Delivery Note - whether customer response hit
/v1/mobile/customer/respond - whether a return
Delivery Notewas created only on reject
Useful live checks:
- local backend:
http://127.0.0.1:8081/healthz - public backend:
https://core.wspace.sbs/healthz - ERP endpoint base: value from
.envERP_URL
ERPNextcore source is not edited from this repo- Firebase service account JSON is local-only and should not be committed
- this repo is the primary backend target for mobile work
- if business behavior changes, update this README and commit it