Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TaskManager

πŸ“‹ About

TaskManager is a full-stack task management application designed to help users organize, track, and manage their daily tasks efficiently. The project demonstrates modern web development practices with a React frontend, Node.js/Express backend, and PostgreSQL database, all containerized with Docker for easy deployment and development.

This application solves the common problem of task organization by providing a clean, intuitive interface for creating, updating, and tracking tasks with proper authentication and data persistence.

πŸš€ Technologies

  • Frontend: React 18, React Router, Axios
  • Backend: Node.js, Express, PostgreSQL (pg library)
  • Authentication: JWT tokens, bcrypt for password hashing
  • Database: PostgreSQL 15
  • Containerization: Docker, Docker Compose
  • Testing: Jest, Supertest
  • Development: Git, npm

πŸ“¦ Installation

Prerequisites

  • Node.js (v18 or higher)
  • Docker and Docker Compose
  • Git

Quick Start with Docker

  1. Clone the repository:
git clone <repository-url>
cd TaskManager
  1. Start all services with Docker Compose:
docker-compose up -d

This will:

  • Start PostgreSQL database
  • Run database migrations
  • Start the Express API server
  • Start the React development server
  1. Access the application:
  • Frontend: http://localhost:3000
  • Backend API: http://localhost:5000/api
  • Health check: http://localhost:5000/health

Manual Setup (Without Docker)

  1. Install dependencies:
# Root dependencies
npm install

# Server dependencies
cd server
npm install

# Client dependencies
cd ../client
npm install
  1. Set up PostgreSQL database:
# Create database
createdb taskmanager

# Or using psql
psql -U postgres
CREATE DATABASE taskmanager;
  1. Configure environment variables:
cd server
cp .env.example .env
# Edit .env with your database credentials and JWT secret
  1. Run database migrations:
cd server
npm run migrate
  1. Start the servers:
# Terminal 1 - Backend
cd server
npm run dev

# Terminal 2 - Frontend
cd client
npm start

πŸ’» Usage

Getting Started

  1. Register a new account: Navigate to the register page and create an account with your email and password (minimum 6 characters).

  2. Login: Use your credentials to log in to the application.

  3. Create tasks: Use the task form on the dashboard to create new tasks with a title and optional description.

  4. Manage tasks:

    • Toggle task completion by clicking the checkbox
    • Edit tasks by clicking the "Edit" button
    • Delete tasks by clicking the "Delete" button

API Endpoints

Authentication

  • POST /api/auth/register - Register a new user

    {
      "email": "user@example.com",
      "password": "password123"
    }
  • POST /api/auth/login - Login user

    {
      "email": "user@example.com",
      "password": "password123"
    }

Tasks (Requires Authentication)

  • GET /api/tasks - Get all tasks for authenticated user
  • GET /api/tasks/:id - Get a specific task
  • POST /api/tasks - Create a new task
    {
      "title": "Task title",
      "description": "Task description (optional)"
    }
  • PUT /api/tasks/:id - Update a task
    {
      "title": "Updated title",
      "description": "Updated description",
      "completed": true
    }
  • DELETE /api/tasks/:id - Delete a task

All task endpoints require a Bearer token in the Authorization header:

Authorization: Bearer <your-jwt-token>

πŸ—οΈ Project Structure

TaskManager/
β”œβ”€β”€ client/                      # React frontend application
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   β”‚   └── index.html
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/          # Reusable React components
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthForm.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Layout.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.js
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.js
β”‚   β”‚   β”‚   β”œβ”€β”€ TaskForm.js
β”‚   β”‚   β”‚   β”œβ”€β”€ TaskItem.js
β”‚   β”‚   β”‚   └── TaskList.js
β”‚   β”‚   β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”‚   β”‚   β”œβ”€β”€ useAuth.js
β”‚   β”‚   β”‚   └── useTasks.js
β”‚   β”‚   β”œβ”€β”€ pages/               # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.js
β”‚   β”‚   β”‚   └── Register.js
β”‚   β”‚   β”œβ”€β”€ services/            # API service layer
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js
β”‚   β”‚   β”‚   └── tasks.js
β”‚   β”‚   β”œβ”€β”€ App.js               # Main App component
β”‚   β”‚   β”œβ”€β”€ index.js             # Entry point
β”‚   β”‚   └── index.css            # Global styles
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ server/                       # Express backend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/              # Configuration files
β”‚   β”‚   β”‚   β”œβ”€β”€ config.js        # Environment config
β”‚   β”‚   β”‚   └── database.js      # Database connection
β”‚   β”‚   β”œβ”€β”€ db/                  # Database files
β”‚   β”‚   β”‚   β”œβ”€β”€ schema.sql       # Database schema
β”‚   β”‚   β”‚   └── migrations.js    # Migration script
β”‚   β”‚   β”œβ”€β”€ middleware/          # Express middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js          # JWT authentication
β”‚   β”‚   β”‚   └── validation.js    # Input validation
β”‚   β”‚   β”œβ”€β”€ models/              # Data models
β”‚   β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   β”‚   └── Task.js
β”‚   β”‚   β”œβ”€β”€ routes/              # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js
β”‚   β”‚   β”‚   └── tasks.js
β”‚   β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   β”‚   β”‚   └── errors.js        # Error handling
β”‚   β”‚   └── index.js             # Express app entry point
β”‚   β”œβ”€β”€ tests/                   # Test files
β”‚   β”‚   β”œβ”€β”€ auth.test.js
β”‚   β”‚   β”œβ”€β”€ tasks.test.js
β”‚   β”‚   └── setup.js
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yml            # Docker Compose configuration
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
└── ARCHITECTURE.md

πŸ§ͺ Testing

Run backend tests:

cd server
npm test

Run tests in watch mode:

cd server
npm run test:watch

πŸ”§ Environment Variables

Server (.env)

PORT=5000
NODE_ENV=development

DB_HOST=localhost
DB_PORT=5432
DB_USER=taskmanager
DB_PASSWORD=taskmanager
DB_NAME=taskmanager

# Or use connection string
DATABASE_URL=postgresql://taskmanager:taskmanager@localhost:5432/taskmanager

JWT_SECRET=your-secret-key-change-in-production
JWT_EXPIRES_IN=7d

Client

The client uses environment variables for API URL (optional):

REACT_APP_API_URL=http://localhost:5000/api

πŸš€ Development

Running in Development Mode

With Docker:

docker-compose up

Without Docker:

# Terminal 1 - Backend
cd server
npm run dev

# Terminal 2 - Frontend
cd client
npm start

Database Migrations

Run migrations manually:

cd server
npm run migrate

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages