Source code structure

This section will help you to understand the source code structure for further development


In this article

Web source code structure

Kindie Web Admin is built by SailsJS, is a Javascript framework designed to resemble the MVC architecture from frameworks like Ruby on Rails. It makes the process of building Node.js apps easier, especially APIs, single page apps and realtime features, like chat…

The api Folder
This folder is composed from a buch of sub-folders:

  • the adaptersfolder contains the adapters used by the application to
    handle database connections
  • the controllers folder contains the application controllers
  • the application’s models are stored in the models folder
  • in the policiesfolder are stored rules for application user access
  • the api services implemented by the app are stored in the services folder

The assets Folder
The assets folder contains subdirectories for the Javascript and CSS files that should be loaded during runtime. This is the best place to store auxiliary libraries used by your application.

The public Folder
Contains the files that are publicly available, such as pictures your site uses, the favicon, etc.

The config Folder
This is one of the important folders. Sails is designed to be flexible. It assumes some standard conventions, but it also allows the developer to change the way Sails configures the created app to fit the project’s needs. The following is a list of configuration files present in the config folder:

  • adapters.js – used to configure the database adapters
  • application.js – general settings for the application
  • assets.js – asset settings for CSS and JS
  • bootstrap.js – code that will be ran before the app launches
  • locales– folder containing translations
  • policies.js – user rights management configuration
  • routes.js – the routes for the system
  • views.js – view related settings

The sails.js documentation contains detailed information on each of these folders.

The views Folder
The application’s views are stored in this folder. Looking at its contents, we notice that the views are generated by default as EJS (embedded JavaScript). Also, the views folder contains views for error handling (404 and 500) and also the layout file (layout.ejs) and the views for the home controller, which were generated by Sails.

Note: You can refer full specs here: https://sailsjs.com/documentation/anatomy

App source code structure

Kindie Mobile Application is built by React Native, is an exciting framework that enables web developers to create robust mobile applications using their existing JavaScript knowledge. It offers faster mobile development, and more efficient code sharing across iOS, Android, and the Web, without sacrificing the end user’s experience or application quality.

Now let’s understand what is the purpose of each directory:
index.android.js and index.ios.js are entry points for Android and iOS, respectively
assets Just as the name implies, this houses static files (e.g images) used in the application.
src all customize source code for the project.

  • src/components: All presentational components will go here. They can be put as separate files or organized into folders.
  • src/config: All configuration will be put here, such as routes, image URL list, and more.
  • src/redux: Specify how the application’s state changes in response to actions sent to the redux store (Reducers).
  • src/navigation: Link to navigate between the screens.
  • src/screens: Here we will put our screen layouts.
  • src/helpers: All utility functions will be here.
  • src/servicessrc/services: define REST service to call API funtion from backend

Have fun!


Leave a Reply