Skip to content

Developer Workspace Setup

Naomi Trevino edited this page Jul 5, 2024 · 3 revisions

1. Development Environment Setup

Nix

We use the nix package manager for builds and environments for

  • Reproducible environments across systems
  • Pinned versions of tooling

Nix replaces usage of multiple other package managers

Setup

MacOS

Run this command in the terminal. Then, run the following commands:

mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" > ~/.config/nix/nix.conf

Windows

Use Linux inside of Windows! WSL install guide Install nix with this command Might be relevant advice here

Linux (non-NixOS)

Follow these instructions for multi-user installation. Then, run the following commands:

mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" > ~/.config/nix/nix.conf

Install direnv

Install the package with Nix:

nix-env -iA nixpkgs.direnv

Setup direnv with your shell (by default most systems use BASH)

Automatically loads development shell and loads important environment variables from .env

Clone the Project

Use git to clone the project wherever you want to git clone [email protected]:neu-dsg/dailp-encoding dailp cd dailp Reach out to Naomi Trevino ([email protected]) for a file called .env. Place this file in the cloned repository.

Run direnv allow to tell direnv that you trust our environment configuration.

The first run will take a while as it installs stuff Whenever you cd to DAILP later, it’ll automatically load Rust, NodeJS, Postgres, etc.

Running Everything Locally

Use the following commands to run different components locally:

Command Description
dev-database Starts an instance of the database if possible.
dev-migrate-schema Run pending schema migrations on local database, if any exist. Requires a running database instance.
dev-migrate-data Pull data from spreadsheets into local database. Requires a running database.
dev-graphql Open a GraphQL server on port 8080.
dev-website Build and deploy website to port 3001.

Initializing the database

Run dev-database in one terminal. Do not cancel the process or close the open terminal as you complete the next steps.

In a new terminal, run dev-migrate-schema then dev-migrate-data. You only need to do this once. You may close this terminal or run new commands in this terminal once data migration is complete.

Run dev-graphql in a second terminal. Do not cancel the process or close the open terminal as you complete the next steps.

In a third terminal, run dev-website. Open your browser to http://localhost:3001 to see the website. At this point, you can also open your browser to http://localhost:3001/graphql to view the GraphQL playground.

Code Editors

All of the DAILP team uses VS Code since it is well supported, well documented, multi-language, powerful, adaptable, and free. That being said, you can use any code editor you like.

2. Git

Why do we use git?

  • Version controlling code
  • Separating feature development from deployed code
  • Reviewing changes made by other people
  • Tightly controlling infrastructure changes

Git Tools

  • We strongly recommend using VS Code's basic git support, optionally supplemented by the GitLens extension.
  • The Git CLI works well for the basics.
  • Even though we recommend using VSCode basic git + GitLens, you may use any git client you want.

Git Guidelines

  • Connect to git with SSH
  • Use Feature Branches– do not directly commit to main
  • Make atomic commits
  • Avoid git rebase and other history changing operations unless you need to clean up a branch with git rebase --interactive
  • When you have merge conflicts, use git merge
  • Include both a commit message and a description when theres more context around a commit. Use git commit for this.

Using Branches

For each branch you work on, follow these steps:

  1. Create a new branch with a name related to the task you're working on. ex. add-user-profile-images or fix-local-cors
  2. Write code, tests, and documentation while committing incrementally
  3. Once your work is ready for review, open a pull request. Add one to two developers as reviewers. Reviewers should aim to give code review feedback promptly– ideally within 48 hours.
  4. Once the PR is approved, it can be merged into main!

3. Front-end

4. Rust Back-end

5. Infrastructure

6. One Type to Rule Them All