mindmingle-backend 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/exercise.json ADDED
@@ -0,0 +1,363 @@
1
+ {
2
+ "exercise": [
3
+ {
4
+ "title": "Deep Breathing",
5
+ "shortDescription": "A simple breath-focused exercise to calm the mind.",
6
+ "category": "breathing",
7
+ "steps": [
8
+ "Sit comfortably with your back relaxed.",
9
+ "Slowly inhale through your nose for 4 seconds.",
10
+ "Pause and hold your breath gently for 2 seconds.",
11
+ "Exhale slowly through your mouth for 6 seconds.",
12
+ "Repeat at a relaxed pace.",
13
+ "If thoughts arise, gently return to your breath."
14
+ ],
15
+ "durationMinutes": 5,
16
+ "difficulty": "beginner",
17
+ "audioUrl": null,
18
+ "isActive": true
19
+ },
20
+ {
21
+ "title": "Box Breathing",
22
+ "shortDescription": "A structured breathing pattern to restore calm and focus.",
23
+ "category": "breathing",
24
+ "steps": [
25
+ "Inhale slowly through your nose for 4 seconds.",
26
+ "Hold your breath for 4 seconds.",
27
+ "Exhale gently through your mouth for 4 seconds.",
28
+ "Hold again for 4 seconds.",
29
+ "Repeat like tracing the four sides of a box."
30
+ ],
31
+ "durationMinutes": 4,
32
+ "difficulty": "beginner",
33
+ "audioUrl": null,
34
+ "isActive": true
35
+ },
36
+ {
37
+ "title": "4-7-8 Relaxation Breathing",
38
+ "shortDescription": "A calming breathing rhythm to relax your body.",
39
+ "category": "breathing",
40
+ "steps": [
41
+ "Sit or lie down comfortably.",
42
+ "Inhale quietly through your nose for 4 seconds.",
43
+ "Hold your breath for 7 seconds.",
44
+ "Exhale slowly through your mouth for 8 seconds.",
45
+ "Repeat gently without straining."
46
+ ],
47
+ "durationMinutes": 5,
48
+ "difficulty": "intermediate",
49
+ "audioUrl": null,
50
+ "isActive": true
51
+ },
52
+ {
53
+ "title": "Counting Your Breath",
54
+ "shortDescription": "Stay present by gently counting each breath.",
55
+ "category": "breathing",
56
+ "steps": [
57
+ "Inhale slowly and mentally count 'one'.",
58
+ "Exhale slowly and mentally count 'two'.",
59
+ "Continue up to ten breaths.",
60
+ "If your mind wanders, gently restart from one.",
61
+ "There is no right or wrong — just awareness."
62
+ ],
63
+ "durationMinutes": 6,
64
+ "difficulty": "beginner",
65
+ "audioUrl": null,
66
+ "isActive": true
67
+ },
68
+ {
69
+ "title": "Alternate Nostril Breathing",
70
+ "shortDescription": "A balancing breath technique to steady the mind.",
71
+ "category": "breathing",
72
+ "steps": [
73
+ "Sit comfortably with relaxed shoulders.",
74
+ "Close your right nostril with your thumb and inhale slowly through the left nostril.",
75
+ "Close your left nostril and exhale through the right.",
76
+ "Inhale through the right.",
77
+ "Close the right nostril and exhale through the left.",
78
+ "Repeat calmly and evenly."
79
+ ],
80
+ "durationMinutes": 7,
81
+ "difficulty": "intermediate",
82
+ "audioUrl": null,
83
+ "isActive": true
84
+ },
85
+ {
86
+ "title": "Basic Mindfulness Meditation",
87
+ "shortDescription": "A simple meditation for beginners to observe thoughts and sensations.",
88
+ "category": "meditation",
89
+ "steps": [
90
+ "Sit comfortably and close your eyes if you wish.",
91
+ "Bring your attention to your natural breathing.",
92
+ "Notice sensations without changing anything.",
93
+ "If thoughts arise, acknowledge them gently.",
94
+ "Guide your attention back to the breath.",
95
+ "Continue with patience and kindness."
96
+ ],
97
+ "durationMinutes": 10,
98
+ "difficulty": "beginner",
99
+ "audioUrl": null,
100
+ "isActive": true
101
+ },
102
+ {
103
+ "title": "Loving-Kindness Meditation",
104
+ "shortDescription": "Cultivate warmth and compassion toward yourself and others.",
105
+ "category": "meditation",
106
+ "steps": [
107
+ "Sit comfortably and relax your body.",
108
+ "Begin by silently saying to yourself: 'May I be safe. May I be peaceful. May I be well.'",
109
+ "Next, bring to mind someone you care for and repeat the same phrases.",
110
+ "Then gently extend these wishes to all beings.",
111
+ "Remain aware of your breath throughout."
112
+ ],
113
+ "durationMinutes": 12,
114
+ "difficulty": "intermediate",
115
+ "audioUrl": null,
116
+ "isActive": true
117
+ },
118
+ {
119
+ "title": "Body Awareness Meditation",
120
+ "shortDescription": "Notice sensations in your body to anchor yourself in the present moment.",
121
+ "category": "meditation",
122
+ "steps": [
123
+ "Sit or lie down comfortably.",
124
+ "Bring attention to your feet and simply notice any sensations.",
125
+ "Slowly move awareness up through your legs, torso, and arms.",
126
+ "Notice tension, warmth, or relaxation without judging it.",
127
+ "End with awareness of your whole body."
128
+ ],
129
+ "durationMinutes": 8,
130
+ "difficulty": "beginner",
131
+ "audioUrl": null,
132
+ "isActive": true
133
+ },
134
+ {
135
+ "title": "Focused Attention Meditation",
136
+ "shortDescription": "Train your attention by focusing gently on a single point.",
137
+ "category": "meditation",
138
+ "steps": [
139
+ "Sit calmly and choose a focus point, such as your breath or a candle flame.",
140
+ "Rest your attention there.",
141
+ "When distractions arise, note them gently without frustration.",
142
+ "Return attention to your chosen focus.",
143
+ "Stay soft and patient."
144
+ ],
145
+ "durationMinutes": 15,
146
+ "difficulty": "intermediate",
147
+ "audioUrl": null,
148
+ "isActive": true
149
+ },
150
+ {
151
+ "title": "Open Awareness Meditation",
152
+ "shortDescription": "Observe sensations, sounds, and thoughts as they arise and fade.",
153
+ "category": "meditation",
154
+ "steps": [
155
+ "Sit comfortably and relax your breathing.",
156
+ "Allow your awareness to open to sounds, sensations, and thoughts.",
157
+ "Notice them arise and pass naturally.",
158
+ "Avoid holding or pushing anything away.",
159
+ "Rest in gentle awareness."
160
+ ],
161
+ "durationMinutes": 20,
162
+ "difficulty": "advanced",
163
+ "audioUrl": null,
164
+ "isActive": true
165
+ },
166
+ {
167
+ "title": "Peaceful Place Visualization",
168
+ "shortDescription": "Imagine a calm and soothing place to relax your mind.",
169
+ "category": "visualization",
170
+ "steps": [
171
+ "Sit comfortably and close your eyes if you wish.",
172
+ "Imagine a place where you feel completely safe and relaxed.",
173
+ "Notice colors, sounds, and sensations around you.",
174
+ "Imagine breathing in calmness from this place.",
175
+ "Stay here for a few minutes and gently return."
176
+ ],
177
+ "durationMinutes": 8,
178
+ "difficulty": "beginner",
179
+ "audioUrl": null,
180
+ "isActive": true
181
+ },
182
+ {
183
+ "title": "Calming Light Visualization",
184
+ "shortDescription": "Visualize warm light relaxing each part of your body.",
185
+ "category": "visualization",
186
+ "steps": [
187
+ "Close your eyes and imagine a warm, gentle light above you.",
188
+ "See it slowly moving through your body.",
189
+ "Imagine tension melting as the light passes.",
190
+ "Breathe calmly and rest in the feeling.",
191
+ "End with a few slow breaths."
192
+ ],
193
+ "durationMinutes": 10,
194
+ "difficulty": "intermediate",
195
+ "audioUrl": null,
196
+ "isActive": true
197
+ },
198
+ {
199
+ "title": "Mountain Visualization",
200
+ "shortDescription": "Visualize yourself as a calm, grounded mountain.",
201
+ "category": "visualization",
202
+ "steps": [
203
+ "Sit upright as if you are a strong, stable mountain.",
204
+ "Feel your body grounded and steady.",
205
+ "Imagine weather passing over you — sun, rain, clouds.",
206
+ "No matter what happens, the mountain remains steady.",
207
+ "Rest in this sense of inner stability."
208
+ ],
209
+ "durationMinutes": 12,
210
+ "difficulty": "intermediate",
211
+ "audioUrl": null,
212
+ "isActive": true
213
+ },
214
+ {
215
+ "title": "Positive Future Visualization",
216
+ "shortDescription": "Imagine yourself moving toward a hopeful and meaningful future.",
217
+ "category": "visualization",
218
+ "steps": [
219
+ "Close your eyes and imagine your future self feeling calm and fulfilled.",
220
+ "Notice how this version of you thinks, feels, and moves.",
221
+ "See yourself taking small steps that support your well-being.",
222
+ "Let this vision motivate and encourage you.",
223
+ "Return gently to the present moment."
224
+ ],
225
+ "durationMinutes": 15,
226
+ "difficulty": "advanced",
227
+ "audioUrl": null,
228
+ "isActive": true
229
+ },
230
+ {
231
+ "title": "Short Body Scan",
232
+ "shortDescription": "Briefly notice sensations throughout the body to relax.",
233
+ "category": "body_scan",
234
+ "steps": [
235
+ "Sit or lie comfortably.",
236
+ "Bring attention to your feet.",
237
+ "Move attention slowly upward through the body.",
238
+ "Notice sensations without judging them.",
239
+ "End with awareness of your whole body breathing."
240
+ ],
241
+ "durationMinutes": 7,
242
+ "difficulty": "beginner",
243
+ "audioUrl": null,
244
+ "isActive": true
245
+ },
246
+ {
247
+ "title": "Full Body Scan",
248
+ "shortDescription": "Relax tension by gently observing each part of the body.",
249
+ "category": "body_scan",
250
+ "steps": [
251
+ "Lie down or sit comfortably.",
252
+ "Start from the toes and move your attention slowly upward.",
253
+ "Notice sensations like warmth, tingling, or relaxation.",
254
+ "Allow the body to soften.",
255
+ "Stay patient and gentle with yourself."
256
+ ],
257
+ "durationMinutes": 15,
258
+ "difficulty": "intermediate",
259
+ "audioUrl": null,
260
+ "isActive": true
261
+ },
262
+ {
263
+ "title": "Tension Release Scan",
264
+ "shortDescription": "Notice and gradually relax muscles throughout the body.",
265
+ "category": "body_scan",
266
+ "steps": [
267
+ "Bring attention to your head and jaw.",
268
+ "Notice areas of tightness.",
269
+ "With each exhale, imagine softening the muscles.",
270
+ "Continue down through shoulders, chest, and legs.",
271
+ "End with a slow, full breath."
272
+ ],
273
+ "durationMinutes": 12,
274
+ "difficulty": "intermediate",
275
+ "audioUrl": null,
276
+ "isActive": true
277
+ },
278
+ {
279
+ "title": "Sleep Body Relaxation",
280
+ "shortDescription": "Gently relax the body to prepare for rest.",
281
+ "category": "body_scan",
282
+ "steps": [
283
+ "Lie comfortably in bed.",
284
+ "Bring attention to your feet and slowly relax them.",
285
+ "Move through the legs, torso, and arms.",
286
+ "Release any remaining tension in the face.",
287
+ "Breathe calmly and drift into rest."
288
+ ],
289
+ "durationMinutes": 10,
290
+ "difficulty": "beginner",
291
+ "audioUrl": null,
292
+ "isActive": true
293
+ },
294
+ {
295
+ "title": "5-4-3-2-1 Grounding Exercise",
296
+ "shortDescription": "Reduce anxiety by connecting to your senses.",
297
+ "category": "grounding",
298
+ "steps": [
299
+ "Name 5 things you can see.",
300
+ "Name 4 things you can feel.",
301
+ "Name 3 things you can hear.",
302
+ "Name 2 things you can smell.",
303
+ "Name 1 thing you can taste or appreciate."
304
+ ],
305
+ "durationMinutes": 6,
306
+ "difficulty": "beginner",
307
+ "audioUrl": null,
308
+ "isActive": true
309
+ },
310
+ {
311
+ "title": "Feet on the Ground",
312
+ "shortDescription": "Feel the support beneath you to stabilize your mind.",
313
+ "category": "grounding",
314
+ "steps": [
315
+ "Place your feet firmly on the floor.",
316
+ "Notice the sensations of contact.",
317
+ "Feel the ground supporting your weight.",
318
+ "Let your shoulders relax.",
319
+ "Breathe naturally and stay present."
320
+ ],
321
+ "durationMinutes": 5,
322
+ "difficulty": "beginner",
323
+ "audioUrl": null,
324
+ "isActive": true
325
+ },
326
+ {
327
+ "title": "Name and Notice",
328
+ "shortDescription": "Calm your thoughts by naming what you observe.",
329
+ "category": "grounding",
330
+ "steps": [
331
+ "Notice what is happening inside or around you.",
332
+ "Silently name it, such as 'thinking', 'hearing', or 'breathing'.",
333
+ "Return attention gently to the present moment.",
334
+ "Continue without judgement."
335
+ ],
336
+ "durationMinutes": 8,
337
+ "difficulty": "intermediate",
338
+ "audioUrl": null,
339
+ "isActive": true
340
+ },
341
+ {
342
+ "title": "Object Focus Grounding",
343
+ "shortDescription": "Use a simple object to bring your mind back to the present.",
344
+ "category": "grounding",
345
+ "steps": [
346
+ "Choose an object near you.",
347
+ "Notice its color, shape, and texture.",
348
+ "Observe small details slowly.",
349
+ "Allow your mind to rest in observation.",
350
+ "Return gently if distracted."
351
+ ],
352
+ "durationMinutes": 7,
353
+ "difficulty": "beginner",
354
+ "audioUrl": null,
355
+ "isActive": true
356
+ }
357
+
358
+
359
+
360
+
361
+
362
+ ]
363
+ }
package/index.js ADDED
@@ -0,0 +1,44 @@
1
+ const express=require("express")
2
+ const cors=require("cors")
3
+ const errorLogger = require("./utils/errorLogger")
4
+ const authRoutes=require("./routes/authRoutes")
5
+ const dbConnect=require("./dbConnect")
6
+ const app=express()
7
+ const dotenv=require("dotenv")
8
+ const moodRoutes=require("./routes/moodRoutes")
9
+ const exerciseRoutes=require("./routes/exerciseRoute")
10
+ const requestLogger = require("./utils/requestLogger")
11
+ dotenv.config()
12
+
13
+ const PORT=process.env.PORT || 3000
14
+
15
+ app.use(cors())
16
+ app.use(express.json())
17
+ app.use(express.urlencoded({extended:true}))
18
+ app.use(requestLogger)
19
+
20
+ app.use("/api/v1/auth", authRoutes);
21
+ app.use("/api/v1/mood", moodRoutes);
22
+ app.use("/api/v1/exercise", exerciseRoutes);
23
+
24
+
25
+ app.get("/api/v1/health", (req, res) => {
26
+ res.json({ status: "OK", app: "Mindmingle API" });
27
+ });
28
+
29
+ app.use(errorLogger);
30
+
31
+ (async () => {
32
+ try {
33
+ await dbConnect();
34
+ app.listen(PORT,()=>{
35
+ console.log(`Server is running on port ${PORT}`)
36
+ })
37
+ } catch (err) {
38
+ process.exit(1);
39
+ }
40
+ })();
41
+
42
+
43
+
44
+
@@ -0,0 +1,28 @@
1
+ const jwt = require("jsonwebtoken");
2
+ const User = require("../models/User");
3
+ const axios = require("axios");
4
+
5
+ const isUser = async (req, res, next) => {
6
+ try {
7
+ if (
8
+ !req.headers ||
9
+ !req.headers.authorization ||
10
+ !req.headers.authorization.startsWith("Bearer")
11
+ ) {
12
+ return res.status(401).send("Authorization header is required");
13
+ }
14
+ const token = req.headers.authorization.split(" ")[1];
15
+ const decoded = jwt.verify(token, process.env.JWT_SECRET);
16
+ const user = await User.findOne({ _id: decoded.userId }).select(
17
+ "_id email provider"
18
+ );
19
+ req.user = user;
20
+ if (!user) {
21
+ return res.status(401).json({ error: "Invalid token user" });
22
+ }
23
+ next();
24
+ } catch (e) {
25
+ return res.status(401).send({ message: "Invalid or expired JWT Token" });
26
+ }
27
+ };
28
+ module.exports = isUser;
@@ -0,0 +1,64 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const exerciseSchema = new mongoose.Schema(
4
+ {
5
+ title: {
6
+ type: String,
7
+ required: true,
8
+ trim: true
9
+ },
10
+
11
+ shortDescription: {
12
+ type: String,
13
+ required: true,
14
+ trim: true
15
+ },
16
+
17
+ category: {
18
+ type: String,
19
+ enum: [
20
+ "breathing",
21
+ "meditation",
22
+ "visualization",
23
+ "body_scan",
24
+ "grounding",
25
+ "mindfulness"
26
+ ],
27
+ required: true
28
+ },
29
+
30
+ steps: {
31
+ type: [String],
32
+ required: true,
33
+ validate: v => Array.isArray(v) && v.length > 0
34
+ },
35
+
36
+ durationMinutes: {
37
+ type: Number,
38
+ required: true,
39
+ min: 1
40
+ },
41
+
42
+ difficulty: {
43
+ type: String,
44
+ enum: ["beginner", "intermediate", "advanced"],
45
+ default: "beginner"
46
+ },
47
+
48
+ audioUrl: {
49
+ type: String,
50
+ default: null
51
+ },
52
+
53
+ isActive: {
54
+ type: Boolean,
55
+ default: true
56
+ }
57
+ },
58
+ { timestamps: true }
59
+ );
60
+
61
+ exerciseSchema.index({ category: 1 });
62
+ exerciseSchema.index({ isActive: 1 });
63
+
64
+ module.exports = mongoose.model("Exercise", exerciseSchema);
package/models/Mood.js ADDED
@@ -0,0 +1,105 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const moodSchema = new mongoose.Schema(
4
+ {
5
+ userId: {
6
+ type: mongoose.Schema.Types.ObjectId,
7
+ ref: "User",
8
+ required: true,
9
+ },
10
+
11
+ moodScore: {
12
+ type: Number,
13
+ min: 1,
14
+ max: 5,
15
+ required: true
16
+ },
17
+
18
+ primaryMood: {
19
+ type: String,
20
+ required: true,
21
+ enum: [
22
+ "happy",
23
+ "calm",
24
+ "excited",
25
+ "okay",
26
+ "stressed",
27
+ "anxious",
28
+ "sad",
29
+ "tired",
30
+ "angry",
31
+ "lonely"
32
+ ]
33
+ },
34
+
35
+ secondaryMoods: {
36
+ type: [String],
37
+ default: []
38
+ },
39
+
40
+ valence: {
41
+ type: String,
42
+ required: true,
43
+ enum: ["positive", "neutral", "negative"]
44
+ },
45
+
46
+ energy: {
47
+ type: String,
48
+ required: true,
49
+ enum: ["high", "medium", "low"]
50
+ },
51
+
52
+ note: {
53
+ type: String,
54
+ trim: true,
55
+ maxlength: 500
56
+ },
57
+
58
+ context: {
59
+ sleepHours: {
60
+ type: Number,
61
+ min: 0,
62
+ max: 24
63
+ },
64
+ activity: {
65
+ type: String,
66
+ enum: [
67
+ "work",
68
+ "study",
69
+ "exercise",
70
+ "social",
71
+ "rest",
72
+ "commute",
73
+ "other"
74
+ ]
75
+ },
76
+ locationType: {
77
+ type: String,
78
+ enum: ["home", "office", "outdoors", "travel", "other"]
79
+ },
80
+ social: {
81
+ type: String,
82
+ enum: [
83
+ "alone",
84
+ "with_friends",
85
+ "with_family",
86
+ "with_colleagues"
87
+ ]
88
+ }
89
+ },
90
+
91
+ moodDate: {
92
+ type: String, // YYYY-MM-DD
93
+ required: true,
94
+ index: true
95
+ }
96
+ },
97
+ {
98
+ timestamps: true
99
+ }
100
+ );
101
+
102
+ moodSchema.index({ userId: 1, moodDate: 1 });
103
+ moodSchema.index({ userId: 1, createdAt: -1 });
104
+
105
+ module.exports = mongoose.model("Mood", moodSchema);
package/models/User.js ADDED
@@ -0,0 +1,54 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const userSchema = new mongoose.Schema(
4
+ {
5
+ name: {
6
+ type: String,
7
+ required: true,
8
+ trim: true,
9
+ },
10
+
11
+ email: {
12
+ type: String,
13
+ required: true,
14
+ lowercase: true,
15
+ trim: true,
16
+ },
17
+
18
+ password: {
19
+ type: String,
20
+ },
21
+
22
+ provider: {
23
+ type: String,
24
+ enum: ["email", "google"],
25
+ default: "email",
26
+ },
27
+
28
+ providerId: {
29
+ type: String,
30
+ default: null,
31
+ },
32
+
33
+ // avatarUrl: {
34
+ // type: String,
35
+ // default: null,
36
+ // },
37
+
38
+ isAnonymous: {
39
+ type: Boolean,
40
+ default: false,
41
+ },
42
+
43
+ isActive: {
44
+ type: Boolean,
45
+ default: true,
46
+ },
47
+ },
48
+ { timestamps: true }
49
+ );
50
+
51
+ userSchema.index({ email: 1 });
52
+
53
+ module.exports= mongoose.model("User", userSchema);
54
+
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "mindmingle-backend",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "start": " nodemon index.js"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": "",
13
+ "dependencies": {
14
+ "axios": "^1.13.2",
15
+ "bcrypt": "^6.0.0",
16
+ "cors": "^2.8.5",
17
+ "dotenv": "^17.2.3",
18
+ "express": "^4.21.2",
19
+ "jsonwebtoken": "^9.0.3",
20
+ "mongoose": "^9.0.2",
21
+ "nodemon": "^3.1.11"
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ const router=require('express').Router();
2
+ const authController=require('../controllers/authController');
3
+
4
+
5
+ router.post("/signup",authController.signUpController);
6
+ router.post("/login",authController.loginController);
7
+ router.post("/google-login",authController.googleLoginController);
8
+
9
+
10
+ module.exports=router;