Skip to content

Commit 50a8bd3

Browse files
committed
Merge branch 'develop' into 441-embedding-models
2 parents 5ce7782 + 9fa287b commit 50a8bd3

43 files changed

Lines changed: 668 additions & 775 deletions

Some content is hidden

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

.github/workflows/containers-publish.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ jobs:
2626
- name: Compute Docker container image addresses
2727
run: |
2828
DOCKER_REPOSITORY="ghcr.io/${GITHUB_REPOSITORY,,}"
29+
git fetch --tags --force
2930
3031
if [[ "${{ github.event_name }}" == "release" ]]; then
31-
DOCKER_TAG="${GITHUB_REF:11}"
32+
TAG="${GITHUB_REF#refs/tags/}"
33+
DOCKER_TAG="${TAG#v}"
3234
else
33-
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
34-
DOCKER_TAG="dev-${SHORT_SHA}"
35+
# Pre-release for develop
36+
BASE_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
37+
VERSION="${BASE_TAG#v}"
38+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
39+
DOCKER_TAG="${VERSION}-dev.${TIMESTAMP}"
3540
fi
3641
3742
echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV
@@ -52,6 +57,7 @@ jobs:
5257
--file Dockerfile.prod \
5358
--tag "${DOCKER_REPOSITORY}/app:latest" \
5459
--tag "${DOCKER_REPOSITORY}/app:${DOCKER_TAG}" \
60+
--build-arg VERSION="${DOCKER_TAG}" \
5561
.
5662
5763
- name: "Push Docker container image app:latest"

.github/workflows/deploy-downstream.yml

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

.github/workflows/frontend-ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Frontend: Lint and Build"
2+
3+
on:
4+
push:
5+
branches: [develop]
6+
pull_request:
7+
branches: [develop]
8+
9+
jobs:
10+
frontend:
11+
name: Lint and Build
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: frontend
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "18"
23+
cache: "npm"
24+
cache-dependency-path: frontend/package-lock.json
25+
26+
- name: Install dependencies
27+
run: npm ci --legacy-peer-deps
28+
29+
- name: Lint
30+
run: npm run lint
31+
continue-on-error: true
32+
33+
- name: Build
34+
run: npm run build
35+
continue-on-error: true

CLAUDE.md

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ Each module contains:
147147
- Auth endpoints via Djoser: `/auth/`
148148
- JWT token lifetime: 60 minutes (access), 1 day (refresh)
149149

150+
#### API Documentation
151+
- Auto-generated using **drf-spectacular** (OpenAPI 3.0)
152+
- **Swagger UI**: `http://localhost:8000/api/docs/` — interactive API explorer
153+
- **ReDoc**: `http://localhost:8000/api/redoc/` — readable reference docs
154+
- **Raw schema**: `http://localhost:8000/api/schema/`
155+
- Configuration in `SPECTACULAR_SETTINGS` in `settings.py`
156+
- Views use `@extend_schema` decorators and `serializer_class` attributes for schema generation
157+
- JWT auth is configured in the schema — use `JWT <token>` (not `Bearer`) in Swagger UI's Authorize dialog
158+
- To document a new endpoint: add `serializer_class` to the view if it has one, or add `@extend_schema` with `inline_serializer` for views returning raw dicts
159+
150160
#### Key Data Models
151161
- **Medication** (`api.views.listMeds.models`) - Medication catalog with benefits/risks
152162
- **MedRule** (`api.models.model_medRule`) - Include/Exclude rules for medications based on patient history
@@ -278,28 +288,6 @@ docker compose exec backend python manage.py test
278288
### Frontend Tests
279289
No test framework currently configured. Consider adding Jest/Vitest for future testing.
280290

281-
## Deployment
282-
283-
### Local Kubernetes (using Devbox)
284-
```bash
285-
# Install Devbox first: https://www.jetify.com/devbox
286-
287-
# Add balancertestsite.com to /etc/hosts
288-
sudo sh -c 'echo "127.0.0.1 balancertestsite.com" >> /etc/hosts'
289-
290-
# Deploy to local k8s cluster
291-
devbox shell
292-
devbox create:cluster
293-
devbox run deploy:balancer
294-
295-
# Access at https://balancertestsite.com:30219/
296-
```
297-
298-
### Production
299-
- Manifests: `deploy/manifests/balancer/`
300-
- ConfigMap: `deploy/manifests/balancer/base/configmap.yml`
301-
- Secrets: `deploy/manifests/balancer/base/secret.template.yaml`
302-
303291
## Key Files Reference
304292

305293
- `server/balancer_backend/settings.py` - Django configuration (auth, database, CORS)

Dockerfile.prod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ RUN npm run build
2121
# Stage 2: Build Backend
2222
FROM python:3.11.4-slim-bullseye
2323

24+
# Receive version argument from build command
25+
ARG VERSION
26+
ENV VERSION=${VERSION}
27+
2428
# Set work directory
2529
WORKDIR /usr/src/app
2630

