diff --git a/backend/Dockerfile b/backend/Dockerfile
index ae14362..9d01efa 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -1,7 +1,7 @@
# Backend build
FROM node:25-slim AS builder
WORKDIR /app
-COPY package.json tsconfig.json drizzle.config.ts ./
+COPY package.json tsconfig.json ./
COPY src ./src
RUN npm install
RUN npm run build
diff --git a/backend/drizzle.config.ts b/backend/drizzle.config.ts
deleted file mode 100644
index 67e8cf7..0000000
--- a/backend/drizzle.config.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { defineConfig } from "drizzle-kit";
-
-const dbUrl = process.env.DATABASE_URL || "file:./data/medassist.db";
-
-export default defineConfig({
- dialect: "libsql",
- schema: "./src/db/schema.ts",
- out: "./drizzle",
- dbCredentials: {
- url: dbUrl,
- },
-});
diff --git a/backend/src/db/migrations/.gitkeep b/backend/src/db/migrations/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/backend/src/db/migrations/0000_init.sql b/backend/src/db/migrations/0000_init.sql
deleted file mode 100644
index 3795932..0000000
--- a/backend/src/db/migrations/0000_init.sql
+++ /dev/null
@@ -1,50 +0,0 @@
-CREATE TABLE IF NOT EXISTS users (
- id integer PRIMARY KEY AUTOINCREMENT,
- email text NOT NULL UNIQUE,
- password_hash text NOT NULL,
- role text NOT NULL DEFAULT 'user',
- created_at integer NOT NULL DEFAULT (strftime('%s','now')),
- updated_at integer NOT NULL DEFAULT (strftime('%s','now'))
-);
-
-CREATE TABLE IF NOT EXISTS medications (
- id integer PRIMARY KEY AUTOINCREMENT,
- name text NOT NULL UNIQUE,
- count integer NOT NULL DEFAULT 0,
- strips integer NOT NULL DEFAULT 0,
- pack_count integer NOT NULL DEFAULT 1,
- strips_per_pack integer NOT NULL DEFAULT 1,
- tabs_per_strip integer NOT NULL DEFAULT 1,
- loose_tablets integer NOT NULL DEFAULT 0,
- usage_json text NOT NULL DEFAULT '[]',
- every_json text NOT NULL DEFAULT '[]',
- start_json text NOT NULL DEFAULT '[]',
- strip_size integer NOT NULL DEFAULT 1,
- updated_at integer NOT NULL DEFAULT (strftime('%s','now'))
-);
-
-CREATE TABLE IF NOT EXISTS refresh_tokens (
- id integer PRIMARY KEY AUTOINCREMENT,
- user_id integer NOT NULL,
- token_id text NOT NULL UNIQUE,
- expires_at integer NOT NULL,
- rotated_at integer,
- revoked integer NOT NULL DEFAULT 0,
- created_at integer NOT NULL DEFAULT (strftime('%s','now')),
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
-);
-
-CREATE TABLE IF NOT EXISTS settings (
- id integer PRIMARY KEY AUTOINCREMENT,
- smtp_host text,
- smtp_port integer,
- smtp_user text,
- smtp_pass_encrypted text,
- smtp_from text,
- smtp_secure integer NOT NULL DEFAULT 0,
- emails_per_day integer NOT NULL DEFAULT 3,
- email_enabled integer NOT NULL DEFAULT 0,
- notification_email text,
- reminder_days_before integer NOT NULL DEFAULT 7,
- updated_at integer NOT NULL DEFAULT (strftime('%s','now'))
-);
diff --git a/backend/src/db/migrations/meta/_journal.json b/backend/src/db/migrations/meta/_journal.json
deleted file mode 100644
index c32c90d..0000000
--- a/backend/src/db/migrations/meta/_journal.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "entries": [
- { "idx": 0, "version": 1, "when": 1734633120, "tag": "0000_init", "breakpoint": false }
- ]
-}
diff --git a/backend/src/index.ts b/backend/src/index.ts
index aeeb97c..ecbdbed 100644
--- a/backend/src/index.ts
+++ b/backend/src/index.ts
@@ -11,6 +11,7 @@ import { authRoutes } from "./routes/auth.js";
import { medicationRoutes } from "./routes/medications.js";
import { settingsRoutes } from "./routes/settings.js";
import { plannerRoutes } from "./routes/planner.js";
+import { startReminderScheduler } from "./services/reminder-scheduler.js";
const app = Fastify({
logger: {
@@ -65,6 +66,12 @@ const start = async () => {
try {
await app.listen({ port: env.PORT, host: "0.0.0.0" });
app.log.info(`Server running on ${env.PORT}`);
+
+ // Start the automatic reminder scheduler
+ startReminderScheduler({
+ info: (msg) => app.log.info(msg),
+ error: (msg) => app.log.error(msg),
+ });
} catch (err) {
app.log.error(err);
process.exit(1);
diff --git a/backend/src/routes/planner.ts b/backend/src/routes/planner.ts
index 9e75b93..d5e0e0a 100644
--- a/backend/src/routes/planner.ts
+++ b/backend/src/routes/planner.ts
@@ -1,5 +1,6 @@
import { FastifyInstance } from "fastify";
import nodemailer from "nodemailer";
+import { updateReminderSentTime } from "../services/reminder-scheduler.js";
type PlannerRow = {
medicationId: number;
@@ -61,22 +62,22 @@ export async function plannerRoutes(app: FastifyInstance) {
day: "numeric",
});
- // Build HTML table
+ // Build HTML table with horizontal scroll for mobile
const tableRows = rows
.map(
(row) => `
-
${row.medicationName}
-
${row.plannerUsage} pills
-
${row.stripsNeeded} × ${row.stripSize}
-
${row.stripsAvailable} blisters
-
- ${row.medicationName}
+
${row.plannerUsage} pills
+
${row.stripsNeeded} × ${row.stripSize}
+
${row.stripsAvailable}
+
+
- ${row.enough ? "✓ Enough" : "⚠ Out of Stock"}
+ ${row.enough ? "✓ OK" : "⚠ Low"}
@@ -91,38 +92,40 @@ export async function plannerRoutes(app: FastifyInstance) {
: "✓ All medications have sufficient supply for this period.";
const html = `
-