Skip to content

AudreyW05/Four-Year-Plan-API

Repository files navigation

Class Planner

A NestJS application that allows students to plan their 4-year academic journey at a university. This application manages users, courses, degrees, and their relationships, enabling students to create personalized class schedules based on degree requirements and course prerequisites.

Table of Contents

Features

  • User Management: Create, read, update, and delete users.
  • Course Management: Manage courses with credits and prerequisites.
  • Degree Management: Define degrees with required courses.
  • Relationship Handling: Manage relationships between users, courses, and degrees.
  • Exception Handling: Robust error handling using Prisma exception filters.

Prerequisites

Before you begin, ensure you have met the following requirements:

Installation

Follow these steps to set up and run the project locally.

1. Clone the Repository

Clone this repository to your local machine using Git.

git clone https://github.com/AudreyW05/Four-Year-Plan-API
cd four-year-plan-api

2. Install Dependencies

pnpm install

3. Configure Environment Variables

cp .env.example .env

Open the .env file in your text editor and add the following line:

DATABASE_URL=postgresql://user:password@localhost:5432/class_planner_db?schema=public

Replace the placeholders:

  • user: Your PostgreSQL username.
  • password: Your PostgreSQL password.
  • localhost: Your PostgreSQL host (usually localhost).
  • 5432: Your PostgreSQL port (default is 5432).
  • class_planner_db: The name of your PostgreSQL database.

Ensure that the specified database (class_planner_db) exists. You can create it using PostgreSQL tools like psql or pgAdmin.

4. Set Up the Database

Use Prisma to generate the client and run migrations to set up your database schema.

pnpm prisma generate
pnpm prisma migrate dev --name init

OPTIONAL: Seed the Database

add seed data to the database

pnpm run seed

5. Run the Application

Start the NestJS application in development mode.

pnpm run start:dev

Import the Postman collection to test the API endpoints.

Run the APIs!

Managing Prisma Migrations

This project uses Prisma for database migrations and schema management. The following scripts have been added to the package.json to help you manage incremental migrations:

Prisma Scripts

  • prisma:generate: Generates the Prisma Client based on your Prisma schema. Run this whenever you make changes to your schema.prisma file.
pnpm prisma:generate
  • prisma:migrate:dev: Creates a new migration and applies it to your development database. Use this when you’re developing and want to keep track of schema changes incrementally.
pnpm prisma:migrate:dev --name <migration-name>

Replace <migration-name> with a descriptive name for your migration, such as add-user-table.

  • prisma:migrate:deploy: Applies all pending migrations to the production database. Use this command when deploying your application to ensure the database schema is up to date.
pnpm prisma:migrate:deploy
  • prisma:migrate:status: Checks the status of your migrations, showing which migrations have been applied and which are pending.
pnpm prisma:migrate:status

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •