SpatiaLite has routing support, and its probably a bit easier to understand than some of the "bigger" engines. See the docs. More searching, following links, reading the code and so on will help you to understand this, and given your stated needs, I won't provide step-by-step instructions here.
I understand that you don't want a canned solution, but I think you may benefit from looking at a simple working system.
I know this is kind of an OLD thread, but I have looked for two days for an answer to this same error message about output dimensions needing to be 2 or 3. I think i have found a solution that could be useful to your problem as well as mine, so I'm going to share it. It worked for me.
My issue, specifically, was when I converted a bunch of KML's from Google Earth to Shapefiles, and then loaded those shapefiles into my PostGIS db. The PostGIS tables would load in QGIS fine, but would not display when published to Geoserver. The error message (from the WMS) was essentially:
Rendering process failed
java.io.IOExceptionOutput dimension must be 2 or 3
So! Here's what I've discovered:
Looking in PostGIS geometry_columns, the tables that would not display had a coord_dimension column value of 4 (which is higher than 2 or 3). It seems that Geoserver does not render 4D features. QGIS does. This was why I was having difficulty finding the problem, the tables were OK, per se.
What I wound up doing was re-saving my shapefiles in QGIS, but I chose the geometry types for my shapefiles (points, lines, and polygons) following the document: http://www.gdal.org/drv_shapefile.html
which basically offers the following information:
SHPT=type: Override the type of shapefile created. Can be one of NULL for a simple .dbf file with no .shp file, POINT, ARC, POLYGON or MULTIPOINT for 2D; POINTZ, ARCZ, POLYGONZ or MULTIPOINTZ for 3D; POINTM, ARCM, POLYGONM or MULTIPOINTM for measured geometries; and POINTZM, ARCZM, POLYGONZM or MULTIPOINTZM for 3D measured geometries. The measure support was added in GDAL 2.1. MULTIPATCH files are not supported.
So, avoiding saving the file as any format that included the M dimension, I was able to bypass the problem of "dimensions must be 2 or 3".
i.e. In QGIS, save your layer as a Shapefile and include SHPT=POLYGON
in the Layer section of the Custom Options when saving.
Hope that helps.
Best Answer
http://wiki.openstreetmap.org/wiki/GIS_software