Skip to content

Commit a865444

Browse files
authored
Merge develop into main (release v1.1.6)
Release: v1.1.6
2 parents c4f28bf + 1b93133 commit a865444

70 files changed

Lines changed: 2974 additions & 806 deletions

Some content is hidden

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

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# These are supported funding model platforms
22

3-
github: [sahilds1] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
44
patreon: # Replace with a single Patreon username
55
open_collective: # Replace with a single Open Collective username
66
ko_fi: # Replace with a single Ko-fi username

.github/ISSUE_TEMPLATE/architectural-issue.md

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

.github/ISSUE_TEMPLATE/issue.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Issue template
3+
about: Help push the project forward
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
## Title
11+
<!-- Title: [Type]: Short description of the problem or goal -->
12+
13+
## Background
14+
<!-- Why does this change need to happen? -->
15+
16+
## Existing Behavior
17+
<!-- What code or docs are changing? Link or paste as needed -->
18+
19+
## Acceptance Criteria
20+
- [] <!-- What does done look like? -->
21+
22+
## Approach
23+
<!-- How are you tackling this? Update as you go -->
24+
25+
## References
26+
<!-- Anything useful — docs, links, decisions -->
27+
28+
## Risks and Rollback
29+
<!-- Anything that could go wrong, or leave blank if low risk -->
30+
31+
## Screenshots / Recordings
32+
<!-- Before/after visuals or console output if helpful -->

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
config/env/*
22
!config/env/*.example
3-
.idea/
3+
.idea/
4+
.DS_Store

CLAUDE.md

Lines changed: 10 additions & 0 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

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ 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/)
9+
10+
You can view the website in a sandbox here: [https://sandbox.balancerproject.org/](https://sandbox.balancerproject.org/)
911

1012
## Contributing
1113

@@ -31,11 +33,9 @@ Get the code using git by either forking or cloning `CodeForPhilly/balancer-main
3133
```
3234
2. (Optional) Add your API keys to `config/env/dev.env`:
3335
- `OpenAI API`
34-
- `Anthropic API`
3536

3637
Tools used for development:
3738
1. `Docker`: Install Docker Desktop
38-
2. `Postman`: Ask to get invited to the Balancer Postman team `balancer_dev`
3939
3. `npm`: In the terminal run 1) 'cd frontend' 2) 'npm install' 3) 'cd ..'
4040

4141
### Running Balancer for development
@@ -53,7 +53,7 @@ The application supports connecting to PostgreSQL databases via:
5353
See [Database Connection Documentation](./docs/DATABASE_CONNECTION.md) for detailed configuration.
5454

5555
**Local Development:**
56-
- 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/)
5757
- The email and password of `pgAdmin` are specified in `balancer-main/docker-compose.yml`
5858
- The first time you use `pgAdmin` after building the Docker containers you will need to register the server.
5959
- The `Host name/address` is the Postgres server service name in the Docker Compose file
@@ -73,6 +73,36 @@ df = pd.read_sql(query, engine)
7373

7474
#### Django REST
7575
- The email and password are set in `server/api/management/commands/createsu.py`
76+
- Backend tests can be run using `pytest` by running the below command inside the running backend container:
77+
78+
```
79+
docker compose exec backend pytest api/ -v
80+
```
81+
82+
## API Documentation
83+
84+
Interactive API docs are auto-generated using [drf-spectacular](https://drf-spectacular.readthedocs.io/) and available at:
85+
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
89+
90+
### Testing authenticated endpoints
91+
92+
Most endpoints require JWT authentication. To test them in Swagger UI:
93+
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.
98+
99+
### Deployment
100+
101+
1. Merging your PR into develop automatically triggers a GitHub Release
102+
2. The release triggers a container build workflow that builds and pushes the Docker image
103+
3. [Go to GitHub Packages](https://github.com/CodeForPhilly/balancer-main/pkgs/container/balancer-main%2Fapp) to find the new image tag
104+
4. Update newTag in kustomization.yaml [in the cluster repo](https://github.com/CodeForPhilly/cfp-live-cluster/blob/main/balancer/kustomization.yaml)
105+
5. Open a PR to [cfp-sandbox-cluster](https://github.com/CodeForPhilly/cfp-sandbox-cluster) (or [cfp-live-cluster](https://github.com/CodeForPhilly/cfp-live-cluster))
76106

77107
## Architecture
78108

config/env/dev.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ SQL_PORT=5432
3131
# SQL_SSL_MODE=require
3232

3333
LOGIN_REDIRECT_URL=
34+
CORS_ALLOWED_ORIGINS=http://localhost:3000
35+
# Domain used by Djoser for activation and password reset email links (should be the frontend URL)
36+
FRONTEND_DOMAIN=localhost:3000
3437
OPENAI_API_KEY=
3538
ANTHROPIC_API_KEY=
3639
PINECONE_API_KEY=

deploy/manifests/balancer/base/balancer.env

Whitespace-only changes.

deploy/manifests/balancer/base/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ spec:
2121
envFrom:
2222
- secretRef:
2323
name: balancer-config
24+
- configMapRef:
25+
name: balancer-config
2426
ports:
2527
- containerPort: 8000
2628
readinessProbe:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: ListenerSet
3+
metadata:
4+
name: balancer-listeners
5+
annotations:
6+
cert-manager.io/cluster-issuer: letsencrypt-prod-gateway
7+
hostname: HOSTNAME_PLACEHOLDER
8+
spec:
9+
parentRef:
10+
name: main-gateway
11+
namespace: envoy-gateway-system
12+
group: gateway.networking.k8s.io
13+
kind: Gateway
14+
listeners:
15+
- name: http
16+
protocol: HTTP
17+
port: 80
18+
hostname: HOSTNAME_PLACEHOLDER
19+
- name: https
20+
protocol: HTTPS
21+
port: 443
22+
hostname: HOSTNAME_PLACEHOLDER
23+
tls:
24+
mode: Terminate
25+
certificateRefs:
26+
- name: balancer-tls
27+
kind: Secret

0 commit comments

Comments
 (0)