create-jinmankn-app 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.
Files changed (117) hide show
  1. package/bin/index.js +76 -0
  2. package/package.json +20 -0
  3. package/templates/blueprint/BLUEPRINT_REPRODUCTION_PROMPT.md +996 -0
  4. package/templates/blueprint/HOW_IT_WORKS.md +286 -0
  5. package/templates/blueprint/README.md +123 -0
  6. package/templates/blueprint/backend/config/db.js +12 -0
  7. package/templates/blueprint/backend/controllers/authController.js +90 -0
  8. package/templates/blueprint/backend/controllers/itemController.js +74 -0
  9. package/templates/blueprint/backend/middleware/auth.js +32 -0
  10. package/templates/blueprint/backend/middleware/errorHandler.js +23 -0
  11. package/templates/blueprint/backend/models/Item.js +26 -0
  12. package/templates/blueprint/backend/models/User.js +28 -0
  13. package/templates/blueprint/backend/package-lock.json +2190 -0
  14. package/templates/blueprint/backend/package.json +23 -0
  15. package/templates/blueprint/backend/routes/authRoutes.js +11 -0
  16. package/templates/blueprint/backend/routes/healthRoutes.js +9 -0
  17. package/templates/blueprint/backend/routes/itemRoutes.js +21 -0
  18. package/templates/blueprint/backend/server.js +29 -0
  19. package/templates/blueprint/frontend/.env.example +1 -0
  20. package/templates/blueprint/frontend/index.html +13 -0
  21. package/templates/blueprint/frontend/package-lock.json +2844 -0
  22. package/templates/blueprint/frontend/package.json +23 -0
  23. package/templates/blueprint/frontend/public/favicon.svg +4 -0
  24. package/templates/blueprint/frontend/src/App.jsx +78 -0
  25. package/templates/blueprint/frontend/src/assets/logo.svg +4 -0
  26. package/templates/blueprint/frontend/src/components/DashboardLayout.jsx +103 -0
  27. package/templates/blueprint/frontend/src/components/ProtectedRoute.jsx +18 -0
  28. package/templates/blueprint/frontend/src/index.css +1 -0
  29. package/templates/blueprint/frontend/src/main.jsx +13 -0
  30. package/templates/blueprint/frontend/src/pages/DashboardHome.jsx +74 -0
  31. package/templates/blueprint/frontend/src/pages/Items.jsx +243 -0
  32. package/templates/blueprint/frontend/src/pages/Login.jsx +101 -0
  33. package/templates/blueprint/frontend/src/pages/Profile.jsx +79 -0
  34. package/templates/blueprint/frontend/src/pages/Register.jsx +122 -0
  35. package/templates/blueprint/frontend/src/pages/Report.jsx +124 -0
  36. package/templates/blueprint/frontend/vite.config.js +10 -0
  37. package/templates/blueprint/package.json +13 -0
  38. package/templates/blueprint/scripts/pack-blueprint.ps1 +18 -0
  39. package/templates/chom/Backend/app.js +25 -0
  40. package/templates/chom/Backend/package-lock.json +1551 -0
  41. package/templates/chom/Backend/package.json +23 -0
  42. package/templates/chom/Backend/seedAdmin.js +21 -0
  43. package/templates/chom/Backend/src/controllers/payment.c.js +57 -0
  44. package/templates/chom/Backend/src/controllers/students.c.js +58 -0
  45. package/templates/chom/Backend/src/controllers/users.c.js +62 -0
  46. package/templates/chom/Backend/src/middleware/authentication.js +18 -0
  47. package/templates/chom/Backend/src/models/payment.m.js +13 -0
  48. package/templates/chom/Backend/src/models/students.m.js +10 -0
  49. package/templates/chom/Backend/src/models/users.m.js +11 -0
  50. package/templates/chom/Backend/src/routes/users.r.js +21 -0
  51. package/templates/chom/Frontend/README.md +16 -0
  52. package/templates/chom/Frontend/eslint.config.js +21 -0
  53. package/templates/chom/Frontend/index.html +13 -0
  54. package/templates/chom/Frontend/package-lock.json +3075 -0
  55. package/templates/chom/Frontend/package.json +31 -0
  56. package/templates/chom/Frontend/public/favicon.svg +1 -0
  57. package/templates/chom/Frontend/public/icons.svg +24 -0
  58. package/templates/chom/Frontend/src/App.css +189 -0
  59. package/templates/chom/Frontend/src/App.jsx +28 -0
  60. package/templates/chom/Frontend/src/api/api.jsx +27 -0
  61. package/templates/chom/Frontend/src/assets/hero.png +0 -0
  62. package/templates/chom/Frontend/src/assets/react.svg +1 -0
  63. package/templates/chom/Frontend/src/assets/vite.svg +1 -0
  64. package/templates/chom/Frontend/src/components/Navbar.jsx +21 -0
  65. package/templates/chom/Frontend/src/index.css +8 -0
  66. package/templates/chom/Frontend/src/main.jsx +10 -0
  67. package/templates/chom/Frontend/src/pages/Dashboard.jsx +21 -0
  68. package/templates/chom/Frontend/src/pages/Landing.jsx +39 -0
  69. package/templates/chom/Frontend/src/pages/Login.jsx +49 -0
  70. package/templates/chom/Frontend/src/pages/Overview.jsx +42 -0
  71. package/templates/chom/Frontend/src/pages/Register.jsx +76 -0
  72. package/templates/chom/Frontend/src/pages/Students.jsx +14 -0
  73. package/templates/chom/Frontend/vite.config.js +8 -0
  74. package/templates/chom/package.json +13 -0
  75. package/templates/hospital-faisal/backend/.env.example +9 -0
  76. package/templates/hospital-faisal/backend/config/db.js +96 -0
  77. package/templates/hospital-faisal/backend/controllers/appointmentController.js +164 -0
  78. package/templates/hospital-faisal/backend/controllers/authController.js +106 -0
  79. package/templates/hospital-faisal/backend/controllers/hospitalReportController.js +72 -0
  80. package/templates/hospital-faisal/backend/controllers/medicalReportController.js +105 -0
  81. package/templates/hospital-faisal/backend/controllers/patientController.js +98 -0
  82. package/templates/hospital-faisal/backend/database/schema.sql +47 -0
  83. package/templates/hospital-faisal/backend/middleware/auth.js +30 -0
  84. package/templates/hospital-faisal/backend/middleware/errorHandler.js +23 -0
  85. package/templates/hospital-faisal/backend/middleware/role.js +6 -0
  86. package/templates/hospital-faisal/backend/package-lock.json +2092 -0
  87. package/templates/hospital-faisal/backend/package.json +23 -0
  88. package/templates/hospital-faisal/backend/routes/appointmentRoutes.js +25 -0
  89. package/templates/hospital-faisal/backend/routes/authRoutes.js +12 -0
  90. package/templates/hospital-faisal/backend/routes/healthRoutes.js +9 -0
  91. package/templates/hospital-faisal/backend/routes/hospitalReportRoutes.js +10 -0
  92. package/templates/hospital-faisal/backend/routes/medicalReportRoutes.js +16 -0
  93. package/templates/hospital-faisal/backend/routes/patientRoutes.js +22 -0
  94. package/templates/hospital-faisal/backend/server.js +46 -0
  95. package/templates/hospital-faisal/frontend/.env.example +1 -0
  96. package/templates/hospital-faisal/frontend/index.html +10 -0
  97. package/templates/hospital-faisal/frontend/package-lock.json +2844 -0
  98. package/templates/hospital-faisal/frontend/package.json +23 -0
  99. package/templates/hospital-faisal/frontend/public/favicon.svg +4 -0
  100. package/templates/hospital-faisal/frontend/src/App.jsx +56 -0
  101. package/templates/hospital-faisal/frontend/src/api.js +20 -0
  102. package/templates/hospital-faisal/frontend/src/assets/logo.svg +4 -0
  103. package/templates/hospital-faisal/frontend/src/components/DashboardLayout.jsx +114 -0
  104. package/templates/hospital-faisal/frontend/src/components/ProtectedRoute.jsx +18 -0
  105. package/templates/hospital-faisal/frontend/src/components/RoleRoute.jsx +14 -0
  106. package/templates/hospital-faisal/frontend/src/index.css +1 -0
  107. package/templates/hospital-faisal/frontend/src/main.jsx +13 -0
  108. package/templates/hospital-faisal/frontend/src/pages/Appointments.jsx +305 -0
  109. package/templates/hospital-faisal/frontend/src/pages/DashboardHome.jsx +105 -0
  110. package/templates/hospital-faisal/frontend/src/pages/Login.jsx +98 -0
  111. package/templates/hospital-faisal/frontend/src/pages/MedicalReports.jsx +182 -0
  112. package/templates/hospital-faisal/frontend/src/pages/Patients.jsx +237 -0
  113. package/templates/hospital-faisal/frontend/src/pages/Profile.jsx +78 -0
  114. package/templates/hospital-faisal/frontend/src/pages/Register.jsx +133 -0
  115. package/templates/hospital-faisal/frontend/src/pages/Report.jsx +167 -0
  116. package/templates/hospital-faisal/frontend/vite.config.js +10 -0
  117. package/templates/hospital-faisal/package.json +13 -0
