Auspicious14 commited on
Commit
d171100
Β·
1 Parent(s): 08543d0

Fix: move prisma migration to runtime

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -0
  2. README.md +166 -18
  3. package.json +2 -2
Dockerfile CHANGED
@@ -29,6 +29,7 @@ COPY --from=builder --chown=node:node /app/package*.json ./
29
  COPY --from=builder --chown=node:node /app/node_modules ./node_modules
30
  COPY --from=builder --chown=node:node /app/dist ./dist
31
  COPY --from=builder --chown=node:node /app/prisma ./prisma
 
32
 
33
  # Set production environment
34
  ENV NODE_ENV=production
 
29
  COPY --from=builder --chown=node:node /app/node_modules ./node_modules
30
  COPY --from=builder --chown=node:node /app/dist ./dist
31
  COPY --from=builder --chown=node:node /app/prisma ./prisma
32
+ COPY --from=builder --chown=node:node /app/prisma.config.ts ./prisma.config.ts
33
 
34
  # Set production environment
35
  ENV NODE_ENV=production
README.md CHANGED
@@ -1,21 +1,169 @@
1
- ---
2
- title: MaternAlert Backend
3
- emoji: πŸ₯
4
- colorFrom: green
5
- colorTo: blue
6
- sdk: docker
7
- app_port: 7860
8
- pinned: false
9
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- # MaternAlert Backend
12
 
13
- This is the persistent backend for the MaternAlert clinical support tool.
14
- It handles:
15
- - πŸ•’ **Scheduled Tasks**: Daily BP reminders and 5-day inactivity checks.
16
- - πŸ“ˆ **Trend Analysis**: 7-day clinical pattern detection.
17
- - πŸ”” **Notifications**: Push alerts via Expo and high-trust HTML emails.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- ## Monitoring
20
- - **Health Check**: `https://huggingface.co/spaces/Auspicious14/MaternAlert/api/v1/health`
21
- - **Logs**: View the "Logs" tab in this Space to see cron job execution.
 
1
+ # Maternal Health Support Backend
2
+
3
+ ⚠️ **CLINICAL SAFETY NOTICE**
4
+
5
+ This application is a **CARE-SUPPORT and ESCALATION TOOL**.
6
+
7
+ - ❌ This is **NOT** a diagnostic system
8
+ - ❌ This is **NOT** a medical device
9
+ - βœ… This **IS** a care-support and escalation tool for early warning awareness
10
+
11
+ ## Purpose
12
+
13
+ This backend supports a maternal health application focused on:
14
+ - Early warning awareness for high blood pressure disorders in pregnancy
15
+ - Care escalation based on objective measurements
16
+ - Educational content delivery
17
+ - Connection to healthcare providers
18
+
19
+ ## Non-Diagnostic Design Principles
20
+
21
+ This system is built with strict clinical safety constraints:
22
+
23
+ 1. **No Diagnosis**: The system never diagnoses conditions
24
+ 2. **No Medical Advice**: No treatment recommendations or medical guidance
25
+ 3. **No Risk Scoring**: No probability calculations or risk percentages
26
+ 4. **Data Minimization**: Only essential data is collected
27
+ 5. **Escalation Bias**: When uncertain, always escalate to higher priority
28
+ 6. **Template-Only Messaging**: No dynamic medical text generation
29
+
30
+ ## Architecture
31
+
32
+ ### Modular Domain-Driven Design
33
+
34
+ ```
35
+ src/
36
+ β”œβ”€β”€ auth/ # Authentication (minimal PII)
37
+ β”œβ”€β”€ user-profile/ # User profile (data minimization)
38
+ β”œβ”€β”€ blood-pressure/ # BP readings (neutral storage)
39
+ β”œβ”€β”€ symptoms/ # Symptom tracking (atomic, non-scored)
40
+ β”œβ”€β”€ care-priority/ # Care priority engine (rule-based)
41
+ β”œβ”€β”€ notifications/ # Alerts (template-only)
42
+ └── education/ # Educational content
43
+ ```
44
+
45
+ ### Technology Stack
46
+
47
+ - **Framework**: NestJS with TypeScript (strict mode)
48
+ - **Database**: PostgreSQL (to be configured in STEP 2)
49
+ - **Authentication**: JWT-based
50
+ - **Validation**: class-validator with strict settings
51
+
52
+ ## Getting Started
53
+
54
+ ### Prerequisites
55
+
56
+ - Node.js 18+
57
+ - PostgreSQL 14+
58
+ - npm or yarn
59
+
60
+ ### Installation
61
+
62
+ ```bash
63
+ # Install dependencies
64
+ npm install
65
+
66
+ # Copy environment template
67
+ cp .env.example .env
68
+
69
+ # Edit .env with your configuration
70
+ # (Database credentials, JWT secrets, etc.)
71
+ ```
72
+
73
+ ### Development
74
+
75
+ ```bash
76
+ # Start in development mode with hot reload
77
+ npm run start:dev
78
+
79
+ # Build for production
80
+ npm run build
81
+
82
+ # Start production server
83
+ npm run start:prod
84
+ ```
85
 
