Get to know more about how Nubia works under the hood, navigating the site, our thought process and tools used
Try it outNubia: what's going on?
As of now, Nubia has 2 major systems: The Client & Server. The Server does the story generation while the client side handles all of the rendering and display of articles. The Server was built using Express Js, a framework for serving nodeJs apps. The API requests are captured by controllers and then these controllers call the services required based on the specification of the reqeust.
Before a route can be valid for use, a series of things have to be put in place. These things include
Major server language is TypescriptNUBIA
Client → NextJs/React, Tailwind, SWR, Zustand
Server → ExpressJs, Rosaenlg, csv-parser
After successful wiring up of the various components, the route is ready to be queried by a client and used to generate stories.
For templating, Nubia uses Rosaenlg which is an NLG open-source tool built ontop of Pug (Actually, it's pug on steroids). Rosaenlg adds additional features to pug, making able to perform tasks pug normally would not ba able to achieve. This can be a little bit tricky as there is no syntax highling for rosae and a lot of the commands would be flagged as in-appropriate by the IDE or syntax formating plugins.
At the moment, the data files are added to the repo under the data folder. This data is then run through an utility function that parses the data to Javascript objects. Very soon, data storage would be moved into a cloud file storage like AWS S3, Google cloud file storage, Azure or whatever cloud platform is deemed worthy at the time, then the urls would be stored in a database. The data parsing utility would also be re-written to accommodate cvs from urls
After creation of the temoplate and adding of data, a service should be created to house the logic of the story creation: parsing the data, calling the template engine, storing data to database and all other major logic.
There is a data parsing utility provided in the code repo that supports csv and takes in 3 parameters which are
After completion of service, a controller is created to handle incoming requests, assign classnames and call the appropriate services.
After the controller is ready and sends a valid response object to the user, a route would be created specifying the story end-points. The typical naming convention for this is host.com/story-name and the route for getting the corresponding data is host.com/story-name/data