This repository contains the source code for iNIcio, the recruitment platform for the Núcleo de Informática da AEFEUP (NIAEFEUP). It is built with Next.js for the frontend and backend logic, and uses Drizzle ORM with a PostgreSQL database for data management.
Follow these steps to get the project running locally:
This will also automatically register the pre-commit hook that formats your code on commit.
npm install
Make sure you have Docker installed. Then, run the following command to start the PostgreSQL database:
docker compose up -d
Copy the .env.example
file to .env
and fill in the required environment variables:
cp .env.example .env
Edit the .env
file to set your database connection string and other necessary configurations.
This will apply the current schema to the running PostgreSQL container.
npx drizzle-kit push
Run the following command to start the Next.js development server:
npm run dev
# Format code manually
npm run format:fix
# Run lint checks
npm run lint
# Start & stop the PostgreSQL database
docker compose down
docker compose up -d
# Push the schema to the database
npx drizzle-kit push
The project uses Drizzle ORM with a PostgreSQL database for managing and querying data.
src/
└── db/
├── db.ts # Initializes the Drizzle instance
└── schema/ # Contains schema definition files (tables, relations, enums)
├── index.ts # Aggregates all schema definitions
├── interview.ts
├── recruitment.ts
└── ...
The db.ts
file initializes the Drizzle ORM instance and connects to the PostgreSQL database using the connection string defined in the .env
file.
import { drizzle } from "drizzle-orm/node-postgres";
import * as schema from "./schema";
export const db = drizzle(process.env.DATABASE_URL!, { schema });
This ensures the app reuses a single database connection and schema reference instead of re-creating it in multiple places.
You can import the database like so:
import { db } from "@/db/db";
-
All database tables and relationships are defined inside
src/db/schema/
as individual.ts
files. -
Each file exports one or more tables (or enums, views, etc.).
-
There's an
index.ts
file insideschema/
that re-exports everything. This is required so Drizzle can register the full schema when initializing.
Whenever you create a new file inside schema/
, make sure to add its exports to index.ts.
Once the website is in production, you should not edit existing schema files directly. Instead, use Drizzle migrations to apply changes.