Skip to content

Weekend Project. Simple fullstack app using Next.js for hashing column names of SQL Query.

License

Notifications You must be signed in to change notification settings

ahmad-alkadri/sql-hasher-app

Repository files navigation

SQL Query Hasher App

Description

This is a Next.js project bootstrapped with create-next-app. It provides a web interface for hashing SQL query column names. It features a SQLite database to store and manage the hashed column names, an API for hashing queries, and a front-end for user interactions. The application allows users to input SQL queries, returns queries with hashed column names, and provides the ability to view and delete entries in the database.

A weekend project. Full blog about it will follow soon!

Getting Started

Prerequisites

  • Node.js (minimum v18 for compatibility with latet Next.js)
  • Docker and Docker Compose (for deployment)

Cloning the Repository

To clone the project and get started, run the following commands:

git clone https://github.com/ahmad-alkadri/sql-hasher-app.git
cd sql-hasher-app

Installation and Dev Mode

To install all necessary Node.js packages, simply run:

npm install

And finally, to run the application in Development mode:

npm run dev

This will start the Next.js development server, by default accessible at http://localhost:3000.

Development

Making Code Changes

Just like typical Next.js app, the structure of the application is as follows:

  • pages/api: Contains the API endpoints, including hashing logic and database interactions
  • pages/index.js: The main front-end component of the application.
  • Additional utility scripts and components as needed.

Running Tests

This project uses Jest for unit testing. To run the tests:

npm test

The tests cover:

  • API endpoints functionality (hashing and database interactions).
  • hashAllColumnRefObjects function correctness.

More test cases will follow. You're also free to contribute to more test cases.

Deployment

Currently there's only one mode of deployment, that is, using Docker Compose for local deployment.

Deploying with Docker Compose

  1. Build the Docker image:
docker-compose build
# For new build without cache at all: 
# `docker-compose build --no-cache`
  1. Start the application:
docker-compose up -d # In detached mode

The two commands above will build the Docker image, run tests, and if successful, start the application. The app will be accessible at http://localhost:3000 or the respective host's IP address.

  1. Stop the application:
docker-compose down
  1. Remove docker containers completely (optional):
docker-compose down --rmi all -v