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 installMake sure you have Docker installed. Then, run the following command to start the local services (PostgreSQL, MinIO, and the websocket server):
docker compose up -dThis also provisions the local S3 bucket: after MinIO starts, the one-shot createbuckets service creates a bucket named after S3_BUCKET (default inicio, see .env). The MinIO console is available at http://localhost:9001 (login inicio / inicio123).
Copy the .env.example file to .env and fill in the required environment variables:
cp .env.example .envEdit the .env file to set your database connection string and other necessary configurations.
This will apply the current schema to the running PostgreSQL container.
npm run db:pushRun 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
npm run db:pushThe 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.tsfiles. -
Each file exports one or more tables (or enums, views, etc.).
-
There's an
index.tsfile 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.
The TypeScript schema in src/db/schema/ is the single source of truth, and changes are shipped as versioned SQL migrations generated by Drizzle Kit. The SQL lives in drizzle/ and is committed. The production container runs the bundled migrate.cjs runner on startup. It uses the same Drizzle migrator, reads the committed SQL from drizzle/, and applies each migration exactly once without requiring the full development dependency tree in the runtime image.
To change the database:
-
Edit the relevant file(s) in
src/db/schema/(and re-export anything new fromindex.ts). -
Generate a migration:
npm run db:generate
-
Review the generated SQL in
drizzle/before committing. -
Apply the migrations:
npm run db:migrate
npm run db:push still exists for local databases, but do not use it on the shared/production database — it bypasses the migration history and can prompt interactively.