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.
- Features
- Prerequisites
- Installation
- Available Scripts
- Project Structure
- API Endpoints
- Contributing
- License
- 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.
Before you begin, ensure you have met the following requirements:
- Node.js: Version 14 or higher. Download Node.js
- pnpm: Fast, disk space-efficient package manager. Install pnpm
- PostgreSQL: Install and set up PostgreSQL. Download PostgreSQL
- Git: For version control and cloning the repository. Download Git
Follow these steps to set up and run the project locally.
Clone this repository to your local machine using Git.
git clone https://github.com/AudreyW05/Four-Year-Plan-API
cd four-year-plan-api
pnpm install
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.
Use Prisma to generate the client and run migrations to set up your database schema.
pnpm prisma generate
pnpm prisma migrate dev --name init
add seed data to the database
pnpm run seed
Start the NestJS application in development mode.
pnpm run start:dev
Import the Postman collection to test the API endpoints.
Run the APIs!
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:generate
: Generates the Prisma Client based on your Prisma schema. Run this whenever you make changes to yourschema.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