No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
data
data_sample
database
public
scripts
server
src
.eslintrc.yml
.gitignore
.travis.yml
LICENSE.md
Procfile
README.md
package.json
yarn.lock

README.md

Flashcards For Developers

"That's how knowledge works. It builds up, like compound interest." - Warren Buffett

This project contains a small site for studying developer flashcards. This project was bootstrapped with Create React App and it may be useful to refer to its User Guide.

Installing

Clone this project and update your path:

git clone git@github.com:nlaz/flashcards-for-developers.git
cd flashcards-for-developers

Install dependencies and run the web application and server application seperately.

yarn install
yarn web
yarn server  # in a separate window

Open http://localhost:3000/ to view the app in the browser.

Configuration

All configuration options can be passed to the server using environment variables. The following variables are supported:

  • PORT - The port on which the server will listen to requests (Default: 3000)
  • DATABASE_URI - The uri of the database used to store data

Environment variables are set by adding files like .env which should not be checked into source control. Additional .env files can be used:

  • .env: Default.
  • .env.local: Local overrides. This file is loaded for all environments except test.
  • .env.development, .env.test, .env.production: Environment-specific settings.
  • .env.development.local, .env.test.local, .env.production.local: Local overrides of environment-specific settings.

For more information check the create-react-app docs.

Available Scripts

In the project directory, you can run:

yarn web

Runs the frontend side of the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn server

Runs the server side of the app in the development mode.
Make API requests to http://localhost:5000 to interact with the server.

The server will also reload if you make edits.
Note: It also initially loads the built React app on the server at http://localhost:5000

yarn test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn build

Builds the React app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

yarn deploy

Builds the React app for production and runs the server so the the app is ready to be deployed.

Syncing with Airtable

The database uses Airtable to manage our content. We have three records that we sync from Airtable: Collections, Decks, and Cards. If Airtable is updated, the changes will have to be synced to the database. There are three scripts provided in the scripts/ folder to sync these records:

  • sync_cards.js
  • sync_collections.js
  • sync_decks.js

Running these scripts will fetch the data from Airtable and OVERWRITE the records in the database. The database can be changed through environment variables. The default environment is development.

Example:

node scripts/sync_cards.js

Syncing with local JSON files

You can also sync the database with content from JSON files. The sample syntax for the JSON files is shown in the data_sample folder.

Usage:

First put your JSON files into the data folder. The files will be ignored by Git. Then run the script below.

node scripts/seed_db_locally.js

Note that running the script will OVERWRITE the records in the database. The database can be changed through environment variables. The default environment is development.

Data Schema

Hierarchy

  • Collections
    • Decks
      • Cards

Please refer to the data_sample directory for schema reference.

Relationships

Collections

Collections hold references to decks that belong to the collection in an key decks which is an array. The items in the array are of type mongoose.Types.ObjectId.

Decks

Cards hold a reference to the deck they belong to in the key deck of type mongoose.Types.ObjectId.

Cards

Cards hold a reference to the deck they belong to in the key deck of type mongoose.Types.ObjectId.

Contributing

Interested in contributing? Contact @nlaz for help to get started.

License

This project is MIT licensed.