Skip to content

Commit f53a48b

Browse files
committed
Merge with main
2 parents d6e3f8a + 474d7e8 commit f53a48b

File tree

80 files changed

+3991
-3534
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3991
-3534
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Design to Engineering Handoff Issue
3+
about: PMs use this template when a User Story is ready for Engineering. This will be a separate issue for Engineering to track their work.
4+
title: 'Engineering for #[add related user story issue number] [Related User Story Title]'
5+
labels: 'milestone: missing, points: missing, Role: missing, Complexity: Missing, Feature: Missing'
6+
assignees: ''
7+
8+
---
9+
10+
**UPDATE LABELS: Add the following labels to each new issue, and remove default labels. Then remove this section:**
11+
* Role
12+
* Feature
13+
* Points
14+
* Complexity
15+
16+
### Dependencies/Related Engineering issues
17+
18+
#### Back End
19+
-
20+
21+
#### Front End
22+
-
23+
24+
#### Dev Ops
25+
-
26+
27+
### Overview
28+
This issue is for tracking engineering work related to #[add related user story issue number], which is [add short description of related user story]
29+
30+
### Action Items
31+
- Assign and Prep
32+
- [ ] Engineering Lead: Review User Story and Design and assign Engineer
33+
- [ ] Engineer: Review User Story and Design
34+
- [ ] Engineer: Work with PM and Design Lead to clarify any questions about the User Story
35+
- [ ] Engineer/Engineering Lead: determine if work should be split into multiple issues, if so create those issues and link them in this issue.
36+
- Draft and Review:
37+
- [ ] [Add engineering action items here]
38+
- [ ] Code is deployed, changes are visible in https://dev.homeunite.us/
39+
- Let Product know that it is ready for review
40+
- [ ] Engineer: Change Issue Status to "For Review/Feedback Needed"
41+
- [ ] Engineer: Add Label "Ready for: Product"
42+
- [ ] Engineer: Tag the PM (assignee) of the related User Story in a comment below and let them know that a draft is ready for review
43+
- [ ] Product: Review https://dev.homeunite.us/ and compare against Acceptance Criteria
44+
- [ ] Repeat above steps until all Acceptance Criteria in the User Story are accounted for
45+
46+
### Resources/Instructions

.github/workflows/run-tests-v1.yml

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run API and App Tests
1+
name: Run API and Frontend Tests
22
on:
33
pull_request:
44
branches: [main]
@@ -11,56 +11,45 @@ jobs:
1111
defaults:
1212
run:
1313
shell: bash
14-
working-directory: ./api
14+
working-directory: ./backend
1515
steps:
1616
- uses: actions/checkout@main
1717
with:
1818
fetch-depth: 500
1919
fetch-tags: true
20-
- name: Set up Python 3.10
21-
uses: actions/setup-python@v4
20+
- name: Install poetry
21+
run: pipx install poetry
22+
- name: Set up Python 3.12
23+
uses: actions/setup-python@v5
2224
with:
23-
python-version: "3.10"
24-
cache: "pip"
25-
- name: Upgrade pip
26-
run: python -m pip install --upgrade pip
27-
- name: Install API dev Dependencies
28-
run: |
29-
pip install -r requirements-dev.txt
30-
- name: Run development tests with mocking enabled, using tox
31-
run: |
32-
# Use tox because it is configured to test against the same package type being deployed
33-
tox
34-
- name: Run release tests with mocking disabled, using tox
35-
env:
36-
COGNITO_REGION: ${{ secrets.COGNITO_REGION }}
37-
COGNITO_ACCESS_ID: ${{ secrets.COGNITO_ACCESS_ID }}
38-
COGNITO_ACCESS_KEY: ${{ secrets.COGNITO_ACCESS_KEY }}
39-
run: |
40-
echo "COGNITO_REGION set"
41-
tox -e releasetest
42-
test-app:
25+
python-version: "3.12"
26+
cache: "poetry"
27+
- name: Install API Dependencies
28+
run: poetry install --with test
29+
- name: Run tests
30+
run: poetry run pytest
31+
test-frontend:
4332
runs-on: ubuntu-latest
4433
defaults:
4534
run:
4635
shell: bash
47-
working-directory: ./app
36+
working-directory: ./frontend
4837
steps:
4938
- uses: actions/checkout@v4
5039
- name: Use Node.js 20
5140
uses: actions/setup-node@v4
5241
with:
5342
node-version: 20
5443
cache: "npm"
55-
cache-dependency-path: app/package-lock.json
44+
cache-dependency-path: frontend/package-lock.json
5645
- name: Run npm CI
5746
run: npm ci
58-
- name: Test app
47+
- name: Test frontend
5948
run: npm run test -- --no-color --run
6049
- name: Run E2E tests
6150
uses: cypress-io/github-action@v5
6251
with:
6352
install: false
6453
start: npm run dev
65-
working-directory: ./app
66-
wait-on: "http://[::1]:4040/"
54+
working-directory: ./frontend
55+
wait-on: "http://localhost:4040/"

