This is a repo for the bachelor's degree project in Computer Science at the Norwegian University of Science and Technology (NTNU). The project is a full-stack application for creating, managing, and validating JSON configuration files.
- Next.js - A React-based framework for building server-rendered or statically-exported React applications.
- NextAuth - A complete open-source authentication solution for Next.js applications.
- TypeScript - A superset of JavaScript that adds static typing.
- Prisma - An open-source next-generation ORM for Node.js and TypeScript.
- tRPC - An end-to-end type-safe RPC library for building APIs with TypeScript and Node.js.
- Chakra UI - A simple, modular and accessible component library for building React applications.
- AJV - A JSON Schema validator for JavaScript.
- Yarn - A fast, reliable, and secure dependency management tool.
- Vercel - A platform for deploying and scaling frontend web projects.
To get a local copy up and running follow these simple steps.
This is a list of things you need in order to use this application.
- Node.js 16
- Yarn 1 (Classic)
Via HTTPS:
git clone https://github.com/nilssen98/bachelor-project.git
Via SSH:
git clone [email protected]:nilssen98/bachelor-project.git
or download it directly as a zip from here.
- Head to https://bachelor-project-rose.vercel.app/
to see the website in operation.
This is the preferred method.
- Make sure you have installed Node.js and Yarn on the system.
- Download and the extract zip-file or clone project to the desired location as specified in the "Downloading the project" section.
- Run the command
yarn install
in the project root. - Copy the env.example file in this directory to .env.development (which will be ignored by Git):
cp env.example .env.development
- Fill in the secrets for all the providers in the .env.development file.
- Run the command
yarn dev
in the project root. - The website should then be available at http://localhost:3000
You can deploy this project with Docker.
- Make sure you have Docker installed on your system.
- Copy and fill in the secrets for all the providers in the .env.production file like mentioned in the "Locally" section.
- Run the following command in the project root:
Or just rebuild the project without touching the database:
docker compose up
docker-compose up --build app
- The website should then be available at http://localhost:3000
Other useful commands:
-d
Detached mode: Run containers in the background
Example files for the schema and a configuration can be found in the docs/examples directory.
When setting up a new project, you need to run this command once to generate the Prisma Client. This generates the Prisma Client APIs that allow you to interact with the database.
yarn prisma generate
To sync the database schema with the Prisma schema, run the following command:
yarn prisma db push
This command should be used after creating a new database or after making any changes to the schema.prisma
file.
Prisma sometimes refuses to correctly read the environment variables, so we included a script that uses dotenv-cli
to read the environment variables from the correct .env
file.
One needs to have dotenv-cli
installed globally to use this script.
yarn db:push
The following is our database schema:
We have included Postman tests for the /api/validate
endpoint.
These tests can be found in the docs/postman directory.
Here is an example of how to use the /api/validate
endpoint with Postman:
- Open Postman and create a new request.
- Set the HTTP method to
POST
. - Enter the URL of your endpoint in the request URL field.
- Select the
Body
tab. - Select the
raw
option. - Select
JSON
as the format. - Enter the JSON object you want to validate in the text area like shown below.
{ "configuration": "Your configuration here as a string", "schema": "Your schema here as a string" }
- Click the
Send
button to send the request.
Keep in mind that this endpoint takes in a JSON object as a string, so you need to escape the quotes in the JSON object.
This is a T3 Stack project bootstrapped with create-t3-app
.