@@ -0,0 +1,98 @@
1
+ const { getPool } = require('../config/db');
2
+
3
+ function formatPatient(row) {
4
+ return {
5
+ id: row.id,
6
+ fullName: row.full_name,
7
+ gender: row.gender,
8
+ dateOfBirth: row.date_of_birth,
9
+ phone: row.phone,
10
+ address: row.address,
11
+ createdAt: row.created_at,
12
+ };
13
+ }
14
+
15
+ exports.getPatients = async (req, res) => {
16
+ try {
17
+ const pool = getPool();
18
+ const [rows] = await pool.query('SELECT * FROM patients ORDER BY full_name');
19
+ res.json({ patients: rows.map(formatPatient) });
20
+ } catch (err) {
21
+ res.status(500).json({ message: err.message });
22
+ }
23
+ };
24
+
25
+ exports.getPatient = async (req, res) => {
26
+ try {
27
+ const pool = getPool();
28
+ const [rows] = await pool.query('SELECT * FROM patients WHERE id = ?', [req.params.id]);
29
+
30
+ if (!rows.length) {
31
+ return res.status(404).json({ message: 'Patient not found' });
32
+ }
33
+
34
+ res.json({ patient: formatPatient(rows[0]) });
35
+ } catch (err) {
36
+ res.status(500).json({ message: err.message });
37
+ }
38
+ };
39
+
40
+ exports.createPatient = async (req, res) => {
41
+ try {
42
+ const { fullName, gender, dateOfBirth, phone, address } = req.body;
43
+
44
+ if (!fullName || !gender || !dateOfBirth || !phone || !address) {
45
+ return res.status(400).json({ message: 'All patient fields are required' });
46
+ }
47
+
48
+ const pool = getPool();
49
+ const [result] = await pool.query(
50
+ `INSERT INTO patients (full_name, gender, date_of_birth, phone, address)
51
+ VALUES (?, ?, ?, ?, ?)`,
52
+ [fullName, gender, dateOfBirth, phone, address],
53
+ );
54
+
55
+ const [rows] = await pool.query('SELECT * FROM patients WHERE id = ?', [result.insertId]);
56
+ res.status(201).json({ patient: formatPatient(rows[0]) });
57
+ } catch (err) {
58
+ res.status(500).json({ message: err.message });
59
+ }
60
+ };
61
+
62
+ exports.updatePatient = async (req, res) => {
63
+ try {
64
+ const { fullName, gender, dateOfBirth, phone, address } = req.body;
65
+ const pool = getPool();
66
+
67
+ const [existing] = await pool.query('SELECT id FROM patients WHERE id = ?', [req.params.id]);
68
+ if (!existing.length) {
69
+ return res.status(404).json({ message: 'Patient not found' });
70
+ }
71
+
72
+ await pool.query(
73
+ `UPDATE patients SET full_name = ?, gender = ?, date_of_birth = ?, phone = ?, address = ?
74
+ WHERE id = ?`,
75
+ [fullName, gender, dateOfBirth, phone, address, req.params.id],
76
+ );
77
+
78
+ const [rows] = await pool.query('SELECT * FROM patients WHERE id = ?', [req.params.id]);
79
+ res.json({ patient: formatPatient(rows[0]) });
80
+ } catch (err) {
81
+ res.status(500).json({ message: err.message });
82
+ }
83
+ };
84
+
85
+ exports.deletePatient = async (req, res) => {
86
+ try {
87
+ const pool = getPool();
88
+ const [result] = await pool.query('DELETE FROM patients WHERE id = ?', [req.params.id]);
89
+
90
+ if (result.affectedRows === 0) {
91
+ return res.status(404).json({ message: 'Patient not found' });
92
+ }
93
+
94
+ res.json({ message: 'Patient deleted' });
95
+ } catch (err) {
96
+ res.status(500).json({ message: err.message });
97
+ }
98
+ };
@@ -0,0 +1,47 @@
1
+ CREATE DATABASE IF NOT EXISTS kf_hospital;
2
+ USE kf_hospital;
3
+
4
+ CREATE TABLE IF NOT EXISTS users (
5
+ id INT AUTO_INCREMENT PRIMARY KEY,
6
+ name VARCHAR(255) NOT NULL,
7
+ email VARCHAR(255) NOT NULL UNIQUE,
8
+ password VARCHAR(255) NOT NULL,
9
+ role ENUM('receptionist', 'doctor') NOT NULL,
10
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
11
+ );
12
+
13
+ CREATE TABLE IF NOT EXISTS patients (
14
+ id INT AUTO_INCREMENT PRIMARY KEY,
15
+ full_name VARCHAR(255) NOT NULL,
16
+ gender ENUM('Male', 'Female', 'Other') NOT NULL,
17
+ date_of_birth DATE NOT NULL,
18
+ phone VARCHAR(50) NOT NULL,
19
+ address TEXT NOT NULL,
20
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
21
+ );
22
+
23
+ CREATE TABLE IF NOT EXISTS appointments (
24
+ id INT AUTO_INCREMENT PRIMARY KEY,
25
+ patient_id INT NOT NULL,
26
+ doctor_id INT NOT NULL,
27
+ appointment_date DATE NOT NULL,
28
+ appointment_time TIME NOT NULL,
29
+ status ENUM('scheduled', 'completed', 'cancelled') NOT NULL DEFAULT 'scheduled',
30
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
31
+ FOREIGN KEY (patient_id) REFERENCES patients(id) ON DELETE CASCADE,
32
+ FOREIGN KEY (doctor_id) REFERENCES users(id) ON DELETE RESTRICT
33
+ );
34
+
35
+ CREATE TABLE IF NOT EXISTS medical_reports (
36
+ id INT AUTO_INCREMENT PRIMARY KEY,
37
+ appointment_id INT NOT NULL UNIQUE,
38
+ patient_id INT NOT NULL,
39
+ doctor_id INT NOT NULL,
40
+ diagnosis TEXT NOT NULL,
41
+ prescription TEXT NOT NULL,
42
+ report_date DATE NOT NULL,
43
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
44
+ FOREIGN KEY (appointment_id) REFERENCES appointments(id) ON DELETE CASCADE,
45
+ FOREIGN KEY (patient_id) REFERENCES patients(id) ON DELETE CASCADE,
46
+ FOREIGN KEY (doctor_id) REFERENCES users(id) ON DELETE RESTRICT
47
+ );
@@ -0,0 +1,30 @@
1
+ const jwt = require('jsonwebtoken');
2
+ const { getPool } = require('../config/db');
3
+
4
+ exports.protect = async (req, res, next) => {
5
+ try {
6
+ const header = req.headers.authorization;
7
+
8
+ if (!header || !header.startsWith('Bearer ')) {
9
+ return res.status(401).json({ message: 'Not authorized' });
10
+ }
11
+
12
+ const token = header.split(' ')[1];
13
+ const decoded = jwt.verify(token, process.env.JWT_SECRET);
14
+
15
+ const pool = getPool();
16
+ const [rows] = await pool.query(
17
+ 'SELECT id, name, email, role FROM users WHERE id = ?',
18
+ [decoded.userId],
19
+ );
20
+
21
+ if (!rows.length) {
22
+ return res.status(401).json({ message: 'Not authorized' });
23
+ }
24
+
25
+ req.user = rows[0];
26
+ next();
27
+ } catch (err) {
28
+ return res.status(401).json({ message: 'Not authorized' });
29
+ }
30
+ };
@@ -0,0 +1,23 @@
1
+
2
+
3
+ exports.notFound = (req, res) => {
4
+ res.status(404).json({ message: 'Route not found' });
5
+ }
6
+
7
+ exports.errorHandler = (err, req, res, next) => {
8
+ console.error(err);
9
+
10
+ if (err.name === 'ValidationError') {
11
+ const messages = Object.values(err.errors).map((e) => e.message);
12
+ return res.status(400).json({ message: messages.join(', ') });
13
+ }
14
+
15
+ if (err.name === 'CastError') {
16
+ return res.status(400).json({ message: 'Invalid ID' });
17
+ }
18
+
19
+ const status = err.statusCode || 500;
20
+ const message = err.message || 'Server error';
21
+
22
+ res.status(status).json({ message });
23
+ }
@@ -0,0 +1,6 @@
1
+ exports.requireRole = (...roles) => (req, res, next) => {
2
+ if (!req.user || !roles.includes(req.user.role)) {
3
+ return res.status(403).json({ message: 'Access denied for your role' });
4
+ }
5
+ next();
6
+ };