Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
install: false
start: npm run dev
working-directory: ./frontend
wait-on: "http://localhost:4040/"
wait-on: "http://localhost:4041/"
6 changes: 3 additions & 3 deletions .github/workflows/run-tests-v2.yml.old
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
image: ghcr.io/hackforla/homeuniteus/app:latest-test
options: --entrypoint /bin/bash --no-healthcheck
env:
CYPRESS_BASE_URL: http://frontend:4040
CYPRESS_BASE_URL: http://frontend:4041
CYPRESS_USE_MOCK: true
steps:
- name: Run Tests With Backend Mocking
Expand All @@ -102,7 +102,7 @@ jobs:
image: ghcr.io/hackforla/homeuniteus/app:latest-test
options: --entrypoint /bin/bash --no-healthcheck
env:
CYPRESS_BASE_URL: http://frontend:4040
CYPRESS_BASE_URL: http://frontend:4041
CYPRESS_USE_MOCK: false
CYPRESS_REAL_EMAIL: [email protected]
CYPRESS_REAL_PASSWORD: Test!123
Expand All @@ -127,4 +127,4 @@ jobs:
# install: false
# start: npm run dev
# working-directory: ./app
# wait-on: "http://[::1]:4040/"
# wait-on: "http://[::1]:4041/"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Building with Docker is the simplest option, and debugging applications within t

1. Build and run all containers by running the `docker compose up -d --build` shell command from the root directory:
2. Verify there are no build errors. If there are build errors, reach out to the development team.
3. Open `http://localhost:4040` in any browser to use Home Unite Us.
3. Open `http://localhost:4041` in any browser to use Home Unite Us.

* `pgAdmin4` is available at http://localhost:5050/browser/ to query the database.
* `moto` server is available at http://localhost:5000/moto-api/ to view mocked AWS data.
Expand Down
4 changes: 2 additions & 2 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
COGNITO_CLIENT_ID=testing
COGNITO_CLIENT_SECRET=testing
COGNITO_REGION=us-east-1
COGNITO_REDIRECT_URI=http://localhost:4040/signin
COGNITO_REDIRECT_URI=http://localhost:4041/signin
COGNITO_USER_POOL_ID=testing
COGNITO_ACCESS_ID=testing
COGNITO_ACCESS_KEY=testing
COGNITO_ENDPOINT_URL=http://127.0.0.1:5000
ROOT_URL=http://localhost:4040
ROOT_URL=http://localhost:4041
DATABASE_URL=postgresql+psycopg2://postgres:[email protected]:5432/huu
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ RUN chmod +x /code/startup_scripts/entrypoint.sh
WORKDIR /code
ENTRYPOINT ["/code/startup_scripts/entrypoint.sh"]
CMD []
EXPOSE 8000
EXPOSE 8080
29 changes: 29 additions & 0 deletions backend/alembic/versions/5e9719d2f076_create_contact_info_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""create contact_info table

Revision ID: 009fe89fbb99
Revises: a1a53aaf81d3
Create Date: 2025-06-20 00:54:00.883606

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '009fe89fbb99'
down_revision = 'a1a53aaf81d3'
branch_labels = None
depends_on = None

