This repository contains the code-base to the LIVE leaderboard for ACM@Amrita Winter of Code (season 1).
- The application is written in Next.js on top of TypeScript. The framework was chosen as it happened to be the most comfortable one at the disposal of the developers at the time of writing.
- We use a PostgreSQL database hosted on NeonDB for quick setup and serverless hosting. The database automatically scales down to an IDLE or sleep state with 5 minutes of inactivity. This allows us to save on costs.
- Interestingly, you can run a 0.25vCPU Neon Serverless Postgres instance every month, absolutely free of cost (191 hours).
- In order to interact with the database, we have written our schema in Prisma, which is an ORM that integrates easily with SQL and manages connection pooling by itself. It also allows us to write type-safe queries without the fear of common vulnerabilities like SQL injection.
Note
This repository does not have any POST/
endpoint and only serves the leaderboard and individual profiles. Data mutations in the database take place through separate functions deployed on Cloudflare Workers. That repository has been kept private for security reasons.
Before setting up the project, ensure you have the following installed on your machine:
- Node.js (version 16 or higher)
- Yarn (version 1.22 or higher)
- PostgreSQL or NeonDB
Follow these steps to set up the project locally after cloning the repository:
-
Install dependencies:
yarn install
-
Create a copy of the
.env
file:
Tip
Do setup the NODE_ENVIRONMENT
variable to development
so that the database
seeding can take place from prisma/seed.ts
. You can add further records into
the seeds for testing purposes but do not commit it upstream.
-
Set up the database:
- Create a project in NeonDB.
- Copy the connection string provided by NeonDB and paste it into the
DATABASE_URL
field in the.env
file.
-
Push the database schema:
npx prisma db push
-
Seed the database:
npx esrun prisma/seed.ts
-
Run the development server:
yarn run dev
- Write descriptive git commit messages.
- Write clear descriptions in pull requests for quicker merging.
For any queries, please reach out to us on our socials or via email.