.incubator/app.Dockerfile

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
ARG NODE_VERSION=20.18.0-bookworm
2+
ARG HUU_BASE_VERSION=1.1
3+
ARG HUU_ECR_REPOSITORY=035866691871.dkr.ecr.us-west-2.amazonaws.com/homeuniteus
4+
5+
# use the official Node image for building the UI bundle
6+
FROM node:${NODE_VERSION} AS client-builder
7+
8+
9+
# navigate to dir where client app source and build will live
10+
WORKDIR /app
11+
12+
# copy the UI source code and configurations into our working dir
13+
COPY ./frontend ./
14+
15+
ENV VITE_HUU_API_BASE_URL=https://qa.homeunite.us/api
16+
17+
# install the NPM packages and generate the UI build
18+
RUN npm install && npm run build
19+
20+
# use our custom base image with pre-installed Python
21+
# note: if we adjust to work with a common stable
22+
# version of Python (i.e. latest available package
23+
# for distro), then we should merge the base image
24+
# dockerfile here and install directly
25+
FROM ${HUU_ECR_REPOSITORY}:base-${HUU_BASE_VERSION}
26+
27+
# expose parameters for custom configuration of build SDK/runtime versions
28+
# and build process configurations
29+
ARG POETRY_VERSION=1.8
30+
ARG HUU_TARGET_ENV=qa
31+
32+
# navigate to dir where API sources and scripts will live
33+
WORKDIR /opt/huu
34+
35+
# copy the API source into our working dir
36+
COPY ./backend ./
37+
38+
# set some env vars to configure poetry behavior
39+
ENV POETRY_HOME=/opt/poetry
40+
ENV POETRY_NO_INTERACTION=1
41+
ENV PYTHONDONTWRITEBYTECODE=1
42+
ENV PYTHONUNBUFFERED=1
43+
44+
# Tell Poetry where to place its cache and virtual environment
45+
ENV POETRY_CACHE_DIR=/opt/.cache
46+
47+
# create a virtual env for the poetry workspace
48+
RUN python3 -m venv venv
49+
50+
# install poetry using the virtual env's version of `pip`
51+
RUN ./venv/bin/pip install "poetry==${POETRY_VERSION}"
52+
53+
# Install the dependencies and clear the cache afterwards.
54+
# This may save some MBs.
55+
# RUN ./venv/bin/poetry install --no-root && rm -rf $POETRY_CACHE_DIR
56+
RUN ./venv/bin/poetry install
57+
58+
# pull our UI build (generated in previous stage) into the conventional
59+
# location for its nginx `server` block
60+
COPY --from=client-builder /app/dist /var/www/${HUU_TARGET_ENV}.homeunite.us/html/
61+
62+
# overwrite the default nginx `server` block with ours - note that
63+
# if we ever want to acutally deploy separate server blocks, this
64+
# file should be deleted in favor of a conf file at:
65+
# /etc/nginx/sites-available/${HUU_TARGET_ENV}.homeunite.us
66+
# which should be symlinked to: `/etc/nginx/sites-enabled/`
67+
COPY ./.incubator/default.conf /etc/nginx/conf.d/default.conf
68+
69+
# replace the template values for the environment - this corresponds
70+
# to the subdomain of *.homeunite.us where this image will be deployed
71+
RUN sed -i "s/<HUU_ENVIRONMENT>/${HUU_TARGET_ENV}/g" /etc/nginx/conf.d/default.conf
72+
73+
# add our entrypoint script, which will start the API process and fork
74+
# it into the background, then run the default entrypoint for nginx
75+
COPY ./.incubator/huu-entrypoint.sh ./
76+
77+
# set the `x` flag to allow execution by the dockerd process
78+
RUN chmod +x /opt/huu/huu-entrypoint.sh
79+
80+
# create the target directory for the nginx access and error logs
81+
RUN mkdir -p /var/log/${HUU_TARGET_ENV}.homeunite.us/
82+
83+
# launch the application from our custom entrypoint script
84+
ENTRYPOINT [ "/opt/huu/huu-entrypoint.sh" ]

