create-fullstack-boilerplate 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 (71) hide show
  1. package/README.md +390 -0
  2. package/index.js +78 -0
  3. package/lib/addDB.js +77 -0
  4. package/lib/addRoute.js +264 -0
  5. package/lib/copyProject.js +25 -0
  6. package/lib/dataTypes.js +79 -0
  7. package/lib/installDeps.js +11 -0
  8. package/lib/prompts.js +289 -0
  9. package/lib/setupExtraDB.js +172 -0
  10. package/lib/setupMainDB.js +9 -0
  11. package/lib/testDBConnection.js +31 -0
  12. package/lib/utils.js +39 -0
  13. package/package.json +45 -0
  14. package/template/Backend/.env +7 -0
  15. package/template/Backend/DB/DBInit.js +28 -0
  16. package/template/Backend/DB/dbConfigs.js +4 -0
  17. package/template/Backend/Models/index.js +54 -0
  18. package/template/Backend/README.md +535 -0
  19. package/template/Backend/middleware/authMiddleware.js +19 -0
  20. package/template/Backend/package-lock.json +2997 -0
  21. package/template/Backend/package.json +32 -0
  22. package/template/Backend/routes/authRoutes.js +15 -0
  23. package/template/Backend/routes/dashboardRoutes.js +13 -0
  24. package/template/Backend/routes/index.js +15 -0
  25. package/template/Backend/routes/settingsRoutes.js +9 -0
  26. package/template/Backend/server.js +70 -0
  27. package/template/Backend/services/authService.js +68 -0
  28. package/template/Backend/services/cryptoService.js +14 -0
  29. package/template/Backend/services/dashboardService.js +39 -0
  30. package/template/Backend/services/settingsService.js +43 -0
  31. package/template/Frontend/.env +3 -0
  32. package/template/Frontend/README.md +576 -0
  33. package/template/Frontend/eslint.config.js +29 -0
  34. package/template/Frontend/index.html +13 -0
  35. package/template/Frontend/package-lock.json +3690 -0
  36. package/template/Frontend/package.json +39 -0
  37. package/template/Frontend/public/PMDLogo.png +0 -0
  38. package/template/Frontend/public/pp.jpg +0 -0
  39. package/template/Frontend/public/tabicon.png +0 -0
  40. package/template/Frontend/src/App.jsx +71 -0
  41. package/template/Frontend/src/assets/fonts/ArticulatCFDemiBold/font.woff +0 -0
  42. package/template/Frontend/src/assets/fonts/ArticulatCFDemiBold/font.woff2 +0 -0
  43. package/template/Frontend/src/assets/fonts/ArticulatCFNormal/font.woff +0 -0
  44. package/template/Frontend/src/assets/fonts/ArticulatCFNormal/font.woff2 +0 -0
  45. package/template/Frontend/src/assets/fonts/ArticulatCFRegular/font.woff +0 -0
  46. package/template/Frontend/src/assets/fonts/ArticulatCFRegular/font.woff2 +0 -0
  47. package/template/Frontend/src/assets/fonts/MixtaProRegularItalic/font.woff +0 -0
  48. package/template/Frontend/src/assets/fonts/MixtaProRegularItalic/font.woff2 +0 -0
  49. package/template/Frontend/src/assets/fonts/fonts_sohne/OTF/S/303/266hneMono-Buch.otf +0 -0
  50. package/template/Frontend/src/assets/fonts/fonts_sohne/OTF/S/303/266hneMono-Leicht.otf +0 -0
  51. package/template/Frontend/src/assets/fonts/fonts_sohne/WOFF2/soehne-mono-buch.woff2 +0 -0
  52. package/template/Frontend/src/assets/fonts/fonts_sohne/WOFF2/soehne-mono-leicht.woff2 +0 -0
  53. package/template/Frontend/src/components/Layout.jsx +61 -0
  54. package/template/Frontend/src/components/Loader.jsx +19 -0
  55. package/template/Frontend/src/components/ProtectedRoute.jsx +19 -0
  56. package/template/Frontend/src/components/Sidebar.jsx +286 -0
  57. package/template/Frontend/src/components/ThemeToggle.jsx +30 -0
  58. package/template/Frontend/src/config/axiosClient.js +46 -0
  59. package/template/Frontend/src/config/encryption.js +11 -0
  60. package/template/Frontend/src/config/routes.js +65 -0
  61. package/template/Frontend/src/contexts/AuthContext.jsx +144 -0
  62. package/template/Frontend/src/contexts/ThemeContext.jsx +69 -0
  63. package/template/Frontend/src/index.css +88 -0
  64. package/template/Frontend/src/main.jsx +11 -0
  65. package/template/Frontend/src/pages/Dashboard.jsx +137 -0
  66. package/template/Frontend/src/pages/Login.jsx +195 -0
  67. package/template/Frontend/src/pages/NotFound.jsx +70 -0
  68. package/template/Frontend/src/pages/Settings.jsx +69 -0
  69. package/template/Frontend/tailwind.config.js +90 -0
  70. package/template/Frontend/vite.config.js +37 -0
  71. package/template/Readme.md +0 -0