86
+ ### Testing
87
 
88
+ ```bash
89
+ # Run unit tests
90
+ npm test
91
+
92
+ # Run tests in watch mode
93
+ npm test:watch
94
+
95
+ # Generate coverage report
96
+ npm test:cov
97
+ ```
98
+
99
+ ## Deployment
100
+
101
+ For persistent background tasks and cron jobs, the backend is optimized for deployment on **Hugging Face Spaces** using Docker.
102
+
103
+ - [Deployment Guide](./DEPLOYMENT.md)
104
+ - [Health Check API](http://localhost:3000/api/v1/health) (when running locally)
105
+
106
+ ## Implementation Status
107
+
108
+ This project follows a 12-step implementation process:
109
+
110
+ ### Phase 1: Foundation
111
+ - [x] **STEP 1**: Project Bootstrap & Architecture βœ…
112
+ - [ ] **STEP 2**: Database & ORM Setup
113
+ - [ ] **STEP 3**: Authentication Module
114
+
115
+ ### Phase 2: Core Data Modules
116
+ - [ ] **STEP 4**: User Profile Module (Data Minimization)
117
+ - [ ] **STEP 5**: Blood Pressure Module (Neutral Handling)
118
+ - [ ] **STEP 6**: Symptom Module (Atomic, Non-Scored)
119
+
120
+ ### Phase 3: Care Logic & Safety
121
+ - [ ] **STEP 7**: Care Priority Engine (Most Critical)
122
+ - [ ] **STEP 8**: Care Priority API Endpoint
123
+ - [ ] **STEP 9**: Notifications & Alerts
124
+
125
+ ### Phase 4: Support & Security
126
+ - [ ] **STEP 10**: Education Content Module
127
+ - [ ] **STEP 11**: Security, Logging & Rate Limiting
128
+ - [ ] **STEP 12**: Final Safety Audit
129
+
130
+ ## API Documentation
131
+
132
+ Once running, API documentation will be available at:
133
+ - Development: `http://localhost:3000/api/v1`
134
+ - Swagger docs: (to be added in later steps)
135
+
136
+ ## Clinical Safety Commitments
137
+
138
+ Every module in this system adheres to:
139
+
140
+ 1. **Deterministic Logic**: No AI/ML for medical decisions
141
+ 2. **Transparent Rules**: All escalation rules are documented
142
+ 3. **Conservative Defaults**: Favor care-seeking when uncertain
143
+ 4. **Audit Trail**: All decisions are logged (without PII)
144
+ 5. **No Diagnostic Language**: Careful wording throughout
145
+
146
+ ## Regulatory Considerations
147
+
148
+ This system is designed for:
149
+ - NGO deployments
150
+ - Public health pilots
151
+ - Clinical partnerships
152
+ - Research studies
153
+
154
+ **Not intended for**:
155
+ - Direct-to-consumer medical diagnosis
156
+ - Replacement of clinical judgment
157
+ - Unsupervised medical decision-making
158
+
159
+ ## License
160
+
161
+ ISC
162
+
163
+ ## Support
164
+
165
+ For questions about clinical safety design or implementation, please review the inline documentation in each module.
166
+
167
+ ---
168
 
169
+ **Remember**: This is a care-support tool. Always encourage users to seek professional medical advice.
 
 
package.json CHANGED
@@ -4,13 +4,13 @@
4
  "description": "Clinical-safe maternal health support backend - Care escalation tool (NOT a diagnostic system)",
5
  "main": "dist/main.js",
6
  "scripts": {
7
- "build": "prisma generate && prisma migrate deploy && nest build",
8
  "postinstall": "prisma generate",
9
  "format": "prettier --write \"src/**/*.ts\"",
10
  "start": "nest start",
11
  "start:dev": "nest start --watch",
12
  "start:debug": "nest start --debug --watch",
13
- "start:prod": "node dist/main",
14
  "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
15
  "test": "jest",
16
  "test:watch": "jest --watch",
 
4
  "description": "Clinical-safe maternal health support backend - Care escalation tool (NOT a diagnostic system)",
5
  "main": "dist/main.js",
6
  "scripts": {
7
+ "build": "prisma generate && nest build",
8
  "postinstall": "prisma generate",
9
  "format": "prettier --write \"src/**/*.ts\"",
10
  "start": "nest start",
11
  "start:dev": "nest start --watch",
12
  "start:debug": "nest start --debug --watch",
13
+ "start:prod": "prisma migrate deploy && node dist/main",
14
  "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
15
  "test": "jest",
16
  "test:watch": "jest --watch",