MeetCode is a fun open-source project that serves as an alternative to LeetCode. It is built using Next.js with Tailwind CSS for the frontend and Prisma as the ORM (Object-Relational Mapping) tool. The project utilizes PostgreSQL as its database, which is hosted on Supabase. The application is deployed on Vercel.
To run MeetCode locally on your machine, follow these steps:
-
Clone the repository:
git clone https://github.com/DebasishBarai/meetcode.git
-
Navigate to the project directory:
cd meetcode -
Install the dependencies:
npm install
-
Environment Variables
To run this project, you will need to create .env file in your root dirctory
Duplicate
.env.exampleto.envUse
openssl rand -base64 32to generate a key and add it underNEXTAUTH_SECRETwhich is a string in the.envfileNEXTAUTH_URLwhich is the base url of your project. In development, it is to be kept as http://localhost:3000DATABASE_URLwhich is the postgresql database url -
Set up the database connection from scratch:
-
Delete the
prismafolder in therootdirectory and also delete theprisma.tsfile in thelibfolder. You are going to set up prisma yourself. -
Create a PostgreSQL database. Recommended to use a dockerize postgress image for creating database.
-
Run
docker run --rm -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres
to set up the initial postgres database server
-
Initialize prisma with command
npx prisma init
-
Now, you may notice that a prisma schema file
schema.prismais created in the prisma folder.Copyandpastetheschema.prismafile data from the github repo. -
Modify the
.envfile withDATABASE_URL="postgresql://postgres@localhost:5432/postgres?schema=public" -
Run prisma database migrations
npx prisma migrate dev --name init
-
Create the seed file
seed.tsin theprismafolder.Copyandpastetheseed.tsfile data from the github repo. -
Make sure you have the
prisma seedscript in thepackage.jsonfile."prisma": { "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts" },
-
Make sure you have the
ts-nodeinstalled in thedevDependenciessection inpackage.jsonfile. -
Run the command to seed the database
npx prisma db seed
-
Now, you create a new file
prisma.tsin thelibfolder.Copyandpastetheprisma.tsfile data from the github repo.
-
-
Start the development server:
npm run dev
-
Access MeetCode by visiting http://localhost:3000 in your browser.
Once you have MeetCode up and running, you can visit the website URL provided here to start using the application. It provides a LeetCode-like experience, allowing you to solve coding problems, practice algorithms, and enhance your programming skills.
We welcome contributions from the community to improve MeetCode. To contribute, please follow these guidelines:
-
Fork the repository.
-
Create a new branch for your feature or bug fix.
-
Make your changes and commit them with descriptive messages.
-
Push your branch to your forked repository.
-
Submit a pull request to the main repository.
MeetCode is licensed under the MIT License.