Skip to content

DeveshDFG/amaranth-codify-platform

Repository files navigation

Amaranth Codify Platform

Svelte Vite Docker Prisma Postgres TypeScript pnpm

Setup

  1. Clone the repository to your local machine.
  2. Make sure you have Node.js installed. You can find instructions to install it from nodejs.org.
  3. Install pnpm if you haven't already. You can find instructions here.
  4. Install Docker from docker.com and ensure it's running.
  5. Navigate to the project directory in your terminal.
  6. Run ./setup_env.sh to create a .env with the necessary environment variables. If you need to reset or wipe the database due to changes in environment variables, see the Emptying the Database section below.
  7. Run the following command to install the dependencies so your editor can resolve them:
    pnpm install
  8. Build the Docker images and start the services:
    docker-compose up

Open your browser and go to http://localhost:8000 to access the application. Hot Module Replacement (HMR) should be working, so any changes you make to the code will automatically refresh the browser.

For subsequent runs, you can simply use the same command, skiping the build step if there are no changes to docker-compose.yaml. But if there are build changes, such as new dependencies or Dockerfile changes, you should run:

docker-compose up --build

so that the images are rebuilt and dependencies are installed.

Database

The application uses PostgreSQL as the database, and Prisma as the ORM. The database is set up and managed through Docker. User authentication is handled using BetterAuth, so it is recommended to not change user data through Prisma directly.

Editing database schema

The schema files are in ./prisma/schema/. Opt to use multiple schema files for better organization.

After making changes to the schema, run:

docker-compose exec web pnpm db:migrate

This will apply the migrations to the database. Make sure to push the migration files to the repository.

If there are migrations pulled from the repository that haven't been applied to your local database, run:

docker-compose exec web pnpm db:migrate:deploy

This will apply any pending migrations to the local database without processing any schema changes that potentially conflict with unapplied migrations.

Seeding

Seeding the database is helpful for populating it with initial data for development or testing purposes. To seed the database, run:

docker-compose exec web pnpm db:seed

Database Management

You can use the Prisma CLI to interact with the database. For example, to open the Prisma Studio, run:

docker-compose exec web pnpm db:studio

and navigate to http://localhost:5555 in your browser.

If there is a specific Prisma command you want to run, you can do so by executing:

docker-compose exec web pnpm prisma <command>

Emptying the Database

If you need to reset the database to its initial state, you can drop all tables and reapply the migrations. Be cautious, as this will delete all data in the database. Resetting the database is easily done by deleting the docker volume that stores the database data. You can do this by running:

docker-compose down -v

Then, start the services again with:

docker-compose up

and apply the migrations again with:

docker-compose exec web pnpm db:migrate

Contributing

There are pre-commit hooks set up to ensure code quality and consistency, which will format your code and check commit messages before each commit.

Commit messages must follow the format:

<type>(<scope>): <subject>

Where:

  • <type> is one of the following: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test.
  • <scope> is an optional scope of the change (e.g., component or file name).
  • <subject> is a brief description of the change.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •