Skip to content

Commit 4f78348

Browse files
author
mzetinajimen
committed
Make folder stuff more clear
1 parent 0f25460 commit 4f78348

7 files changed

Lines changed: 50 additions & 35 deletions

File tree

Tech-Lab-On-Campus/NewsFeed/Makefile

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,40 @@ FLASK_PORT = 8000
77
help:
88
@echo "Usage:"
99
@echo " help - Prints this screen"
10-
@echo " fmt-backend - Make the formatting changes directly to the backend code"
1110
@echo " install - Install all frontend and backend dependencies"
11+
@echo " fmt-backend - Make the formatting changes directly to the backend code"
1212
@echo " lint-backend - Lints the backend code"
1313
@echo " redis-in-docker - Runs redis in a docker container"
14-
@echo " run - Run both the backend and frontend"
1514
@echo " run-backend - Run the development version of the backend flask app"
1615
@echo " run-frontend - Run the frontend version of this application"
1716
@echo " clean - Clean out temporaries"
1817

19-
20-
.PHONY: install
2118
install:
2219
cd backend && $(PYTHON) -m pip install -e .[dev]
2320
cd frontend && npm install --save-dev
2421

2522
.PHONY: fmt-backend
26-
fmt-backend:
23+
fmt-backend: install
2724
$(PYTHON) -m ruff format
2825
$(PYTHON) -m ruff check --fix
2926

30-
.PHONY: run-backend
31-
run-backend:
32-
FLASK_APP=$(FLASK_APP) flask run --host=0.0.0.0 --port=${FLASK_PORT}
33-
3427
.PHONY: lint-backend
35-
lint-backend:
28+
lint-backend: install
3629
$(PYTHON) -m ruff check
3730
$(PYTHON) -m mypy backend/app --show-error-codes
3831

32+
.PHONY: run-backend
33+
run-backend: install
34+
FLASK_APP=$(FLASK_APP) flask run --host=0.0.0.0 --port=${FLASK_PORT}
35+
3936
.PHONY: redis-in-docker
4037
redis-in-docker:
4138
docker compose up -d redis
4239

4340
.PHONY: run-frontend
44-
run-frontend:
41+
run-frontend: install
4542
cd frontend && npm run dev
4643

47-
.PHONY: run
48-
run:
49-
flask run --host=0.0.0.0 --port=${FLASK_PORT} &
50-
cd frontend && npm run dev &
51-
5244
.PHONY: clean
5345
clean:
5446
@echo "Removing temporary files"

Tech-Lab-On-Campus/NewsFeed/docs/backend.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
You are tasked to get news articles from Redis Cache. You will be implementing two functions in order to display them on the News Feed Website. Do not worry about reading in the data from Redis; this is done for you in `backend/app/utils/redis.py`.
44

55
## Hints:
6-
* **Hint 1:** There is only one function from `backend/app/utils/redis.py` you will need to fetch articles.
6+
* **Hint 1:** There is only one function from `backend/app/utils/redis.py` you will need to fetch articles. It can return any object you store in redis and take any shape you like.
77
* **Hint 2:** In order to get the articles, look at how the data is written into Redis in `backend/app/__init__.py`.
88
* **Hint 3**: You can test the backend / API changes without the frontend code! Run `localhost:8000/{endpoint}`.
9+
- **Hint 4:** The relevant resources can be found from [resources](./resources/overview.md).
910

1011
## Part 1: Write a function to Format Data
1112
In `backend/app/newsfeed.py`, implement a private method that can format the data into an article object. Check a json file in `backend/app/resources/dataset/news` to retrieve necessary information to create an article object.

Tech-Lab-On-Campus/NewsFeed/docs/frontend.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ You are tasked with populating the frontend of a news feed webpage which is goin
77
- **Hint 1:** Some classes included in `frontend/src/styles/globals.css` may help with styling.
88
- **Hint 2:** [Array.map()]((https://www.geeksforgeeks.org/typescript-array-map-method/)) may be useful.
99
- **Hint 3:** This [Medium blog](https://medium.com/@bhanu.mt.1501/api-calls-in-react-js-342a09d5315f) may be useful to figure how to fetch data.
10+
- **Hint 4:** The relevant resources can be found from [resources](./resources/overview.md).
1011

1112
## Part 1 : Display a Featured News Article
1213
In `frontend/src/components/FeaturedNews.tsx` implement the component that will display the featured news article.

Tech-Lab-On-Campus/NewsFeed/docs/index.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ By participating in this tech lab, students will:
3131
- Develop APIs to handle data requests and responses.
3232
- Integrate Redis for storing data to improve performance.
3333

34-
### Frontend (React)
34+
### Frontend (NextJS/React)
3535

3636
- Create a user interface to display data retrieved from the backend.
3737
- Implement forms and components to interact with the backend APIs.
@@ -69,9 +69,20 @@ VS Code may also show a pop up requesting to repoen in container, you can also c
6969

7070
### Run the Website
7171

72-
1. Open up a new terminal window, you can use `` Ctrl+Shift+` ``
72+
All of the `make` commands should be run from the Newfeed folder (using the `cd bbit-learning-labs/Tech-Lab-On-Campus/NewsFeed`
73+
command from above should have placed you in the right folder). You can also simplify your workspace by simply opening
74+
the Newsfeed folder in VS Code. To check that you are in the right folder on your computer terminal:
75+
76+
1. Run `pwd`
77+
2. Verify that is says `/local/path/to/bbit-learning-labs/Tech-Lab-On-Campus/NewsFeed`, where "/local/path/to" is your
78+
local computers path to the bbit-learning-labs folder you cloned. An example of this would be: "/user/USERNAME/Downloads",
79+
but this will vary from person to person.
80+
81+
To get the web app up and running:
82+
83+
1. Open up a new **VS Code terminal window**, you can use <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>`</kbd>
7384
2. In the terminal, run `make run-backend` to run the backend
74-
3. Open up another new terminal window, you can use `` Ctrl+Shift+` `` again
85+
3. Open up another new terminal window, you can use <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>`</kbd> again
7586
4. In the terminal, run `make run-frontend` to run the frontend
7687

7788
✨ You should now be ready to develop! ✨
@@ -97,11 +108,19 @@ If you are encountering issues with docker, you can use Github codespaces instea
97108
9. Open up a new terminal and run `make run-frontend`
98109
10. A pop up should appear saying that port 3000 is in use. Click on `Open in Browser`. If not, the link can be opened from the terminal window
99110

111+
### Starting Frontend
112+
113+
- Clicking on http://localhost:3000 in the terminal opens to a blank page in the browser?
114+
- Make sure you have done `make run` from the NewsFeed folder (where the Makefile is)
115+
- It will probably have opened to 0.0.0.0:3000, just rewrite the url to localhost:3000 in the browser and it should load.
116+
- npm packages are not loading
117+
- If you are a bloomberg engineer, try turning off bbpvn while dev container sets up
118+
- Otherwise, try running make clean or deleting any package.json or node_module directories and running:
119+
`npm install` from within the `./frontend` folder. (Can reach via `cd frontend`)
120+
- If this does not work, try to open in codespaces, see [issues with docker](#issues-with-docker) section above.
121+
100122
## Resources
101123

102-
- [React Documentation](https://reactjs.org/docs/getting-started.html)
103-
- [Flask Documentation](https://flask.palletsprojects.com/en/2.0.x/)
104-
- [Redis Documentation](https://redis.io/documentation)
105-
- [Docker Documentation](https://docs.docker.com/)
124+
- [Resources](./resources/)
106125

107126
We hope you enjoy this learning experience and look forward to seeing your innovative solutions!
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Instructions for creating resource documents
2+
3+
In this directory, you can find introductions to the basic functionality of the technologies that will be used for this tech lab.
4+
5+
The technologies planned to be used are:
6+
* [Git](./git-basics.md)
7+
* [Docker](./docker-basics.md)
8+
* [Python](./python-basics.md)
9+
* [Redis](./redis-basics.md)
10+
* [JavaScript](./html-basics.md)
11+
* [React](./react-basics.md)
12+
* [NextJS](./next-js-bascis.md)

Tech-Lab-On-Campus/NewsFeed/docs/resources/resources.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

Tech-Lab-On-Campus/NewsFeed/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ nav:
55
- Frontend: frontend.md
66
- Interview Question Prompt: api-question-prompt.md
77
- Resources:
8+
- Overview: resources/overview.md
89
- Git Basics: resources/git-basics.md
910
- Docker Basics: resources/docker-basics.md
1011
- Python Basics: resources/python-basics.md

0 commit comments

Comments
 (0)