In a slash chord, the chord on the left is played over the bass note on the right.
So for D/G a D chord is played over a G bass note.
If you have separate player on bass, then a guitarist can play an ordinary D chord, while the bassist plays G.
If you're trying to play D/G on a solo guitar, then you have to find a fingering in which your prominent bass note is G (say, 3rd fret on the bass E), along with notes from D major on the higher strings.
Transposing slash chords is no different from transposing any other piece of music. All the notes go up or down by the same interval. Remember that not all steps in a major/minor scale are the same interval. You have to count the semitones.
So, to transpose D/G by one tone, just add two semitones to all the notes: E/A
Go up by three semitones and you'll find that D becomes F (D -> Eb -> E -> F) and G becomes Bb (G -> Ab -> A -> Bb).
Just remember that B and C are a semitone apart, as are F and G, and it'll make sense.
In terms of coding, there's almost nothing to it:
transposedNote = originalNote + interval
... assuming you're representing your notes as integers and an increment of one represents a semitone step. That's how MIDI represents notes. Middle C=60, C#=61, D=62 etc.