def upgrade():
op.create_table(
'contact_info',
sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
sa.Column('preferred_method', sa.String(length=50), nullable=False),
sa.Column('phone_number', sa.String(length=20), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
)


def downgrade():
op.drop_table('contact_info')
6 changes: 3 additions & 3 deletions backend/alembic/versions/a1a53aaf81d3_initial_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def upgrade() -> None:
sa.Column('title', sa.String(), nullable=False),
sa.Column('description', sa.String(), nullable=False),
sa.Column('created_at',
sa.DateTime(timezone=True),
server_default=sa.sql.func.utcnow(),
nullable=False), sa.PrimaryKeyConstraint('form_id'))
sa.DateTime(timezone=True),
server_default=sa.text('CURRENT_TIMESTAMP'),
nullable=False)),
op.create_table('housing_orgs',
sa.Column('housing_org_id', sa.Integer(), nullable=False),
sa.Column('org_name', sa.String(), nullable=False),
Expand Down
15 changes: 15 additions & 0 deletions backend/app/modules/host_dashboard/crud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from sqlalchemy.orm import Session
from . import models, schemas

def create_contact_info(db: Session, contact_info: schemas.ContactInfoCreate):
db_entry = models.ContactInfo(
preferred_method=contact_info.preferred_method,
phone_number=contact_info.phone_number
)
db.add(db_entry)
db.commit()
db.refresh(db_entry)
return db_entry

def get_contact_info(db: Session, contact_id: int):
return db.query(models.ContactInfo).filter(models.ContactInfo.id == contact_id).first()
10 changes: 10 additions & 0 deletions backend/app/modules/host_dashboard/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from sqlalchemy import Column, Integer, String, DateTime, func
from app.core.db import Base

class ContactInfo(Base):
__tablename__ = "contact_info"

id = Column(Integer, primary_key=True, index=True, autoincrement=True)
preferred_method = Column(String(50), nullable=False)
phone_number = Column(String(20), nullable=False)
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
20 changes: 20 additions & 0 deletions backend/app/modules/host_dashboard/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
from app.modules.deps import DbSessionDep
from . import schemas, crud

router = APIRouter()

@router.post("/contact-info")
def submit_contact_info(
contact_info: schemas.ContactInfoCreate,
db: DbSessionDep
):
return crud.create_contact_info(db, contact_info)

@router.get("/contact-info/{contact_id}", response_model=schemas.ContactInfo)
def get_contact_info(contact_id: int, db: DbSessionDep):
contact = crud.get_contact_info(db, contact_id)
if not contact:
raise HTTPException(status_code=404, detail="Contact info not found")
return contact
15 changes: 15 additions & 0 deletions backend/app/modules/host_dashboard/schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pydantic import BaseModel, Field
from datetime import datetime

class ContactInfoCreate(BaseModel):
preferred_method: str = Field(..., max_length=50)
phone_number: str = Field(..., min_length=10, max_length=20)

class ContactInfo(BaseModel):
id: int
preferred_method: str
phone_number: str
created_at: datetime

class Config:
orm_mode = True
6 changes: 6 additions & 0 deletions backend/app/modules/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from app.modules.tenant_housing_orgs import controller as housing_org
from app.modules.workflow.dashboards.coordinator import coordinator_dashboard

from app.modules.host_dashboard import routes as host_dashboard_routes

api_router = APIRouter()

api_router.include_router(auth_controller.router,
Expand All @@ -23,3 +25,7 @@
prefix="/housing-orgs",
tags=["tenant_housing_orgs"])
api_router.include_router(coordinator_dashboard.router, tags=["coordinator"])

api_router.include_router(host_dashboard_routes.router,
prefix="/host-dashboard",
tags=["host-dashboard"])
8 changes: 6 additions & 2 deletions backend/startup_scripts/create_groups_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ def create_group(groups, group, user_pool_id):
create_user(cognito_client, user_pool_id, email, group)
print(email + '/Test123! created.')

sql = 'INSERT INTO public.user (email, "firstName", "lastName", "roleId") VALUES (%s, %s, %s, %s) ON CONFLICT(email) DO NOTHING'
create_table = 'CREATE TABLE IF NOT EXISTS public.user (id SERIAL NOT NULL, email varchar(256), "firstName" varchar(256), "lastName" varchar(256), "roleId" integer, PRIMARY KEY (id));'

sql = 'INSERT INTO public.user (email, "firstName", "lastName", "roleId") VALUES (%s, %s, %s, %s)'
url = urlparse(os.environ['DATABASE_URL'])
with psycopg2.connect(database=url.path[1:],
user=url.username,
password=url.password,
host=url.hostname,
port=url.port) as db_conn:
with db_conn.cursor() as cur:
cur.executemany(sql, rows)
cur.execute(create_table)
db_conn.commit()
cur.executemany(sql, rows)
db_conn.commit()
7 changes: 5 additions & 2 deletions backend/startup_scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ if [ -r .env ]; then
fi

# Alembic migration
alembic upgrade head
# alembic upgrade head

if [ "$1" == "prod" ]; then
fastapi run app/main.py --port 8000
else
env | grep COGNITO
# Setup moto server and export Cognito environment variables
python startup_scripts/setup_moto_server.py > envfile
cat envfile
source envfile
rm envfile

env | grep COGNITO
sleep 3
# Create test users in moto server and postgres
python startup_scripts/create_groups_users.py

Expand Down
58 changes: 29 additions & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,35 @@ services:
motoserver:
image: motoserver/moto:latest
ports:
- "5000:5000"
environment:
- MOTO_PORT=5000
backend:
build:
context: ./backend
ports:
- "8000:8000"
environment:
- COGNITO_CLIENT_ID=testing
- COGNITO_CLIENT_SECRET=testing
- COGNITO_REGION=us-east-1
- COGNITO_REDIRECT_URI=http://localhost:4040/signin
- COGNITO_USER_POOL_ID=testing
- COGNITO_ACCESS_ID=testing
- COGNITO_ACCESS_KEY=testing
- COGNITO_ENDPOINT_URL=http://motoserver:5000
- ROOT_URL=http://localhost:4040
- DATABASE_URL=postgresql+psycopg2://postgres:postgres@db:5432/huu
links:
- db
depends_on:
- pgadmin
- motoserver
frontend:
build:
context: ./frontend
ports:
- "4040:80"
- "6789:5000"
# environment:
# - MOTO_PORT=6789
# backend:
# build:
# context: ./backend
# ports:
# - "8080:8080"
# environment:
# - COGNITO_CLIENT_ID=testing
# - COGNITO_CLIENT_SECRET=testing
# - COGNITO_REGION=us-east-1
# - COGNITO_REDIRECT_URI=http://localhost:4041/signin
# - COGNITO_USER_POOL_ID=testing
# - COGNITO_ACCESS_ID=testing
# - COGNITO_ACCESS_KEY=testing
# - COGNITO_ENDPOINT_URL=http://motoserver:5000
# - ROOT_URL=http://localhost:4041
# - DATABASE_URL=postgresql+psycopg2://postgres:postgres@db:5432/huu
# links:
# - db
# depends_on:
# - pgadmin
# - motoserver
# frontend:
# build:
# context: ./frontend
# ports:
- "4041:80"
volumes:
db-data: {}
pgadmin-data: {}
Expand Down
2 changes: 1 addition & 1 deletion flask-api/.env.prod.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV='production'
COGNITO_CLIENT_ID=
COGNITO_CLIENT_SECRET=
COGNITO_REGION=
COGNITO_REDIRECT_URI=http://localhost:4040/signin
COGNITO_REDIRECT_URI=http://localhost:4041/signin
COGNITO_USER_POOL_ID=
SECRET_KEY=
COGNITO_ACCESS_ID=
Expand Down
2 changes: 1 addition & 1 deletion flask-api/.env.staging.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV='staging'
COGNITO_CLIENT_ID=
COGNITO_CLIENT_SECRET=
COGNITO_REGION=
COGNITO_REDIRECT_URI=http://localhost:4040/signin
COGNITO_REDIRECT_URI=http://localhost:4041/signin
COGNITO_USER_POOL_ID=
SECRET_KEY=
COGNITO_ACCESS_ID=
Expand Down
2 changes: 1 addition & 1 deletion flask-api/openapi_server/configs/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DevelopmentHUUConfig(HUUConfig):
HOST: str = "127.0.0.1"
TESTING: bool = False
SECRET_KEY: str = "unsecurekey"
ROOT_URL: str = "http://localhost:4040"
ROOT_URL: str = "http://localhost:4041"
DATABASE_URL: str = "sqlite:///./homeuniteus.db"

def post_validate(self):
Expand Down
3 changes: 0 additions & 3 deletions frontend/.env.example

This file was deleted.

10 changes: 5 additions & 5 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Named temprorary image to build client bundles
FROM node:lts-alpine as builder
ARG VITE_HUU_API_BASE_URL
FROM node:20-alpine as builder
ARG VITE_HUU_API_BASE_URL=http://localhost:8080/api/
ENV VITE_HUU_API_BASE_URL=${VITE_HUU_API_BASE_URL}

# do all copies/builds within a subdirectory
Expand All @@ -19,11 +19,12 @@ FROM cypress/base as development
WORKDIR /app
RUN apt-get update && apt-get install -y curl


# Copy built assets and all source files from builder
COPY --from=builder /app .
RUN npx cypress install
HEALTHCHECK --interval=5s --timeout=5s --retries=3 \
CMD curl --fail http://127.0.0.1:4040 || exit 1
CMD curl --fail http://127.0.0.1:4041 || exit 1
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["npx vite --host"]

Expand All @@ -41,5 +42,4 @@ RUN if [ -e "nginx.conf" ]; then \
# Default nginx runs on port 80, but we will
# publish to a different port at Docker
# runtime environment level
EXPOSE 80
ENTRYPOINT ["/bin/sh", "-c"]
EXPOSE 80
4 changes: 2 additions & 2 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The minimum node version enforced is currently 20+, which is the current LTS ver
4. Run the command `npm install` to download all dependencies from the local package.json
5. Create a local `.env` file and copy the contents from `.env.example`
6. Message a team member to obtain values for the .env file
7. From the `frontend/` directory run `npm run dev` to start a development server at `http://127.0.0.1:4040/`
7. From the `frontend/` directory run `npm run dev` to start a development server at `http://127.0.0.1:4041/`

The setup for the front end application is now complete and you should see the website running in your browser at the listed port.

Expand Down Expand Up @@ -64,7 +64,7 @@ The table below describes the environment variables that are used by this app:

| Variable | Required? | Example | Description |
| ----------------------- | --------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `VITE_HUU_API_BASE_URL` | YES | http://localhost:8080/api/ | The HUU API's base URL. In a development environment (mode is 'development' or 'test'): if this variable is not defined, then `http://localhost:4040/api/` will be used by default. In non-development environment: if this variable is not defined, then the build will throw an error. |
| `VITE_HUU_API_BASE_URL` | YES | http://localhost:8080/api/ | The HUU API's base URL. In a development environment (mode is 'development' or 'test'): if this variable is not defined, then `http://localhost:4041/api/` will be used by default. In non-development environment: if this variable is not defined, then the build will throw an error. |
| | | | |

## Production
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {defineConfig} from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:4040',
baseUrl: 'http://localhost:4041',
},
component: {
devServer: {
Expand Down
Loading
Loading