Skip to content

ARTMashimbyi/-ConstitutionVault

Repository files navigation

-ConstitutionVault

Constitution Vault

codecov Your project description goes here.

πŸ“š Constitution Vault - Frontend

This is the frontend for Constitution Vault, a document management web application


πŸš€ Features

  • πŸ“‚ Upload documents with metadata (name, writer, year, subject)
  • πŸ” Search documents by title, writer, or subject
  • πŸ“„ View documents inline (PDF rendering)
  • πŸ—‘οΈ Select and delete one or more documents
  • 🎨 Clean, modern UI with sidebar navigation

🧱 Folder Structure

public/
β”œβ”€β”€ index.html         # Main homepage
β”œβ”€β”€ add.html           # Upload document page
β”œβ”€β”€ read.html          # Inline PDF viewer
β”œβ”€β”€ style.css          # UI styles
β”œβ”€β”€ index.js           # Logic for fetching, searching, deleting
β”œβ”€β”€ add.js             # Handles file uploads
β”œβ”€β”€ read.js            # Displays PDFs
└── assets/            # (Optional) UI images, logos

πŸ”§ Requirements

  • A running backend API (http://localhost:3000) connected to your Azure SQL database.
  • PDF documents are uploaded and stored as binary in the backend.

πŸ› οΈ Setup Instructions

  1. Clone the Repository
git clone https://github.com/your-username/constitution-vault-frontend.git
cd constitution-vault-frontend
  1. Install Dependencies

Make sure you have Node.js and npm installed. Then run:

npm install
  1. Run the Development Server

To start the frontend application, run:

npm start

This will start the app on http://localhost:3000, assuming your backend is running on that address.


πŸ§ͺ Running Tests

This project uses Jest for testing. Follow the steps below to run the tests:

  1. Install Testing Dependencies

Make sure you have Jest installed by running:

npm install --save-dev jest jest-environment-jsdom
  1. Run Tests

To run tests with code coverage, run:

npx jest --coverage

This will run all the tests and generate a code coverage report.

  1. View the Test Results

Once the tests complete, you'll see the output in your terminal, indicating whether the tests passed and the coverage details.


πŸ“ Pages

  • index.html – Lists all uploaded books and allows searching & deleting.
  • add.html – Form to upload a new book and PDF file.
  • read.html?id=1 – View PDF inline based on book ID from URL.

πŸ”„ API Endpoints Used

The frontend makes requests to the following backend routes:

Method Endpoint Description
GET /books Fetch all books
POST /upload Upload new document
GET /books/:id/document Fetch PDF for a book
DELETE /books/:id Delete a book by ID

✨ Code Coverage

codecov

Coverage information is uploaded to Codecov, and you can view detailed reports there.