- Pick one group member to fork the front-end layer repo, and add everyone as collaborators.
- Pick either the same or a different group member to fork the back-end layer repo, and add everyone as collaborators.
- Designate one pair to go through the front-end setup steps, and another pair to go through the back-end setup steps.
Splitting this work allows the pairs to commit and push the initial setup. Then, the rest of the group can pull down that work, which will help everyone!
Feel free to follow these steps on one machine in this order exactly. Feel free to ask questions and get help from your teammates when you need!
Click here to expand front-end layer setup steps.
Clone the forked repo. Do not clone this inside of another project folder, because that will cause issues.
Create a new React app within this project folder. You must perform this within this front-end project folder.
$ npx create-react-app .
Install axios:
$ yarn add axios
Create a file named .env
.
The front-end layer needs to send API requests to the back-end layer. In order to handle this, the front-end layer repo must include a .env
file with this line:
REACT_APP_BACKEND_URL=http://localhost:5000
Note that this REACT_APP_BACKEND_URL
must include http://
.
Use this environment variable to send your API requests. You can read it by using the expression process.env.REACT_APP_BACKEND_URL
. For example, we may use it like this in any component:
axios.get(`${process.env.REACT_APP_BACKEND_URL}/boards`, {
// ...
This will make Heroku deployment easier.
Commit and push your files to your repo, especially including the package.json
file!
Feel free to follow these steps on one machine in this order exactly. Feel free to ask questions and get help from your teammates when you need!
Getting one or two members to do the back-end layer setup first is helpful. This pair can create the models, which will create the migration files. When other members can pull the migration files from git and run the migrations, it's a lot smoother!
Click here to expand back-end layer setup steps.
Clone the forked repo. Do not clone this inside of another project folder, because that will cause issues.
Create a virtual environment:
$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ # You're in activated virtual environment!
Install dependencies (we've already gathered them all into a requirements.txt
file):
(venv) $ pip install -r requirements.txt
Create a database named inspiration_board_development
.
Create a file named .env
.
Add this environment variable: FLASK_ENV=development
Also, add the environment variable SQLALCHEMY_DATABASE_URI
to hold the path to your development database.
Your .env
may look like this:
FLASK_ENV=development
SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://postgres:postgres@localhost:5432/inspiration_board_development
Consider these two initial models with these attributes:
Board
, table name: board
board_id
, int, primary keytitle
, stringowner
, string
Card
, table name: card
card_id
, int, primary keymessage
, stringlikes_count
, int
Then follow these steps. Recall that we can update our models any time. These steps are to initialize our database:
- Run
flask db init
(Do this before making the model files.) - Create the model files for them
- Update
app/__init__.py
to import the two models intocreate_app
- Run
flask db migrate -m "adds Board and Card models"
- Run
flask db upgrade
Check that your Flask server can run with $ flask run
.
The environment variable in the .env
file, FLASK_ENV
, will automatically enable development mode. This enables hot-reloading, which is a feature that refreshes the Flask server every time there is a detected change.
Alternatively, if our environment variable FLASK_ENV
is not enabling development mode, we can manually set it with $ FLASK_ENV=development flask run
.
It is highly recommended to run the Flask servers in development mode.
Commit and push your files to your repo, especially including the migration files!
Get all members aligned on the front-end. Get all members to...
- Clone the repo and pull changes
- Create an identical
.env
file on their local machine - Install dependencies using
yarn install
Get all members aligned on the back-end. Get all members to...
- Clone the repo and pull changes
- Create the
inspiration_board_development
database on their local machine - Create an identical
.env
file on their local machine - Create a virtual environment and activate it
- Install the dependencies from
requirements.txt
- Run
flask db upgrade
The next step is to pursue feature development!
Read through the project requirements, and make a strategy. This is the recommended strategy:
-
Some folks pair and begin front-end development.
- Start with displaying:
- A list of Boards
- A form to create a new Board
- From the requirements, we can infer that each Board has a
title
,owner
name, andboard_id
(as the hidden, implied primary key).
- Start with displaying:
-
Other folks pair and begin back-end development.
- Start with making the conventional endpoints for:
- Getting a list of all boards
- Creating a board
- From the requirements, we can infer that the front-end layer is expecting responses with a
title
,owner
name, andboard_id
.
- Start with making the conventional endpoints for: