This guide provides step-by-step instructions to set up, run, and verify the Document Versioning System.
Ensure you have the following installed on your machine:
- Node.js (v18 or higher)
- npm (Node Package Manager)
- Docker & Docker Compose (for running PostgreSQL and Redis)
-
Install Dependencies
npm install
-
Start Infrastructure This project uses Docker Compose to manage PostgreSQL and Redis instances.
docker compose up -d
- PostgreSQL runs on port
5432 - Redis runs on port
6379
- PostgreSQL runs on port
-
Environment Variables The project expects a
.envfile in the root directory. A default one should already be present:PG_HOST=localhost PG_PORT=5432 PG_USER=postgres PG_PASSWORD=postgres PG_DATABASE=postgres REDIS_HOST=localhost REDIS_PORT=6379 PORT=3000
Runs the server using ts-node for hot-reloading (if configured) or direct TypeScript execution.
npm run devCompiles the TypeScript code to JavaScript in the dist folder and includes necessary assets (like schema.sql).
npm run build
npm startTo verify that the system correctly handles concurrent version updates (PostgreSQL Row-Level Locking):
- Ensure the server is running (in a separate terminal).
- Run the verification script:
npm run npm:verify
Expected Output:
The script sends 5 parallel update requests. You should see a success message indicating the final version is 6 (1 initial creation + 5 updates).