As that "enterprising kid" who couldn't wait until the SCiO was completed, and who was fed up with his 3d printed visible light spectroscope, I put in a lot of research effort figuring out how to go about creating a portable, financially attainable NIR spectroscope. I started out thinking it would be fairly straightforward since I already worked on creating CCD sensor driver boards in my early highschool years (after all it just seemed like you'd need a linear CCD with no IR-cut filter, a diffraction grating, a prism with 95%+ reflectivity, and an IR emitter with a peak wavelength of ~920nm). I invested about 6 months working through the various roadblocks I encountered until I managed to get half-decent results from it when taking the spectrum of various salts. Still never managed to fully refine it since I didn't have the budget to (Heck the Eagle schematics I sent off to a PCB fabricator were so poorly-designed that in order to get it to work correctly it required me to solder a wire across two traces to prevent the sensor from blowing up). It's still somewhere in one of my drawers and is a fun novelty item (and it did win (second?) place at my junior science fair) but at least with my design, it really wasn't the portable tricorder I was hoping for...
The healthtech company I work for has expressed interest to CP about using the SCiO phone for a project. If that doesn't work out, we might replicate this work by Fraunhofer. We're already looking into it. And since it's not core to our business, if we do, we'll open source it too.
There are two classes of problems in spectroscopy: qualitative (trying to identify what the sample is) and quantitative (deciding concentrations of one or more analyte in sample).
Qualitative is quite simple: each material have quite unique fingerprint and you match it against dataset.
Quantitative is very very tricky. You have to pick good region of spectra and you have to pick good features (say peak areas or peak high). For complex solutions you will get a lot of peak overlaps and then you have problem with matrix effects for most samples (non-linearities caused by combinations of various compounds and so forth).
Good news is that a lot of interesting things can be found in near infrared region, so you don't really need expensive diffraction gratings and delicate optics.
https://www.youtube.com/watch?v=SfiqdooNBb8
Cheap diffraction grating and a cheap camera; basically, the idea would be to somehow use an IR sensitive camera (most are - at least in the far-mid range), an IR source (maybe an unfocused IR laser diode?), and a diffraction grating.
Ideally for the grating you'd use one for IR - but I haven't found one that wasn't reflective-based (instead of transmissive) - there's probably a good reason (likely having to do with cheap materials and IR absorption - which is why lenses and mirrors for laser cutters tend to be pretty pricey).
Anyhow - thems the basics. Take that, get an image from the camera, run a fourier transform on the data, get the peaks, then pass it thru a trained CNN (?) - heck, you might be able to forgo the transform part and just use the data from the camera directly (repurpose imagenet or something).
Yeah - I think this whole thing could be made an open-source project; probably even an instructable...? At the very least, it could become an interesting science fair project for some enterprising kid...