Rifleman Dodd is a work of fiction that is based upon and in real world events. Forester was a keen history buff and he did a lot of research which went into his books. For example, his more famous Hornblower series is based on a fictional sailor who rises through the ranks but it includes real ships, people and events. The lead character's adventures often include fictionalised versions of exploits by real sailors of the period.
Similarly "Rifleman Dodd" is a fictional character that interacts with real people and events. The background events really happened and his regiment, the 95th Rifles, were really involved. it's just his personal exploits that are fiction. Forester was fortunate that several members of the Rifle Brigade (the 95th) wrote journals and autobiographies after the war. Together these give a good account of the world these men inhabited, how they were recruited, what day-to-day life was like in the Peninsular War and what it was like in and after battle.
Sample source texts:
The Recollections of Rifleman Harris
Adventures of a Soldier (Edward Costello)
Adventures in the Rifle brigade (J. Kincaid)
Random shots from a Rifleman (J. Kincaid)