PromptBase
Close icon
General
Home
Marketplace
Hire
Create
Login
Sell
Explore
πŸ€– GPT

Building A Task Management Application

Building A Task Management Application gpt prompt mini thumbnail
1Heart icon
Favorites
3Eye icon
Views
GPT-4O
TestedTick icon
TipsTick icon
4 examplesTick icon
Expert Developer for Building a Task Management Application
...more
$3.99
Get prompt
After purchasing, you will gain access to the prompt file which you can use with GPT or the app builder. You'll receive 20 free generation credits with this purchase. By purchasing this prompt, you agree to our terms of service.
2 weeks ago
Related item

Prompt Details

Model
Chat - GPT-4o (gpt-4o)
Token size
150 ($0.00750 / call)
Example input
[ project goal ]: Team task collaboration tool [ programming language ]: JavaScript [ framework/library ]: React and Express
Example output
Developing a **Team Task Collaboration Tool** using **JavaScript**, **React**, and **Express** involves creating a robust architecture, database schema, and efficient backend and frontend communication. Below is a comprehensive guide: --- ### **1. Structuring the Project Files** Organize the project for scalability and maintainability: ```plaintext team-task-tool/ β”‚ β”œβ”€β”€ backend/ # Backend (Express.js) folder β”‚ β”œβ”€β”€ config/ # Configuration files (DB, environment variables) β”‚ β”‚ β”œβ”€β”€ db.js # Database connection β”‚ β”‚ β”œβ”€β”€ dotenv.js # Environment variable config β”‚ β”‚ β”‚ β”œβ”€β”€ controllers/ # Logic for handling requests β”‚ β”‚ β”œβ”€β”€ authController.js # Authentication logic β”‚ β”‚ β”œβ”€β”€ taskController.js # Task management logic β”‚ β”‚ β”œβ”€β”€ userController.js # User management logic β”‚ β”‚ β”‚ β”œβ”€β”€ middlewares/ # Middleware (auth, validation, etc.) β”‚ β”‚ β”œβ”€β”€ authMiddleware.js # Authentication middleware β”‚ β”‚ β”œβ”€β”€ errorHandler.js # Error handling β”‚ β”‚ β”‚ β”œβ”€β”€ models/ # Database models/schema β”‚ β”‚ β”œβ”€β”€ User.js # User schema β”‚ β”‚ β”œβ”€β”€ Task.js # Task schema β”‚ β”‚ β”‚ β”œβ”€β”€ routes/ # Route handlers β”‚ β”‚ β”œβ”€β”€ authRoutes.js # Authentication routes β”‚ β”‚ β”œβ”€β”€ taskRoutes.js # Task routes β”‚ β”‚ β”œβ”€β”€ userRoutes.js # User routes β”‚ β”‚ β”‚ β”œβ”€β”€ utils/ # Helper functions/utilities β”‚ β”‚ β”œβ”€β”€ tokenUtils.js # JWT token creation/verification β”‚ β”‚ β”‚ β”œβ”€β”€ app.js # Express app initialization β”‚ β”œβ”€β”€ server.js # Entry point for backend β”‚ β”œβ”€β”€ frontend/ # Frontend (React.js) folder β”‚ β”œβ”€β”€ public/ # Public files β”‚ β”œβ”€β”€ src/ # Source code β”‚ β”‚ β”œβ”€β”€ components/ # Reusable components β”‚ β”‚ β”‚ β”œβ”€β”€ TaskCard.js # Task card component β”‚ β”‚ β”‚ β”œβ”€β”€ Navbar.js # Navigation bar β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ pages/ # Page-level components β”‚ β”‚ β”‚ β”œβ”€β”€ Dashboard.js # Dashboard with tasks β”‚ β”‚ β”‚ β”œβ”€β”€ Login.js # Login page β”‚ β”‚ β”‚ β”œβ”€β”€ TaskDetail.js # Task detail page β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ context/ # Context for state management β”‚ β”‚ β”‚ β”œβ”€β”€ AuthContext.js # Auth state context β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ services/ # API service logic β”‚ β”‚ β”‚ β”œβ”€β”€ api.js # Axios API client setup β”‚ β”‚ β”‚ β”œβ”€β”€ taskService.js # Task-related API calls β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ utils/ # Utility functions β”‚ β”‚ β”‚ β”œβ”€β”€ formatDate.js # Format date utility β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ App.js # React root component β”‚ β”‚ β”œβ”€β”€ index.js # React entry point β”‚ β”‚ β”‚ β”œβ”€β”€ package.json β”‚ β”œβ”€β”€ README.md β”œβ”€β”€ .env # Environment variables β”œβ”€β”€ package.json # Project dependencies └── yarn.lock ``` --- ### **2. Setting Up the Database Schema** #### **User Model (User.js)** ```javascript const mongoose = require('mongoose'); const userSchema = new mongoose.Schema({ name: { type: String, required: true }, email: { type: String, required: true, unique: true }, password: { type: String, required: true }, role: { type: String, enum: ['admin', 'user'], default: 'user' }, // Role-based access }, { timestamps: true }); module.exports = mongoose.model('User', userSchema); ``` #### **Task Model (Task.js)** ```javascript const mongoose = require('mongoose'); const taskSchema = new mongoose.Schema({ title: { type: String, required: true }, description: { type: String }, priority: { type: String, enum: ['low', 'medium', 'high'], default: 'medium' }, tags: [String], // Array of tags assignedTo: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, // User reference status: { type: String, enum: ['pending', 'in-progress', 'completed'], default: 'pending' }, deadline: { type: Date }, createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, }, { timestamps: true }); module.exports = mongoose.model('Task', taskSchema); ``` --- ### **3. Implementing User Authentication & Role-Based Access Control** #### **Authentication Middleware (authMiddleware.js)** ```javascript const jwt = require('jsonwebtoken'); const authMiddleware = (req, res, next) => { const token = req.headers.authorization?.split(' ')[1]; if (!token) return res.status(401).json({ message: 'Unauthorized' }); try { const decoded = jwt.verify(token, process.env.JWT_SECRET); req.user = decoded; next(); } catch (error) { res.status(403).json({ message: 'Invalid token' }); } }; module.exports = authMiddleware; ``` #### **Role-Based Access Control** ```javascript const roleMiddleware = (roles) => (req, res, next) => { if (!roles.includes(req.user.role)) { return res.status(403).json({ message: 'Access denied' }); } next(); }; module.exports = roleMiddleware; ``` --- ### **4. Creating APIs for Managing Tasks** #### **Task Controller (taskController.js)** ```javascript const Task = require('../models/Task'); const createTask = async (req, res) => { try { const { title, description, priority, tags, assignedTo, deadline } = req.body; const newTask = await Task.create({ title, description, priority, tags, assignedTo, deadline, createdBy: req.user.id, }); res.status(201).json(newTask); } catch (error) { res.status(500).json({ message: error.message }); } }; const getTasks = async (req, res) => { try { const tasks = await Task.find({}).populate('assignedTo createdBy', 'name email'); res.status(200).json(tasks); } catch (error) { res.status(500).json({ message: error.message }); } }; module.exports = { createTask, getTasks }; ``` --- ### **5. Adding Features (Reminders, Tags, Status Updates)** #### **Adding Reminders** Use a **cron job** with libraries like `node-cron` or `agenda` to send reminders: ```javascript const cron = require('node-cron'); cron.schedule('0 9 * * *', async () => { const now = new Date(); const upcomingTasks = await Task.find({ deadline: { $lte: new Date(now.getTime() + 24 * 60 * 60 * 1000) } }); upcomingTasks.forEach((task) => { console.log(`Reminder: Task "${task.title}" is due soon.`); // Add email or notification logic here }); }); ``` --- ### **6. Ensuring Responsiveness & Performance Optimization** - **Database**: Use indexing for frequently queried fields like `assignedTo` or `status`. - **Backend**: - Enable gzip compression (`compression` middleware in Express). - Implement pagination for large datasets. - **Frontend**: - Use React's **lazy loading** for components. - Cache API responses where feasible (e.g., React Query or SWR). - **Overall**: - Use a CDN for serving static files. --- ### **7. Comments & Documentation** - Use **JSDoc** for detailed function and API documentation. - Add meaningful inline comments in critical code sections. --- ### **Sample API Route (taskRoutes.js)** ```javascript const express = require('express'); const { createTask, getTasks } = require('../controllers/taskController'); const authMiddleware = require('../middlewares/authMiddleware'); const roleMiddleware = require('../middlewares/roleMiddleware'); const router = express.Router(); router.post('/create', authMiddleware, roleMiddleware(['admin', 'user']), createTask); router.get('/', authMiddleware, getTasks); module.exports = router; ``` --- This structure and implementation provide a scalable, secure, and maintainable foundation for your **Team Task Collaboration Tool**. Let me know if you'd like further guidance on any specific part!
Browse Marketplace