# Getting Started with Project Progress Tracker

This guide will help you set up and run the Project Progress Tracker application on your local machine for development and testing purposes.

## Prerequisites

Before you begin, make sure you have the following installed:

- **Node.js** (v14.x or later)
- **npm** (v6.x or later)
- **PostgreSQL** (v12.x or later)
- **Git** (for version control)

## Initial Setup

1. **Clone the repository**

```bash
git clone <repository-url>
cd ProjectProgressTracker
```

2. **Set up the database**

Start the PostgreSQL service:

```bash
sudo service postgresql start
```

Create a database for the application:

```bash
createdb project_tracker
```

Initialize the database schema:

```bash
psql -d project_tracker -f backend/src/config/init.sql
```

3. **Configure environment variables**

For the backend, create a `.env` file in the `/backend` directory:

```bash
PORT=5000
DB_USER=postgres
DB_HOST=localhost
DB_NAME=project_tracker
DB_PASSWORD=postgres
DB_PORT=5432
JWT_SECRET=your_jwt_secret_key_change_in_production
CORS_ORIGIN=http://localhost:3000
```

For the frontend, create a `.env` file in the `/frontend` directory:

```bash
REACT_APP_API_URL=http://localhost:5000/api
```

4. **Install dependencies**

For the backend:

```bash
cd backend
npm install
```

For the frontend:

```bash
cd frontend
npm install
```

## Running the Application

### Quick Start (using the development script)

The easiest way to start both frontend and backend servers is using the provided script:

```bash
# Make sure the script is executable
chmod +x run-dev.sh

# Run the development servers
./run-dev.sh
```

This script will:
- Check if PostgreSQL is running
- Create the database if it doesn't exist
- Start the backend server at http://localhost:5000
- Start the frontend server at http://localhost:3000

### Manual Start

If you prefer to start the servers manually:

For the backend:

```bash
cd backend
npm run dev
```

For the frontend (in a separate terminal):

```bash
cd frontend
npm start
```

## Default Admin Access

The application comes with a default super admin account:

- **Email**: admin@projecttracker.com
- **Password**: password123

**Important**: Change the default admin password immediately after the first login for security reasons.

## Using the Application

1. **Login** using the default admin credentials
2. **Create Projects** from the dashboard
3. **Update project progress** as tasks are completed
4. **Share projects** with external stakeholders using the share link feature

## Docker Deployment

To deploy the application using Docker:

```bash
# Build the Docker images
docker-compose build

# Start the containers
docker-compose up -d
```

Access the application at http://localhost

## Troubleshooting

### Database Connection Issues

If you encounter database connection problems:

1. Ensure PostgreSQL is running: `pg_isready`
2. Verify database credentials in the `.env` file
3. Check that the database exists: `psql -l`

### API Connection Issues

If the frontend can't connect to the backend API:

1. Ensure backend server is running at http://localhost:5000
2. Verify the REACT_APP_API_URL in the frontend .env file
3. Check for CORS issues in browser console

### Authentication Issues

If you can't log in:

1. Verify that you're using the correct credentials
2. Check if the JWT_SECRET in the backend .env file is properly set
3. Ensure the database has been initialized with the default admin user

## Next Steps

1. Create additional admin and guest users
2. Create your first project
3. Share project links with stakeholders
4. Explore the user management features (Super Admin only)

For any additional questions or issues, please refer to the project documentation or raise an issue in the project repository.