.incubator/base.Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ARG NGINX_VERSION=1.27.2
2+
3+
FROM nginx:${NGINX_VERSION}
4+
5+
ARG PYTHON_VERSION=3.12.5
6+
7+
# use latest available system package listings and installations
8+
RUN apt-get update -y && apt-get upgrade -y
9+
10+
# we need `curl` to download things, and `build-essential` to
11+
# install python and node from source
12+
RUN apt-get install -y \
13+
curl \
14+
build-essential \
15+
libsqlite3-dev \
16+
libpq-dev \
17+
zlib1g-dev
18+
19+
# keep dependency installation resources separate from source
20+
WORKDIR /opt
21+
22+
# download and install python from source
23+
# as of this writing, the latest package supported by apt is Python 3.9, and
24+
# this is the simplest way to get Python 3.12+ installed
25+
26+
# download and extract Python source
27+
RUN curl -LO https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \
28+
&& tar xzf Python-${PYTHON_VERSION}.tgz
29+
30+
# navigate to root of Python source for installation
31+
WORKDIR /opt/Python-${PYTHON_VERSION}
32+
33+
# build and install Python from source
34+
RUN ./configure --enable-loadable-sqlite-extensions \
35+
&& make \
36+
&& make install
37+

.incubator/default.conf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
server {
2+
3+
listen 80;
4+
listen [::]:80;
5+
6+
root /var/www/<HUU_ENVIRONMENT>.homeunite.us/html;
7+
index index.html index.htm index.nginx-debian.html;
8+
9+
server_name <HUU_ENVIRONMENT>.homeunite.us www.<HUU_ENVIRONMENT>.homeunite.us localhost;
10+
11+
access_log /var/log/<HUU_ENVIRONMENT>.homeunite.us/nginx-access.log;
12+
error_log /var/log/<HUU_ENVIRONMENT>.homeunite.us/nginx-error.log;
13+
14+
location / {
15+
try_files $uri $uri/ /index.html =404;
16+
}
17+
18+
location /img {
19+
try_files $uri =404;
20+
}
21+
22+
location /api/ {
23+
proxy_set_header X-Real-IP $remote_addr;
24+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
25+
proxy_set_header X-Forwarded-Proto $scheme;
26+
proxy_set_header X-NginX-Proxy true;
27+
proxy_pass http://127.0.0.1:8000/api/;
28+
proxy_ssl_session_reuse off;
29+
proxy_set_header Host $http_host;
30+
proxy_cache_bypass $http_upgrade;
31+
proxy_redirect off;
32+
}
33+
34+
}

.incubator/huu-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
pushd /opt/huu
4+
./venv/bin/poetry run fastapi run app/main.py --port 8000 &
5+
popd
6+
7+
/docker-entrypoint.sh nginx -g 'daemon off;'

README.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ This project is part of a larger initiative at Hack for LA around creating a sha
1414

1515
## Technology Overview
1616