package/README.md ADDED
@@ -0,0 +1,390 @@
1
+ # create-fullstack-app
2
+
3
+ A powerful CLI tool to quickly scaffold a complete fullstack application with React, Node.js, Express, and Sequelize with multi-database support. Get started building real features instead of spending time on project setup!
4
+
5
+ ## ✨ Features
6
+
7
+ - šŸš€ **Quick Setup** - Create a production-ready fullstack project in minutes
8
+ - šŸ—„ļø **Multi-Database Support** - Connect to multiple databases (MySQL, MariaDB, PostgreSQL)
9
+ - šŸ”§ **Interactive CLI** - User-friendly prompts guide you through setup
10
+ - šŸ“¦ **Modern Stack** - React 19, Node.js 20+, Express, Sequelize, Tailwind CSS, DaisyUI
11
+ - šŸ”Œ **Dynamic Database Addition** - Add new databases to existing projects
12
+ - šŸ›£ļø **Route Generator** - Quickly scaffold new API endpoints with services
13
+ - šŸ” **Authentication Ready** - JWT-based authentication out of the box
14
+ - šŸ“ **Comprehensive Documentation** - Detailed READMEs for both frontend and backend
15
+ - šŸŽÆ **Best Practices** - Following industry-standard project structure
16
+
17
+ ## šŸ“‹ Prerequisites
18
+
19
+ - **Node.js** >= 20.0.0
20
+ - **npm** or **yarn**
21
+ - **Database Server** (MySQL, MariaDB, or PostgreSQL)
22
+
23
+ ## šŸš€ Quick Start
24
+
25
+ ### Create a New Project
26
+
27
+ ```bash
28
+ npx create-fullstack-app
29
+ ```
30
+
31
+ Or install globally:
32
+
33
+ ```bash
34
+ npm install -g create-fullstack-app
35
+ create-fullstack-app
36
+ ```
37
+
38
+ Follow the interactive prompts:
39
+
40
+ 1. Enter your project name
41
+ 2. Choose your main database dialect (MySQL, MariaDB, or PostgreSQL)
42
+ 3. Optionally add an extra database
43
+ 4. Optionally initialize a Git repository
44
+
45
+ The tool will:
46
+ - āœ… Copy project template files
47
+ - āœ… Configure databases
48
+ - āœ… Install all dependencies
49
+ - āœ… Test database connections
50
+ - āœ… Set up environment variables
51
+
52
+ ### Start Development
53
+
54
+ ```bash
55
+ cd your-project-name
56
+
57
+ # Start backend server
58
+ cd backend
59
+ npm run dev
60
+
61
+ # In another terminal, start frontend
62
+ cd frontend
63
+ npm run dev
64
+ ```
65
+
66
+ - Backend runs on: `http://localhost:5000`
67
+ - Frontend runs on: `http://localhost:5173`
68
+
69
+ ## šŸ—„ļø Database Management
70
+
71
+ ### Add a Database to Existing Project
72
+
73
+ Navigate to your project root and run:
74
+
75
+ ```bash
76
+ npx create-fullstack-app add-db
77
+ ```
78
+
79
+ The CLI will prompt you for:
80
+ - Database identifier (e.g., `REPORTING_DB`, `ANALYTICS_DB`)
81
+ - Database credentials (host, port, username, password)
82
+ - Database name
83
+ - Table/model name
84
+ - Whether to define table attributes now
85
+
86
+ #### Defining Table Attributes
87
+
88
+ When adding a database, you can choose to define your table schema interactively:
89
+
90
+ 1. **Primary Key**: Define your primary key column (name, type, auto-increment)
91
+ 2. **Other Attributes**: Add as many columns as needed with:
92
+ - Column name
93
+ - Data type (dialect-specific options)
94
+ - Length/precision (for VARCHAR, DECIMAL, etc.)
95
+ - Constraints (NOT NULL, UNIQUE, DEFAULT values)
96
+
97
+ The tool automatically:
98
+ - Creates a folder in `Models/[DB_NAME]/`
99
+ - Generates the model file with your schema
100
+ - Creates database configuration file
101
+ - Updates `DB/dbConfigs.js`
102
+ - Adds credentials to `.env`
103
+ - Tests the database connection
104
+
105
+ ### Data Types by Dialect
106
+
107
+ The CLI provides appropriate data types based on your selected database dialect:
108
+
109
+ **MySQL/MariaDB:**
110
+ - INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL
111
+ - STRING (VARCHAR), TEXT
112
+ - BOOLEAN, DATE, DATETIME, TIME
113
+ - JSON, BLOB, ENUM
114
+
115
+ **PostgreSQL:**
116
+ - INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL
117
+ - STRING (VARCHAR), TEXT
118
+ - BOOLEAN, DATE, TIMESTAMP, TIME
119
+ - JSON, JSONB, BYTEA, UUID, ARRAY, ENUM
120
+
121
+ ## šŸ›£ļø Route Management
122
+
123
+ ### Add a New Route
124
+
125
+ Navigate to your project root and run:
126
+
127
+ ```bash
128
+ npx create-fullstack-app add-route
129
+ ```
130
+
131
+ The CLI will prompt you for:
132
+ - Route name (e.g., `users`, `products`)
133
+ - Route path (e.g., `/users`)
134
+ - Whether authentication is required
135
+
136
+ This automatically:
137
+ - āœ… Creates `routes/[routeName]Routes.js` with CRUD endpoints
138
+ - āœ… Creates `services/[routeName]Service.js` with business logic stubs
139
+ - āœ… Updates `routes/index.js` to register the new route
140
+ - āœ… Applies authentication middleware if requested
141
+
142
+ ### Generated Route Structure
143
+
144
+ ```javascript
145
+ // routes/usersRoutes.js
146
+ GET /users - Get all users
147
+ GET /users/:id - Get user by ID
148
+ POST /users - Create new user
149
+ PUT /users/:id - Update user
150
+ DELETE /users/:id - Delete user
151
+ ```
152
+
153
+ Each route delegates to a corresponding service function where you implement your business logic.
154
+
155
+ ## šŸ“ Project Structure
156
+
157
+ ```
158
+ your-project/
159
+ ā”œā”€ā”€ backend/
160
+ │ ā”œā”€ā”€ DB/ # Database configurations
161
+ │ │ ā”œā”€ā”€ DBInit.js # Connection initialization
162
+ │ │ ā”œā”€ā”€ dbConfigs.js # Database registry
163
+ │ │ └── [DB].config.js # Individual DB configs
164
+ │ ā”œā”€ā”€ Models/ # Sequelize models
165
+ │ │ ā”œā”€ā”€ index.js # Model loader
166
+ │ │ └── [DB_NAME]/ # Models per database
167
+ │ ā”œā”€ā”€ routes/ # API endpoints
168
+ │ │ ā”œā”€ā”€ index.js # Main router
169
+ │ │ └── *Routes.js # Feature routes
170
+ │ ā”œā”€ā”€ services/ # Business logic
171
+ │ │ └── *Service.js # Service functions
172
+ │ ā”œā”€ā”€ middleware/ # Express middleware
173
+ │ ā”œā”€ā”€ .env # Environment variables
174
+ │ ā”œā”€ā”€ package.json
175
+ │ ā”œā”€ā”€ server.js # Application entry
176
+ │ └── README.md # Backend documentation
177
+ └── frontend/
178
+ ā”œā”€ā”€ src/
179
+ │ ā”œā”€ā”€ components/ # React components
180
+ │ ā”œā”€ā”€ pages/ # Page components
181
+ │ ā”œā”€ā”€ services/ # API clients
182
+ │ ā”œā”€ā”€ App.jsx
183
+ │ └── main.jsx
184
+ ā”œā”€ā”€ public/
185
+ ā”œā”€ā”€ .env
186
+ ā”œā”€ā”€ package.json
187
+ ā”œā”€ā”€ vite.config.js
188
+ └── README.md # Frontend documentation
189
+ ```
190
+
191
+ ## šŸ”§ Configuration
192
+
193
+ ### Backend Environment Variables
194
+
195
+ ```env
196
+ # Server
197
+ PORT=5000
198
+ CLIENT_URL=http://localhost:5173
199
+
200
+ # Security
201
+ JWT_SECRET=your_jwt_secret
202
+ PASSWORD_ENCRYPTION_KEY=your_encryption_key
203
+
204
+ # Database Example (created when you add a database)
205
+ MAIN_DB_USER=root
206
+ MAIN_DB_PASSWORD=password
207
+ MAIN_DB_NAME=mydb
208
+ MAIN_DB_HOST=localhost
209
+ MAIN_DB_PORT=3306
210
+ ```
211
+
212
+ ### Frontend Environment Variables
213
+
214
+ ```env
215
+ VITE_API_URL=http://localhost:5000/api
216
+ ```
217
+
218
+ **Important:** Vite requires environment variables to be prefixed with `VITE_`.
219
+
220
+ ## šŸ’» Usage Examples
221
+
222
+ ### Accessing Databases in Your Code
223
+
224
+ ```javascript
225
+ // Import all databases
226
+ const databases = require('./Models');
227
+
228
+ // Access specific database
229
+ const { MAIN_DB, REPORTING_DB } = databases;
230
+
231
+ // Use models
232
+ const { User, Product } = MAIN_DB;
233
+
234
+ // Sequelize operations
235
+ const users = await User.findAll();
236
+ const user = await User.findByPk(1);
237
+ await User.create({ name: 'John', email: 'john@example.com' });
238
+ ```
239
+
240
+ ### Creating API Endpoints
241
+
242
+ After generating a route with `add-route`, implement your service logic:
243
+
244
+ ```javascript
245
+ // services/usersService.js
246
+ const { MAIN_DB } = require('../Models');
247
+ const { User } = MAIN_DB;
248
+
249
+ exports.getAll = async (req, res) => {
250
+ try {
251
+ const users = await User.findAll();
252
+ res.json(users);
253
+ } catch (error) {
254
+ res.status(500).json({ message: 'Error fetching users', error: error.message });
255
+ }
256
+ };
257
+ ```
258
+
259
+ ### Making API Calls from Frontend
260
+
261
+ ```javascript
262
+ // src/services/api.js
263
+ import axios from 'axios';
264
+
265
+ const api = axios.create({
266
+ baseURL: import.meta.env.VITE_API_URL
267
+ });
268
+
269
+ // Add auth token to requests
270
+ api.interceptors.request.use((config) => {
271
+ const token = localStorage.getItem('token');
272
+ if (token) {
273
+ config.headers.Authorization = `Bearer ${token}`;
274
+ }
275
+ return config;
276
+ });
277
+
278
+ export default api;
279
+
280
+ // src/services/userService.js
281
+ import api from './api';
282
+
283
+ export const getUsers = () => api.get('/users');
284
+ export const createUser = (data) => api.post('/users', data);
285
+ ```
286
+
287
+ ## šŸ“š Technology Stack
288
+
289
+ ### Backend
290
+ - **Node.js** - JavaScript runtime
291
+ - **Express** - Web framework
292
+ - **Sequelize** - ORM for SQL databases
293
+ - **JWT** - Authentication
294
+ - **bcryptjs** - Password hashing
295
+ - **colors** - Terminal output styling
296
+ - **dotenv** - Environment variable management
297
+
298
+ ### Frontend
299
+ - **React 19** - UI library
300
+ - **Vite** - Build tool
301
+ - **Tailwind CSS 4** - Utility-first CSS
302
+ - **DaisyUI** - Component library
303
+ - **React Router** - Routing
304
+ - **Axios** - HTTP client
305
+ - **Recharts** - Data visualization
306
+
307
+ ## šŸŽÆ Best Practices
308
+
309
+ 1. **Environment Variables**: Never commit `.env` files
310
+ 2. **Database Models**: Organize models by database
311
+ 3. **Service Layer**: Keep business logic in services, not routes
312
+ 4. **Error Handling**: Always handle errors and provide meaningful messages
313
+ 5. **Authentication**: Use JWT tokens stored in localStorage
314
+ 6. **Validation**: Validate input on both client and server
315
+ 7. **Documentation**: Update READMEs when adding features
316
+
317
+ ## šŸ”’ Security Considerations
318
+
319
+ - Change default JWT secrets in production
320
+ - Use environment variables for sensitive data
321
+ - Implement rate limiting for APIs
322
+ - Sanitize user inputs
323
+ - Use HTTPS in production
324
+ - Keep dependencies updated
325
+
326
+ ## šŸ› Troubleshooting
327
+
328
+ ### Command Not Found
329
+
330
+ ```bash
331
+ # Reinstall the package globally
332
+ npm install -g create-fullstack-app
333
+ ```
334
+
335
+ ### Database Connection Failed
336
+
337
+ - Verify database server is running
338
+ - Check credentials in `.env`
339
+ - Ensure database exists
340
+ - Check network connectivity
341
+ - Verify port is not blocked
342
+
343
+ ### Port Already in Use
344
+
345
+ ```bash
346
+ # Windows
347
+ netstat -ano | findstr :5000
348
+ taskkill /PID <PID> /F
349
+
350
+ # Linux/Mac
351
+ lsof -i :5000
352
+ kill -9 <PID>
353
+ ```
354
+
355
+ ### Module Not Found
356
+
357
+ ```bash
358
+ # Reinstall dependencies
359
+ cd backend && npm install
360
+ cd ../frontend && npm install
361
+ ```
362
+
363
+ ## šŸ“– Additional Documentation
364
+
365
+ After creating your project, refer to:
366
+
367
+ - `backend/README.md` - Complete backend documentation including Sequelize usage
368
+ - `frontend/README.md` - Complete frontend documentation including React patterns
369
+
370
+ ## šŸ¤ Contributing
371
+
372
+ Found a bug or have a feature request? Please open an issue on GitHub.
373
+
374
+ ## šŸ“ License
375
+
376
+ ISC
377
+
378
+ ## šŸ‘Øā€šŸ’» Author
379
+
380
+ Muhammad Huzaifa
381
+
382
+ ## šŸ™ Acknowledgments
383
+
384
+ Built with modern tools and best practices to help developers start building features faster!
385
+
386
+ ---
387
+
388
+ **Happy Coding! šŸš€**
389
+
390
+ Get started in minutes, not hours. Focus on building features, not boilerplate.
package/index.js ADDED
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+
3
+ (async () => {
4
+ const argv = process.argv.slice(2);
5
+
6
+ if (argv[0] === "add-db") {
7
+ await require("./lib/addDB")();
8
+ return;
9
+ }
10
+
11
+ if (argv[0] === "add-route") {
12
+ await require("./lib/addRoute")();
13
+ return;
14
+ }
15
+
16
+ // ---- Your existing create-project code ----
17
+ const path = require("path");
18
+ const { ensure } = require("./lib/utils");
19
+ const copyProject = require("./lib/copyProject");
20
+ const installDeps = require("./lib/installDeps");
21
+ const setupMainDB = require("./lib/setupMainDB");
22
+ const setupExtraDB = require("./lib/setupExtraDB");
23
+ const testDBConnection = require("./lib/testDBConnection");
24
+ const { mainPrompts, extraDBPrompts } = require("./lib/prompts");
25
+
26
+ const fs = ensure("fs-extra");
27
+
28
+ try {
29
+ console.log("\nšŸŽ›ļø Setting Up Full Stack Project...\n");
30
+
31
+ const answers = await mainPrompts();
32
+ const templateDir = path.join(__dirname, "template");
33
+ const targetDir = path.join(process.cwd(), answers.projectName);
34
+
35
+ await copyProject(templateDir, targetDir);
36
+ await setupMainDB(targetDir, answers.dbDialect);
37
+ await installDeps(targetDir);
38
+
39
+ if (answers.addExtraDB) {
40
+ const extraDB = await extraDBPrompts();
41
+ console.log(`\nšŸ” Testing connection for ${extraDB.dbKey}...`);
42
+ const ok = await testDBConnection(targetDir, extraDB);
43
+
44
+ if (ok) {
45
+ await setupExtraDB(targetDir, extraDB);
46
+ console.log(`āœ… Extra DB '${extraDB.dbKey}' successfully integrated.\n`);
47
+ } else {
48
+ console.log(`āš ļø Connection failed. Skipping extra DB setup.\n`);
49
+ }
50
+ }
51
+
52
+ if (answers.initGit) {
53
+ try {
54
+ const execa = require("execa").execa || require("execa");
55
+ await execa("git", ["init"], { cwd: targetDir });
56
+ if (answers.remoteRepo) {
57
+ await execa("git", ["remote", "add", "origin", answers.remoteRepo], { cwd: targetDir });
58
+ }
59
+ console.log("āœ… Git initialized.\n");
60
+ } catch (gitErr) {
61
+ console.log(`āš ļø Git initialization failed: ${gitErr.message}`);
62
+ console.log(` You can initialize git manually later.\n`);
63
+ }
64
+ }
65
+
66
+ console.log(`\nšŸŽ‰ Project Ready!`);
67
+ console.log(`\nāž”ļø Next Steps:`);
68
+ console.log(` cd ${answers.projectName}`);
69
+ console.log(` cd backend && npm run dev`);
70
+ console.log(` cd ../frontend && npm run dev\n`);
71
+ } catch (err) {
72
+ console.error(`\nāŒ Error creating project: ${err.message}\n`);
73
+ if (err.stack && process.env.DEBUG) {
74
+ console.error(err.stack);
75
+ }
76
+ process.exit(1);
77
+ }
78
+ })();
package/lib/addDB.js ADDED
@@ -0,0 +1,77 @@
1
+ const path = require("path");
2
+ const { extraDBPrompts } = require("./prompts");
3
+ const testDBConnection = require("./testDBConnection");
4
+ const setupExtraDB = require("./setupExtraDB");
5
+ const { ensure } = require("./utils");
6
+ const fs = ensure("fs-extra");
7
+
8
+ module.exports = async function addDB() {
9
+ console.log(`\nāž• Add New Database to Existing Project\n`);
10
+
11
+ const targetDir = process.cwd();
12
+ const backendDir = path.join(targetDir, "backend");
13
+ const dbDir = path.join(backendDir, "DB");
14
+ const modelsDir = path.join(backendDir, "Models");
15
+
16
+ // Check if we're in a valid project
17
+ if (!await fs.pathExists(backendDir)) {
18
+ console.log(`āŒ Error: No backend folder found. Are you in a project root directory?`);
19
+ console.log(` Run this command from your project root (where backend/ folder exists).`);
20
+ return;
21
+ }
22
+
23
+ if (!await fs.pathExists(dbDir)) {
24
+ console.log(`āŒ Error: No DB folder found in backend. This doesn't appear to be a valid project.`);
25
+ return;
26
+ }
27
+
28
+ if (!await fs.pathExists(modelsDir)) {
29
+ console.log(`āŒ Error: No Models folder found in backend. This doesn't appear to be a valid project.`);
30
+ return;
31
+ }
32
+
33
+ try {
34
+ // Ask DB info
35
+ const extraDB = await extraDBPrompts();
36
+
37
+ // Check if DB with same key already exists
38
+ const dbConfigsPath = path.join(dbDir, "dbConfigs.js");
39
+ if (await fs.pathExists(dbConfigsPath)) {
40
+ const dbConfigsContent = await fs.readFile(dbConfigsPath, "utf8");
41
+ if (dbConfigsContent.includes(`key: "${extraDB.dbKey}"`)) {
42
+ console.log(`\nāš ļø Database with key '${extraDB.dbKey}' already exists in the project.`);
43
+ console.log(` Please use a different DB identifier.\n`);
44
+ return;
45
+ }
46
+ }
47
+
48
+ // Check if DB folder already exists
49
+ const dbFolder = path.join(modelsDir, extraDB.dbKey);
50
+ if (await fs.pathExists(dbFolder)) {
51
+ console.log(`\nāš ļø Folder '${extraDB.dbKey}' already exists in Models directory.`);
52
+ console.log(` Please use a different DB identifier.\n`);
53
+ return;
54
+ }
55
+
56
+ console.log(`\nšŸ” Testing connection for ${extraDB.dbKey}...\n`);
57
+ const ok = await testDBConnection(targetDir, extraDB);
58
+
59
+ if (!ok) {
60
+ console.log(`āŒ Connection failed. DB not added.\n`);
61
+ return;
62
+ }
63
+
64
+ await setupExtraDB(targetDir, extraDB);
65
+ console.log(`\nāœ… Successfully added ${extraDB.dbKey} to project.\n`);
66
+ console.log(`šŸ“ Next steps:`);
67
+ console.log(` 1. Check backend/.env for database credentials`);
68
+ console.log(` 2. Add more models in backend/Models/${extraDB.dbKey}/`);
69
+ console.log(` 3. Import and use in your routes: const { ${extraDB.dbKey} } = require('./Models');\n`);
70
+
71
+ } catch (err) {
72
+ console.log(`\nāŒ Error adding DB:`, err.message);
73
+ if (err.stack) {
74
+ console.log(`\nStack trace:`, err.stack);
75
+ }
76
+ }
77
+ };