A full-stack application for tracking work hours with PostgreSQL database, Node.js backend, and React frontend.
This application is fully containerized and can be run using Docker and Docker Compose.
-
Clone this repository:
git clone <repository-url> cd work-hours-tracker
-
Start the application:
docker-compose up -d
-
Access the application:
- Frontend: http://localhost:80
- Backend API: http://localhost:3001/api
The application consists of three main services:
-
Database (PostgreSQL)
- Persists data in a named volume
- Automatically runs initialization scripts to create tables
- Accessible on port 5432 (if needed for direct access)
-
Backend (Node.js)
- RESTful API built with Express
- JWT authentication
- Connected to the database service
- Exposed on port 3001
-
Frontend (React)
- Single page application built with React
- Served by Nginx
- Exposed on port 80
The following environment variables can be modified in the docker-compose.yml file:
POSTGRES_USER
: Database username (default: user)POSTGRES_PASSWORD
: Database password (default: password)POSTGRES_DB
: Database name (default: workhours)
DB_HOST
: Database host (default: db)DB_USER
: Database username (default: user)DB_PASSWORD
: Database password (default: password)DB_NAME
: Database name (default: workhours)DB_PORT
: Database port (default: 5432)PORT
: Backend port (default: 3001)
VITE_API_URL
: Backend API URL (default: http://localhost:3001/api)
For local development without Docker:
- Database: Set up a PostgreSQL database and run the scripts in
database/tables.sql
. - Backend: Navigate to the
backend
directory, install dependencies withnpm install
, and start withnpm run dev
. - Frontend: Navigate to the
frontend
directory, install dependencies withnpm install
, and start withnpm run dev
.
The PostgreSQL database data is stored in a Docker volume named pgdata
, ensuring that your data persists across container restarts.