Skip to content
Draft
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
6 changes: 3 additions & 3 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ jobs:

services:
redis:
image: redis:6.2.3-alpine
image: redis:7.2.15-alpine
ports: ["6379:6379"]
options: --entrypoint redis-server

db:
image: postgres:12.8-alpine
image: postgres:17.10-alpine
env:
POSTGRES_PASSWORD: password
ports:
Expand All @@ -125,7 +125,7 @@ jobs:
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: 4.4.9
mongodb-version: 8.0.28

- name: Load database schema
run: |
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.3
3.4.10
8 changes: 4 additions & 4 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nodejs 12.22.6
ruby 3.2.3
postgres 12.8
mongodb 4.4.9
redis 6.2.3
ruby 3.4.10
postgres 17.10
mongodb 8.0.28
redis 7.2.15
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

Flaredown is a chronic-illness symptom tracker. It is a monorepo with three deployable apps:

- `backend/` — Rails 7.1 API (Ruby 3.2.3), the only backend for all clients.
- `backend/` — Rails 8.1 API (Ruby 3.4.10), the only backend for all clients.
- `frontend/` — Ember.js 2.18 web app (the production web client at app.flaredown.com), proxies API calls to the backend.
- `native/` — Expo / React Native + TypeScript app (newer, in-progress replacement for the Ember client).

Expand Down Expand Up @@ -44,7 +44,7 @@ CI (`.github/workflows/{backend,frontend,native}.yml`) uses path filters — bac
The backend uses **both PostgreSQL and MongoDB simultaneously**, split by data type:

- **PostgreSQL (ActiveRecord)** — relational/reference data: `User` (Devise auth), `Condition`, `Symptom`, `Treatment`, `Food`, `Tag`, `Profile`, `Weather`, and the `user_*` join tables. These models subclass `ActiveRecord::Base` and carry a `# == Schema Information` header. Schema lives in `db/schema.rb` + `db/structure.sql`; migrations in `db/migrate/`.
- **MongoDB (Mongoid 8)** — high-volume, user-generated, schemaless data: `Checkin` (the core daily symptom/treatment/tag log), `Comment`, `Reaction`, `Pattern`, `Notification`, `HarveyBradshawIndex`, `Feedback`, `PromotionRate`, `OracleRequest`. These `include Mongoid::Document`. Config in `config/mongoid.yml`.
- **MongoDB (Mongoid 9)** — high-volume, user-generated, schemaless data: `Checkin` (the core daily symptom/treatment/tag log), `Comment`, `Reaction`, `Pattern`, `Notification`, `HarveyBradshawIndex`, `Feedback`, `PromotionRate`, `OracleRequest`. These `include Mongoid::Document`. Config in `config/mongoid.yml`.

The two stores are linked by an **encrypted foreign key**: Mongo documents store `encrypted_user_id` (symmetric-encryption gem, see `config/symmetric-encryption.yml`) rather than a plain `user_id`, and dereference it back to the Postgres `User`. When querying check-in data by user, filter on `encrypted_user_id`, not `user_id`. `Checkin` embeds condition/symptom/treatment sub-documents inline.

Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Help would be appreciated! Please join us in [slack #flaredown](https://join.sla

## Environment

* PostgreSQL 12.8
* MongoDB 4.4.9
* Redis 6.2.3
* Ruby 3.2.3
* PostgreSQL 17.10
* MongoDB 8.0.28
* Redis 7.2.15
* Ruby 3.4.10
* Node 12.22.6

## Installation
Expand Down Expand Up @@ -53,6 +53,13 @@ Visit your app at [http://localhost:4300](http://localhost:4300).

Frontend dependency changes are handled automatically by Docker. For a full reset of all local Docker data, including databases and dependency volumes, run `docker compose down -v`, then run the database setup command again afterward.

If you already had the stack running before the PostgreSQL 17 and MongoDB 8 upgrade, you have to do that reset once. Neither database will start against a data directory written by an older major version, so `docker compose --profile dev up` fails until the old volumes are gone. The local data is disposable:

```bash
docker compose down -v
docker compose --profile tools run --rm app-setup
```

### Running natively

#### Mac Prerequisites
Expand All @@ -78,7 +85,6 @@ On macOS, you can install `libpq` by running `brew install libpq && brew link --
```bash
cd backend
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
bundle config set --local without 'production'
bundle config set --local jobs 5
bundle config set --local retry 10
bundle install
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.2.3
FROM ruby:3.4.10

# set working directory
WORKDIR /app
Expand Down
37 changes: 22 additions & 15 deletions backend/Gemfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
source "https://rubygems.org"

ruby "3.2.3"
ruby "3.4.10"

# Configuration management. keep on top of Gemfile
gem "dotenv-rails", groups: %i[development test]

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem "rails", "~> 7.1.0"
gem "rails", "~> 8.1.0"
gem "rake"
gem "sprockets-rails"

# JSON serializer
gem "active_model_serializers", "~> 0.9"
# JSON serializer. Pinned to the 0.9 series on purpose: `~> 0.9` would allow
# 0.10, which is a rewrite with a different JSON format that the Ember client
# (ActiveModelAdapter + EmbeddedRecordsMixin) cannot consume.
gem "active_model_serializers", "~> 0.9.8"

# Use postgresql and mongo as the database for Active Record
gem "mongoid", "8.1.3" # https://www.mongodb.com/docs/mongoid/current/reference/compatibility/#rails-compatibility
gem "mongoid", "9.1.0" # https://www.mongodb.com/docs/mongoid/current/reference/compatibility/#rails-compatibility
gem "pg"

# Use Puma as the app server
gem "puma", "5.6.8"
gem "puma", "8.0.2"

# Authentication libraries
gem "cancancan", "~> 3.6.1"
gem "cancancan-mongoid", "~> 2.0"
gem "devise", "~> 4.8"
gem "devise", "~> 5.0"
gem "devise_invitable", "~> 2.0"
gem "omniauth", "~> 1.8"
gem "omniauth-facebook", "~> 3.0"
gem "omniauth", "~> 2.1"
gem "omniauth-facebook", "~> 11.0"

# Colored output to console
gem "colored"

# Background jobs
gem "sidekiq", "~> 7.3"
gem "sidekiq", "~> 8.1"

# Both stopped being Ruby default gems in 3.4, so they have to be asked for.
# csv is used by DataExportJob and the trackings export task; mutex_m is required
# by httpclient, which pusher depends on. Until now each resolved by accident —
# csv as another gem's dependency, mutex_m as one of Rails 7.1's.
gem "csv"
gem "mutex_m"

# Structured seed data
gem "seedbank"
Expand Down Expand Up @@ -82,7 +91,9 @@ group :development, :test do
end

group :development do
gem "annotate"
# Successor to `annotate`, which was last released in 2022 and requires
# activerecord < 8.0.
gem "annotaterb"
gem "awesome_print"
gem "better_errors"
gem "brakeman"
Expand All @@ -99,10 +110,6 @@ group :test do
gem "webmock"
end

group :production do
gem "rails_12factor"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]

Expand Down
Loading
Loading