README.md

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ for patients with bipolar disorder, helping them shorten their journey to stabil
55

66
## Usage
77

8-
You can view the current build of the website here: [https://balancertestsite.com](https://balancertestsite.com/)
8+
You can view the current build of the website here: [https://balancerproject.org/](https://balancerproject.org/)
99

1010
## Contributing
1111

@@ -21,13 +21,17 @@ The project kanban board is [on GitHub here](https://github.com/orgs/CodeForPhil
2121

2222
The Code for Philly Code of Conduct is [here](https://codeforphilly.org/pages/code_of_conduct/)
2323

24-
### Setting up a development environment
24+
### Setting up a development environment
2525

2626
Get the code using git by either forking or cloning `CodeForPhilly/balancer-main`
2727

28-
Tools used to run Balancer:
29-
1. `OpenAI API`: Ask for an API key and add it to `config/env/env.dev`
30-
2. `Anthropic API`: Ask for an API key and add it to `config/env/env.dev`
28+
1. Copy the example environment file:
29+
```bash
30+
cp config/env/dev.env.example config/env/dev.env
31+
```
32+
2. (Optional) Add your API keys to `config/env/dev.env`:
33+
- `OpenAI API`
34+
- `Anthropic API`
3135

3236
Tools used for development:
3337
1. `Docker`: Install Docker Desktop
@@ -49,7 +53,7 @@ The application supports connecting to PostgreSQL databases via:
4953
See [Database Connection Documentation](./docs/DATABASE_CONNECTION.md) for detailed configuration.
5054

5155
**Local Development:**
52-
- Download a sample of papers to upload from [https://balancertestsite.com](https://balancertestsite.com/)
56+
- Download a sample of papers to upload from [https://balancerproject.org/](https://balancerproject.org/)
5357
- The email and password of `pgAdmin` are specified in `balancer-main/docker-compose.yml`
5458
- The first time you use `pgAdmin` after building the Docker containers you will need to register the server.
5559
- The `Host name/address` is the Postgres server service name in the Docker Compose file
@@ -75,39 +79,22 @@ df = pd.read_sql(query, engine)
7579
docker compose exec backend pytest api/ -v
7680
```
7781

78-
## Local Kubernetes Deployment
82+
## API Documentation
7983

80-
### Prereqs
84+
Interactive API docs are auto-generated using [drf-spectacular](https://drf-spectacular.readthedocs.io/) and available at:
8185

82-
- Fill the configmap with the [env vars](./deploy/manifests/balancer/base/configmap.yml)
83-
- Install [Devbox](https://www.jetify.com/devbox)
84-
- Run the following script with admin privileges:
86+
- **Swagger UI**: [http://localhost:8000/api/docs/](http://localhost:8000/api/docs/) — interactive explorer with "Try it out" functionality
87+
- **ReDoc**: [http://localhost:8000/api/redoc/](http://localhost:8000/api/redoc/) — clean, readable reference docs
88+
- **Raw schema**: [http://localhost:8000/api/schema/](http://localhost:8000/api/schema/) — OpenAPI 3.0 JSON/YAML
8589

86-
```bash
87-
HOSTNAME="balancertestsite.com"
88-
LOCAL_IP="127.0.0.1"
90+
### Testing authenticated endpoints
8991

90-
# Check if the correct line already exists
91-
if grep -q "^$LOCAL_IP[[:space:]]\+$HOSTNAME" /etc/hosts; then
92-
echo "Entry for $HOSTNAME with IP $LOCAL_IP already exists in /etc/hosts"
93-
else
94-
echo "Updating /etc/hosts for $HOSTNAME"
95-
sudo sed -i "/[[:space:]]$HOSTNAME/d" /etc/hosts
96-
echo "$LOCAL_IP $HOSTNAME" | sudo tee -a /etc/hosts
97-
fi
98-
```
99-
100-
### Steps to reproduce
101-
102-
Inside root dir of balancer
103-
104-
```bash
105-
devbox shell
106-
devbox create:cluster
107-
devbox run deploy:balancer
108-
```
92+
Most endpoints require JWT authentication. To test them in Swagger UI:
10993

110-
The website should be available in [https://balancertestsite.com:30219/](https://balancertestsite.com:30219/)
94+
1. **Get a token**: Find the `POST /auth/jwt/create/` endpoint in Swagger UI, click **Try it out**, enter an authorized `email` and `password`, and click **Execute**. Copy the `access` token from the response.
95+
2. **Authorize**: Click the **Authorize** button (lock icon) at the top of the page. Enter `JWT <your-access-token>` in the value field. The prefix must be `JWT`, not `Bearer`.
96+
3. **Test endpoints**: All subsequent requests will include your token. Use **Try it out** on any protected endpoint.
97+
4. **Token refresh**: Access tokens expire after 60 minutes. Use `POST /auth/jwt/refresh/` with your `refresh` token, or repeat step 1.
11198

11299
## Architecture
113100

db/Dockerfile

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

0 commit comments

Comments
 (0)