Source code structure
This section will help you to understand the source code structure for further development
In this article
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 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
Note: You can refer full specs here: https://sailsjs.com/documentation/anatomy
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