Files
borrow-system/README.md
2025-08-19 19:42:11 +02:00

5.8 KiB
Raw Blame History

Borrow System

React TypeScript Vite TailwindCSS Node.js Express MySQL Docker JWT

A small fullstack system to log in, view available items, reserve them for a time window, and manage personal loans.

  • Frontend: React + TypeScript + Vite + Tailwind CSS
  • Backend: Node.js + Express + MySQL + JWT (jose)
  • Orchestration: Docker Compose (backend + MySQL)

Contents

Features (highlevel)

  • Auth via JWT (login -> token cookie) using the backend route in backend/routes/api.js.
  • After login, the app loads items, loans, and user loans and keeps them in localStorage.
  • Choose a date range to fetch borrowable items, select items, and create a loan.
  • Manage personal loans list (and delete a loan).

Key frontend utilities:

UI flow (main screens):

Quick start

You can run the backend + MySQL via Docker, and run the frontend locally.

1) Environment

Root .env (used by docker-compose):

DB_PASSWORD=yourStrongPassword

Backend .env (used by Node in the backend container or local dev):

# DB (only needed for local dev; in Docker these are provided by compose)
DB_HOST=mysql
DB_USER=root
DB_PASSWORD=yourStrongPassword
DB_NAME=borrow_system

# Security
SECRET_KEY=yourVerySecretJwtKey
ADMIN_ID=yourAdminApiKey

2) Start backend + DB (Docker)

From the repo root:

docker compose up -d

Initialize schema and mock data in MySQL:

# copy schema into the mysql container
docker cp backend/scheme.sql borrow_system-mysql:/scheme.sql

# run it
docker exec -i borrow_system-mysql sh -c 'mysql -u root -p"$MYSQL_ROOT_PASSWORD" borrow_system < /scheme.sql'

3) Run the frontend (local)

cd frontend
npm install
npm run dev

The frontend expects the backend on http://localhost:8002 (see fetches in frontend/src/utils/fetchData.ts and frontend/src/utils/userHandler.ts).

Development

Configuration notes

API documentation

Do not use this README for API details. Refer to the dedicated API docs:

  • Web/API