The main server-side part of GpxEdit is quite simple. The view (the map) can call getgpx to load a gpx file content. The view can produce and save in a gpx file through savegpx which basically writes the given content to a given destination file.
There is a controller part to manage the app admin settings and to manage personal tile servers URLs.
View (the map)
The Leaflet.Draw plugin is used as a basis to manipulate waypoints and lines on the map. GpxEdit uses the L.Draw events, primitives and variables to maintain properties associated with waypoints and lines. A popup opens when user clicks on a line or a marker. There is a form to set associated field values in this popup.
Loading a gpx file is done by parsing it with JQuery and then draw elements with L.Draw primitives and put associated information in gpxedit.layersData hashtable.
To save the map content as a gpx file, GpxEdit uses the combination of the L.Draw elements and the associated informations (names, comments...) to perform a naive xml generation.