The Task Manager Application is a web-based platform designed to help users manage their tasks efficiently. It includes features for user authentication, task creation, and task management. The application is built using Django for the backend and React for the frontend, with PostgreSQL as the database.
- Overview
- Project Structure
- Setup Instructions
- Backend Development
- Frontend Development
- Future Work
- Contributing
- License
task_manager/
├── env/
├── frontend/
├── task_manager/
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ ├── wsgi.py
├── tasks/
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── serializers.py
│ ├── views.py
│ ├── tests.py
│ ├── urls.py
├── users/
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── serializers.py
│ ├── views.py
│ ├── tests.py
│ ├── urls.py
├── tests/
│ ├── __init__.py
│ ├── test_tasks.py
│ ├── test_authentication_permissions.py
├── manage.py
└── README.md
- Python 3.8+
- Node.js and npm
- PostgreSQL
-
Clone the repository:
git clone https://github.com/yourusername/task_manager.git cd task_manager
-
Create and activate a virtual environment:
python3 -m venv env source env/bin/activate
-
Install the required packages:
pip install django psycopg2-binary djangorestframework
-
Configure PostgreSQL database: Edit
task_manager/settings.py
to configure the PostgreSQL database:DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'task_manager_db', 'USER': 'your_db_user', 'PASSWORD': 'your_db_password', 'HOST': 'localhost', 'PORT': '5432', } }
-
Run migrations:
python manage.py makemigrations python manage.py migrate
-
Run the development server:
python manage.py runserver
-
Navigate to the frontend directory:
cd frontend
-
Install the required packages:
npm install
-
Run the development server:
npm start
- Initialized a Django project named
task_manager
. - Configured the project to use PostgreSQL as the database.
- Configured PostgreSQL database settings in
settings.py
.
- Created two Django apps:
users
andtasks
.
-
Defined the
User
model inusers/models.py
:from django.db import models class User(models.Model): username = models.CharField(max_length=100, unique=True) email = models.EmailField(unique=True) password = models.CharField(max_length=100)
-
Defined the
Task
model intasks/models.py
:from django.db import models from users.models import User class Task(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=255) description = models.TextField() completed = models.BooleanField(default=False) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True)
- Created serializers for
User
andTask
models.
- Created viewsets for
User
andTask
models.
- Configured URLs to include routes for the viewsets.
- Ran initial migrations to create database tables.
- Initialized a React project.
- Created basic components for task list and user profile.
- Set up routing for the application.
- Implement user authentication and authorization.
- Develop more features for task management.
- Integrate gamification and AI-driven features.
- Set up CI/CD pipelines using GitHub Actions or Jenkins.
Contributions are welcome! Please read the contributing guidelines before submitting a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
-
Inheritance from
AbstractUser
inUser
Model:- Why: To ensure the custom
User
model includes all necessary methods and attributes required by Django's authentication system. - What: Changed the custom
User
model to inherit fromAbstractUser
instead ofmodels.Model
.
- Why: To ensure the custom
-
Field Definitions in
User
Model:- Why: To ensure custom fields like
username
,email
, andpassword
are compatible withAbstractUser
. - What: Defined these fields in the custom
User
model.
- Why: To ensure custom fields like
-
REQUIRED_FIELDS
andUSERNAME_FIELD
inUser
Model:- Why: To specify which fields are required and which field is used for authentication.
- What: Set
REQUIRED_FIELDS
to['email']
andUSERNAME_FIELD
tousername
.
-
AUTH_USER_MODEL
Setting insettings.py
:- Why: To inform Django to use the custom
User
model for authentication and user management. - What: Set
AUTH_USER_MODEL
to'users.User'
.
- Why: To inform Django to use the custom
-
Database Migrations:
- Why: To update the database schema to reflect the changes made to the custom
User
model. - What: Ran
python manage.py makemigrations
andpython manage.py migrate
.
- Why: To update the database schema to reflect the changes made to the custom
-
Added
__str__
Method toTask
Model:- Why: To fix the test failure related to the string representation of the
Task
model. - What: Added the
__str__
method to theTask
model to return thetitle
of the task.
- Why: To fix the test failure related to the string representation of the
- Updated Custom
User
Model: Ensured compatibility with Django's authentication system. - Verified
settings.py
: SetAUTH_USER_MODEL
to use the customUser
model. - Migrated Database: Updated the database schema.
- Fixed
Task
Model Test: Added__str__
method to return thetitle
of the task.
Project Overview: Develop a task manager application with a focus on backend development to improve backend skills. This application will initially be a simple task manager and later evolve into a gamified service.
Objective: Create a robust backend for managing tasks, users, and interactions. Implement a basic frontend to interact with the backend. Expand the project to include gamification and AI-driven features.
Technical Stack:
- Backend Framework: Django (Python)
- Frontend Framework: React (JavaScript)
- Database: PostgreSQL
- API: RESTful APIs
- Version Control: Git
- Development Environment: VS Code with CoPilot
- CI/CD Tools: GitHub Actions or Jenkins
Backend Development Steps:
-
Project Initialization:
- Set up a Git repository for version control.
- Initialize Django project and configure PostgreSQL database.
-
Database Models:
- Define Django models for tasks and users.
- Example:
from django.db import models class User(models.Model): username = models.CharField(max_length=100, unique=True) email = models.EmailField(unique=True) password = models.CharField(max_length=100) class Task(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=255) description = models.TextField() completed = models.BooleanField(default=False) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True)
-
API Development:
- Create RESTful APIs using Django REST Framework.
- Example API views for tasks:
from rest_framework import viewsets from .models import Task from .serializers import TaskSerializer class TaskViewSet(viewsets.ModelViewSet): queryset = Task.objects.all() serializer_class = TaskSerializer
-
User Authentication:
- Implement user registration and authentication.
- Use Django’s built-in authentication system or Django REST Framework’s authentication classes.
-
Frontend Integration:
- Develop React components to interact with backend APIs.
- Example component for listing tasks:
import React, { useState, useEffect } from 'react'; import axios from 'axios'; function TaskList() { const [tasks, setTasks] = useState([]); useEffect(() => { axios.get('/api/tasks/') .then(response => setTasks(response.data)) .catch(error => console.error('Error fetching tasks:', error)); }, []); return ( <div> <h1>Task List</h1> <ul> {tasks.map(task => ( <li key={task.id}>{task.title} - {task.completed ? 'Completed' : 'Pending'}</li> ))} </ul> </div> ); } export default TaskList;
-
Testing and Validation:
- Write unit tests for backend APIs and frontend components.
- Example Django test case:
from django.test import TestCase from .models import Task class TaskModelTest(TestCase): def test_task_creation(self): task = Task.objects.create(title='Test Task', description='Test Description') self.assertEqual(task.title, 'Test Task') self.assertFalse(task.completed)
-
CI/CD Setup:
- Configure GitHub Actions or Jenkins for continuous integration and deployment.
- Example GitHub Actions configuration:
name: CI/CD Pipeline on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.9' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Run tests run: | python manage.py test - name: Deploy run: | echo "Deploying application..." # Add deployment commands here
Future Expansion:
- Add gamification features such as experience points and task ratings.
- Integrate AI for advanced task management and user interaction.
Development Timeline:
- Allocate 1-2 hours daily for development.
- Break down tasks into sprints: project initialization, core functionality, frontend integration, testing, and deployment.
Notes:
- Emphasize backend development for a strong foundation.
- Plan for incremental updates and scalability.