Skip to content

Commit 06fc61b

Browse files
committed
Add backend, readme, mdimages
1 parent 43a8fe1 commit 06fc61b

20 files changed

+1057
-1
lines changed

README.md

+72-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,73 @@
11
# CSPathway
2-
An app to guide students though what classes to take
2+
An app to guide students though what classes to take
3+
## Developing
4+
### Git
5+
We use GitHub to host the project, which is a Git hosting service. In order to start working on the project, you must use Git to clone the project.
6+
If you don't have any experience with Git, we recommend using the [GitHub Desktop app](https://desktop.github.com/download/) to give Git an easy-to-use interface.
7+
8+
To get started with this project, fork it!
9+
![Screenshot of GitHub fork button](mdfiles/image-10.png)
10+
11+
![SCreenshot of GutHub fork page](mdfiles/image-11.png)
12+
You can then easily clone the project by clicking the green "Code" button on your fork's GitHub page and selecting "Open with GitHub Desktop".
13+
![Screenshot of Code menu, arrow pointing to "Open with GitHub Desktop"](mdfiles/image.png)
14+
You then need to select a location on your computer to save the project, and click "Clone".
15+
![Screeenshot of GitHub Desktop "Clone" menu](mdfiles/image-1.png)
16+
You will then be asked how the fork will be used. You'll (hopefully!) be contributing back to the parent project.
17+
![Screenshot of "how are you planning to use this fork" menu, arrows pointing to "contributing to the parent project" and "continue"](mdfiles/image-7.png)
18+
Once cloned, you can open the project in your preferred code editor. If you do not have one already, we recommend using [Visual Studio Code](https://code.visualstudio.com/).
19+
![Screenshot of GitHub Desktop "no local changes" screen, with arrow pointing to "Open in Visual Studio Code"](mdfiles/image-2.png)
20+
### Node.js
21+
Both the backend and frontend of the project require Node.js to run. You can download Node.js from the [official website](https://nodejs.org/en/). Installation steps vary by operating system, but the default settings should work for most users.
22+
![Screenshot of NodeJS Homepage, arrow pointing to download button](mdfiles/image-3.png)
23+
## Running the Project
24+
### Structure
25+
There are 2 halves to this project. The frontend and the backend. The frontend is the website that is shown to users, and the backend is where all the computations are done.
26+
27+
Without a backend, the frontend won't be able to display any questions or pathways. Without a frontend, nobody will be able to talk to the backend. Both are necessary for the project to work.
28+
29+
### Backend
30+
31+
To run the backend, you should open a terminal in your code editor. Then, navigate to the backend folder of the project. You can do this by typing `cd backend` in the terminal.
32+
33+
Then, you should make sure all libraries are installed with `npm install`.
34+
35+
Finally, you can start the backend with `node .`. This will start the backend on port 3000.
36+
37+
### Frontend
38+
39+
To run the frontend, open a second terminal in your code editor. Then, navigate to the frontend folder of the project. You can do this by typing `cd frontend` in the terminal.
40+
41+
Then, you should make sure all libraries are installed with `npm install`.
42+
43+
Finally, you can start the frontend with `npm run dev`. This will start the frontend. It will provide you with a link to open the website in your browser.
44+
45+
### Making Changes
46+
47+
When you make a change to the backend, you will need to restart the backend for the changes to take effect. You can do this by pressing `Ctrl+C` in the terminal where the backend is running, and then running `node .` again.
48+
49+
When you make a change to the frontend, changes should appear automatically in your browser. If they do not, you can try refreshing the page. Make sure Auto Save is enabled in your code editor as well.
50+
51+
## Contributing
52+
53+
Once you have made changes to the project, you should commit your changes to Git. Think of a commit like a revision in the Google Docs version history menu. It's a snapshot of the project at a certain point in time.
54+
55+
![Screenshot of Google Docs version history](mdfiles/image-4.png)
56+
57+
To do this, go to the GitHub Desktop app and you should see a list of files that have changed. You can select the files you want to commit. You can also write a commit message to describe what you changed.
58+
59+
![Screenshot of commit menu, arrow pointing to "commit to main"](mdfiles/image-12.png)
60+
61+
To upload your changes to GitHub, you should click "Push Origin" in GitHub Desktop. This will upload your changes to your fork of the project on GitHub.
62+
63+
![Screenshot of GitHub Desktop, arrows pointing to "Push Origin"](mdfiles/image-13.png)
64+
65+
Once you have finished your commits and changes, you should submit a "Pull Request". This is a request to add your changes to the main project. You can do this by clicking "Create Pull Request" in the "Branch" menu in GitHub Desktop.
66+
67+
![Screenshot of menu bar, arrows pointing to "Branch > Create Pull Request](mdfiles/image-14.png)
68+
69+
A browser window will open, where you can write a description of your changes. You can also see a list of changes that you made.
70+
71+
![Screenshot of GitHub Pull Request page, with arrows pointing to title, description, and submit button.](mdfiles/image-15.png)
72+
73+
After you hit submit, your changes are now able to be added to the project.

backend/index.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// We will be using a backend library called Express JS
2+
const express = require('express')
3+
// This creates an app object for use in the code
4+
const app = express()
5+
// This automatically takes the body of requests and interprets them as JSON
6+
app.use(express.json());
7+
// This sets the port that the server will be running on
8+
const port = 3000
9+
10+
11+
// This is a simple GET request that sends a string back to the client
12+
app.get('/exampleget', (req, res) => {
13+
res.send('Hello World!')
14+
})
15+
16+
17+
// This is a simple POST request that logs the body of the request and sends a string back to the client
18+
// POST requests are used to send data to the server, like when submitting a user's replies to a form
19+
app.post('/examplepost', (req, res) => {
20+
// log body of the request, json
21+
console.log(req.body);
22+
res.send('Hello World!')
23+
})
24+
25+
// This starts the app once all the endpoints have been defined
26+
app.listen(port, () => {
27+
console.log(`Example app listening on port ${port}`)
28+
})

0 commit comments

Comments
 (0)