17-
The HomeUniteUs project is structured as a multi-[docker](https://docs.docker.com/) container application (for local development and testing), with secret-protected access to networked resources. The project contains three containers, whose activities are coordinated using the `docker compose` configuration outlined in `docker-compose.yml`. The three containers are:
18-
19-
1. `app`: A frontend [React](https://reactjs.org/docs/getting-started.html) app developed using [TypeScript](https://www.typescriptlang.org/).
20-
* We use [Redux](https://redux.js.org/) to manage client state, with the [Redux Toolkit](https://redux-toolkit.js.org/) to simplify development.
21-
* We use the [Material UI](https://material-ui.com/) component library, for access to high quality UI components designed with accessibility in mind.
22-
* We use the [Vite](https://vitejs.dev/) build tool, for fast dev builds and optimized production builds.
23-
2. `api`: A backend python [connexion](https://connexion.readthedocs.io/en/latest/) REST API, hosted on [AWS](https://docs.aws.amazon.com/).
24-
* We use `connexion` to simplify our API specification and validation. `connexion` uses the [OpenAPI](https://www.openapis.org/) [specification](https://spec.openapis.org/oas/v3.0.1.html) to map API URLs to specific python functions. It will handle routing, validation, security, and parameter passing when an API request is made. `connexion` also generates documentation for our API, and provides a useful user interface (at `{URL}/api/ui`) that can be used to easily interact with the API for development purposes. We use the variant of `connexion` that runs on top of [Flask](https://flask.palletsprojects.com/en/1.1.x/).
25-
* We use the [SQLAlchemy](https://www.sqlalchemy.org/) SQL toolkit and [Object-Relational Mapper (ORM)](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping). This serves as a developer-friendly layer between the python app and the database.
26-
* We use [gunicorn](https://gunicorn.org/) as our WSGI server. A WSGI server acts as a communication intermediary between an HTTP proxy and the Hone Unite Us API, handling client requests and passing them to the application, then returning the application's responses to the client.
27-
* We use [nginx](https://nginx.org/en/docs/) as our HTTP server. This “reverse proxy” sits in front of the WSGI server, and handles a number of complex web server tasks. It is capable of load balancing across the WSGI server works, managing TLS connections, serving static files, and more.
17+
The HomeUniteUs project is structured as a multi-[docker](https://docs.docker.com/) container application, with secret-protected access to networked resources. The project contains five containers, whose activities are coordinated using the `docker compose` configuration outlined in `docker-compose.yml`. The five containers are:
18+
19+
1. `frontend`: A frontend [React](https://reactjs.org/docs/getting-started.html) app developed using [TypeScript](https://www.typescriptlang.org/).
20+
* It uses [Redux](https://redux.js.org/) to manage client state, with the [Redux Toolkit](https://redux-toolkit.js.org/) to simplify development.
21+
* It uses the [Material UI](https://material-ui.com/) component library, for access to high quality UI components designed with accessibility in mind.
22+
* It uses the [Vite](https://vitejs.dev/) build tool, for fast dev builds and optimized production builds.
23+
2. `backend`: A backend python API, hosted on [AWS](https://docs.aws.amazon.com/).
24+
* It uses `FastAPI` as its web framework.
25+
* It uses the [SQLAlchemy](https://www.sqlalchemy.org/) SQL toolkit and [Object-Relational Mapper (ORM)](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping). This serves as a developer-friendly layer between the Python app and the database.
2826
3. `db`: A [PostgreSQL](https://www.postgresql.org/) database container.
2927
* The database is stored as a docker volume, `db-data`.
3028
* If the volume is not found during spin-up, then an empty database volume will be created.
31-
32-
In the production environment, each of these services along with `nginx` are deployed onto an EC2 instance and managed as `systemd` service units instead of with Docker.
29+
4. `motoserver`: A development tool. It runs [`moto`](http://docs.getmoto.org/en/latest/docs/server_mode.html) in Server Mode.
30+
* It allows developers to mock AWS so that AWS secrets are not needed for local development. This tool is used because HUU uses AWS Cognito as its identity and access provider. However, most local development will not need to make actual calls to AWS Cognito for HUU feature development. Using this tool will allow developers to login to HUU on their development machine.
31+
* It has a dashboard located at http://127.0.0.1:5000/moto-api/
32+
5. `pgadmin`: An optional development tool. It is a container running [pgAdmin4](https://www.pgadmin.org/). pgAdmin4 is database administration and development platform for PostgreSQL.
33+
* This tool will allow can be used to run queries against the PostgreSQL server running in the `db` container.
34+
* It is accessed by going to http://127.0.0.1:5050
3335

3436
## Build Instructions
3537

36-
Before you can build the project, you will require a `.env` file containing access keys to the application third party services. Please message a team member on the [#home-unite-us slack channel](https://hackforla.slack.com/archives/CRWUG7X0C) once you've completed onboarding. See the [api](./api/README.md) and [app](./app/README.md) READMEs for more information about the required and optional environment variables.
37-
38-
Since this project is dockerized, you can choose to either build the backend and frontend apps as docker containers or directly onto your local machine. This guide will focus on docker builds, but full local build and deployment instructions can be found in the [api](./api/README.md) and [app](./app/README.md) READMEs.
38+
Since this project is Dockerized, you can choose to either build the backend and frontend apps as Docker containers or directly onto your local machine. This guide will focus on Docker builds, but full local build and deployment instructions can be found in the [api](./backend/README.md) and [app](./frontend/README.md) READMEs.
3939

4040
Also note that the code in this repo *should* build without issue on Linux, Windows, and MacOS. We do, however, utilize some Linux-only tools during deployment and primarily target the Linux platform.
4141

@@ -45,16 +45,28 @@ Building with Docker is the simplest option, and debugging applications within t
4545

4646
#### Requirements
4747

48-
* A copy of the `.env` file described above
49-
* An up-to-date installation of [docker](https://docs.docker.com/get-docker/)
48+
* An up-to-date installation of [Docker](https://docs.docker.com/get-docker/)
5049

5150
#### Instructions
5251

53-
1. Place a copy of the `.env` file in the `app` directory
54-
2. Place a copy of the `.env` file in the `api` directory
55-
3. Build all three containers by running the `docker compose up` shell command from the root directory:
56-
4. Verify there are no build errors, and open `localhost:4040` in any browser, to see the application
52+
1. Build and run all containers by running the `docker compose up -d --build` shell command from the root directory:
53+
2. Verify there are no build errors. If there are build errors, reach out to the development team.
54+
3. Open `http://localhost:4040` in any browser to use Home Unite Us.
55+
56+
* `pgAdmin4` is available at http://localhost:5050/browser/ to query the database.
57+
* `moto` server is available at http://localhost:5000/moto-api/ to view mocked AWS data.
58+
59+
#### Test Users
60+
61+
For local development, test users already exist when started using Docker.
62+
63+
The password for all test users is `Test123!`.
64+
65+
- 1 Admin: admin@email.com
66+
- 26 Guests: guest[a-z]@email.com (e.g. `guesta@email.com`, `guestb@email.com`, ... `guestz@email.com`)
67+
- 26 Coordinators: coordinator[a-z]@email.com (e.g. `coordinatora@email.com`, `coordinatorb@email.com`, ... `coordinatorz@email.com`)
68+
- 26 Hosts: host[a-z]@email.com (e.g. `hosta@email.com`, `hostb@email.com`, ... `hostz@email.com`)
5769

5870
## Testing Instructions
5971

60-
Testing instructions for each application are in the [api](./api/README.md) and [app](./app/README.md) README files.
72+
Testing instructions for each application are in the [backend](./backend/README.md) and [frontend](./frontend/README.md) README files.

backend/.env.example

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
COGNITO_CLIENT_ID=
2-
COGNITO_CLIENT_SECRET=
3-
COGNITO_REGION=
4-
COGNITO_REDIRECT_URI=http://localhost:34828/signin
5-
COGNITO_USER_POOL_ID=
6-
COGNITO_ACCESS_ID=
7-
COGNITO_ACCESS_KEY=
8-
ROOT_URL=http://localhost:34828
9-
DATABASE_URL=sqlite:///./homeuniteus.db
1+
COGNITO_CLIENT_ID=testing
2+
COGNITO_CLIENT_SECRET=testing
3+
COGNITO_REGION=us-east-1
4+
COGNITO_REDIRECT_URI=http://localhost:4040/signin
5+
COGNITO_USER_POOL_ID=testing
6+
COGNITO_ACCESS_ID=testing
7+
COGNITO_ACCESS_KEY=testing
8+
COGNITO_ENDPOINT_URL=http://127.0.0.1:5000
9+
ROOT_URL=http://localhost:4040
10+
DATABASE_URL=postgresql+psycopg2://postgres:postgres@127.0.0.1:5432/huu

0 commit comments

Comments
 (0)