TAAFT
Free mode
100% free
Freemium
Free Trial
Deals

azurespheredev / GridUnity-Assessment

1 0 Language: TypeScript Updated: 4mo ago

README

GridUnity Take Home Assessment Solution

๐Ÿš€ Features Implemented

  • Access directories using snapshot, list, restore, prune operations
  • Enhance list operation to include additional disk-usage metrics
  • Implement a check operation that scans the database for any corrupted file
    content
  • Use chunking to de-duplicate storage at a more fine-grained level
  • GraphQL APIs to test out via tools like Postman

๐Ÿ“ฆ Architecture

.
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ config/                 # Database configuration files
โ”‚   โ”œโ”€โ”€ entities/               # Database entity definitions
โ”‚   โ”œโ”€โ”€ graphql/
โ”‚   โ”‚   โ””โ”€โ”€ resolvers/          # GraphQL resolvers
โ”‚   โ”œโ”€โ”€ helpers/                # CLI & server helpers
โ”‚   โ”œโ”€โ”€ utils/                  # Utility modules (hashing, chunking, etc.)
โ”‚   โ”œโ”€โ”€ app.ts                  # Entry point for the Koa + Apollo server
โ”‚   โ””โ”€โ”€ database.ts             # Database connection setup
โ”œโ”€โ”€ tests/                      # Comprehensive integration & unit tests
โ”œโ”€โ”€ database.sqlite             # SQLite database file (generated)
โ”œโ”€โ”€ package.json                # Project dependencies & scripts
โ””โ”€โ”€ tsconfig.json               # TypeScript configuration

โš™๏ธ Technologies

  • Node.js / TypeScript
  • GraphQL (Apollo)
  • TypeORM (SQLite Database)
  • Koa Framework
  • Jest (Testing Framework)

โœ… Prerequisites

  • Node.js (20.x or later recommended)
  • npm or yarn (preferred)

๐Ÿ›  Installation

  1. Clone Repository

    git clone https://github.com/azurespheredev/GridUnity-Assessment
    cd GridUnity-Assessment
  2. Install Dependencies

    yarn install
  3. Environment Setup

    Create a .env file (for development):

    NODE_ENV=development
    PORT=4000
  4. Register Environment Variable (Windows OS)

    Make sure you have these dependencies installed globally

    npm i -g ts-node typescript

    And add <your absolute folder path>/scripts/windows to PATH in environment variable settings.

โ–ถ๏ธ Usage

In the root directory of the project, run the following:

Snapshot a Directory

backuptool snapshot --target-directory=./data

List Snapshots

backuptool list

Example Output:

SNAPSHOT  TIMESTAMP                FILE                SIZE        DISTINCT_SIZE
1         2025-03-31 10:58:31.000  data_001.txt        2750        2750
1         2025-03-31 10:58:31.000  data_002.txt        2727        2727
1         2025-03-31 10:58:31.000  data_003.txt        1855        1855
total                                                  7332

Restore a Snapshot

backuptool restore --snapshot-number=1 --output-directory=./out

Prune a Snapshot

backuptool prune --snapshot=1

Check Data Integrity

backuptool check

๐Ÿงช Running Tests

yarn test
๐Ÿงช GraphQL Resolver Tests:
   โˆš List snapshots returns correct snapshot details (564 ms)
   โˆš Get snapshot by ID returns correct snapshot (29 ms)
   โˆš Create snapshot from the specific directory (23 ms)
   โˆš Restore snapshot to new directory (20 ms)
   โˆš Snapshotting twice without changes should not duplicate chunk content (24 ms)
   โˆš Pruning snapshot does not affect others (40 ms)

Test Suites: 1 passed, 1 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        5.325 s

Tests cover snapshot creation, chunk-based deduplication, restores, pruning safety, and integrity verification.

0 AIs selected
Clear selection
#
Name
Task