Model the spec on the one for comments 2.0 (http://docs.moodle.org/en/Development:Comments_2.0)
ratingslib.php, similar to commentslib.php, should implement a separate ratings table and API so that modules can easily implement ratings on arbitrary items within the activities (forum posts, glossary entries etc). The ratings parameters (eg which scale etc) should be stored on the course_modules
tables. This is related to grades only in that grades are often based on aggregations of ratings.