This repository has been archived by the owner on Feb 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Code Walkthrough
Emmanuel Proulx edited this page Jan 2, 2019
·
9 revisions
The code is split into 5 different sections:
- The Tree API simply lets users query the clades collection; it builds a tree based on a root clade and a depth).
- The User API provides the front-end with members and permissions.
- The Client hold all of the React code and serves as the client.
- The Admin Daemon is basically a transaction processor; when someone makes a change, it doesn't update the database directly. It creates a transaction that the daemon picks up and processes to then update the database.
- The Common code is included in every module above. It contains code to access AWS (for S3 which is used for storing images) as well as database models.
This project uses:
- Git (Bitbucket)
- Node.js
- Express
- Express-jwt
- React.js
- Bluebird
- D3
- Mongoose
- Passport
- fbjs
- fixed-data-table
- isomorphic-style-loader
- Draft.js
- Classnames
- throttle-debounce
- eventemitter3
- fetch (whatwg-fetch, window.fetch polyfill)
- history
- Babel
- Fastclick
- universal-router
- compression
- pretty-error
- AWS (aws-sdk)
- MongoDB
- npm
- pm2
Let's explore how the code is organized. Each of the modules contains the following:
File/Folder | Description |
---|---|
File package.json | The input file for the npm install command. Contains a list of all the library dependencies, with version numbers. Contains also the actions you can do on this project. |
File package-lock.json | Contains a detailed description of all the actions of npm install. |
node_modules | This is where the library dependencies get downloaded to. |
src | Source code (more on this in next section). |
test | Tests. Not used. |
tools/*.js | This contains the configuration and scripts that are used to compile the project. |
File README.md | Description of the repository. |
The content of the src folder, depends on the type of module. For the back-end modules (admin-api, admin-daemon, public-api), the structure is:
File/Folder | Description |
---|---|
common | A subproject that contains S3 utilities and database models. It is located in its own Git repository, and included in each other project. |
File app.js | "Main" of the module. |
controllers | For REST API modules (admin-api, public-api), this contains a list of controllers. Each controller is in charge of a single subset of the API, e.g. authentication, user management, clade administration. |
routes | Contains the mapping between URLs and controllers. index.js is the main map, and other files each contain a single subset. |
middleware | Contains adapters to external systems. For example, AuthCheck.js contains the adapter between the Passport authentication system and our database. |
modules | |
components | Contains various utility classes. |
build | Generated by the build. |
File/Folder | Description |
---|---|
docs | Documentation. (Outdated.) |
node_modules | Contains the library dependencies, as downloaded by the build. |
components | Contains all the dynamic web pages and GUI elements. |
core | Contains various utility classes. |
public | Contains all the static GUI elements such as icons, robots.txt, etc. |
routes | Contains the mapping between URLs and components. index.js is the main map, and other files each contain a single subset. |
File server.js | Server-side "main" for the web application. |
File client.js | Client-side "main" for the web application. |
File config.js | Hardcoded values for port and external URLs and credentials. |
Users of the system are stored in the phylex-admin database in the users table.
There are two types of users: Admin and User.
- An admin can do anything including administer the users, roles, transactions, and everything that a normal user can do.
- A user can only access the clades and has a read-only access to everhthing else. Users must be vetted via a registration process. They first apply via the main page's Register section. After they are accepted, they can log in.
- The software (code) is distributed under the MIT License.
- The data is distributed under the "Creative Commons, Attribution-NoDerivatives" license.
- For full license text, see https://github.com/phylogeny-explorer/explorer/blob/master/LICENSE