The basic blues format
In general the blues is a combination of minor pentatonic melody played over a harmonic progression emphasising the tonic, sub-dominant and dominant chords. It’s also common for all the chords to be played with a dominant 7th voicing (i.e. having a b7) although the only chord functioning as a dominant is the V (dominant) chord.
Pentatonic Melody + Diatonic Harmony = Blues
We can begin with the fundamental observation about blues harmony: it springs from the combination of minor pentatonic melodies over tonic, subdominant and dominant major chords. The result is a unique hybrid melody-harmony relationship that depends on familiar functional relationships, but goes beyond the constraints of a pure major key system. 
In its most basic form the structure of the blues follows this 12 bar pattern:
- 4 bars of the I chord
- 2 bars of the IV chord, followed by 2 bars of the I chord
- 1 bar of the V chord, 1 bar of the IV chord, and 2 bars of the I chord
In the key of C that gives you the following basic progression.
Blues harmony works in a different way than conventional diatonic harmony. Although some of the gestures and points of connection are the same, a crucial difference is that there is no single modal source the defines the blues tonality. 
When you think about it playing dominant 7th chords for the entire harmony shouldn’t work! It breaks a lot of the rules of functional harmony. However, we still get a sense of forward motion because the root notes follow an expected pattern based on chord families (harmonic function).
The harmonic function of the I, IV and V chords is independant of thheir dominant seventh quality. 
You could play a 12 bar blues progression using just major and minor triads and it would still sound like the blues albeit a rather monotonous one. Actually, Chuck Berry style blues shuffles really only use 5th chords (just the root and the 5th) and it still sounds like the blues.
Notes on melody
The basis of blues melody is the minor pentatonic scale with the addition of the blue note (the flat 5). This is often referred to as the blues scale. It is also common to introduce the major 3rd. Here’s the weird thing though; playing the minor pentatonic scale over a dominant 7th chord shouldn’t work because the minor pentatonic scale has a minor 3rd and the dominant 7th chord has a major 3rd. And this only applies to the I7 chord anyway.
One way to think of this is that the b3 functions like a #9 when played over the I7 chord. Similarly, the minor pentatonic when played over the IV7 chord produces a 9 tension.
…blues melody is an independent layer with its own set of defining pitches. 
Variations on the blues progression
Getting back to the 12 bar progression it’s common to play a basic turnaround by playing the V chord in bar 12. Additionally in bars 9 and 10 we can play the IV then the V chords before returning to the I chord in bar 11. This is called the soft retreat to the tonic. We end up with something like this:
The next variation is to add a IV chord in bar 2.
The next variation adds a ii-V movement in bars 9 and 10. Note that although the ii chord is a min7 the V and I are still voiced as dominant 7th chords. You can also add a vi chord in bar 8 to create a vi-ii-V-i progression.
The next variation uses a I-vi-ii-V (or a iii-vi-ii-V) as the turnaround. Note that we can use dominant 7th for all chords if you like or the ‘real’ diatonic chords.
It is also possible to add a diminished chord in bar 6, like this:
Using chord substitutions
Given these basic progressions we can start to use usual jazz harmonic substitutions – such as secondary dominants – to add interest. The first example of this is to use a secondary ii-V in bar 4 to the IV chord in bar 5. Remember, the rule about secondary dominants is:
Any diatonic chord may be preceded by a dominant 7th chord whose root is a 5th above its own root
We want to target the F7 in bar 5 so its secondary dominant is C7 (a 5th above). Remember also that:
Any secondary dominant can be preceded by its own ii chord
In this case that would be Gmin7 which gives us the following progression:
It is common to play ‘outside’ lines in bar 4 using perhaps the C altered scale or C diminished.
The next variation we can try is to add a minor secondary ii-V in bar 8 to the ii chord in bar 9.
Note that what we are getting here – despite the jazzy additions – is still a blues based on the traditional 12 bar form. All we are doing is using the accepted rules of chord substitution to add embellishment while still preserving the sense of forward motion.
Of course we don’t have to stop here. There are many other substitutions and embellishments that can be made. For an example, take a look at Blues for Alice by Charlie Parker. Here’s that tune transposed to C major for ease of comparison to previous examples.
 The Berkley Book of Jazz Harmony, p132
 The Berkley Book of Jazz Harmony, p133
 The Berkley Book of Jazz Harmony, p135
 The Berkley Book of Jazz Harmony, p133