Skip to content

Set up NestJS Scaffold and Project Folder Structure #31

@phertyameen

Description

@phertyameen

Initialize the SafeGig backend using NestJS with a modular folder structure that supports scalability, Postgres integration, and future smart contract interaction. This will serve as the foundation for all upcoming modules (Auth, Jobs, Escrow, Messaging, etc.).

Tasks:

Initialize NestJS project

Run nest new backend (or equivalent) with TypeScript.

Set up ESLint + Prettier for consistent code style.

Add .env.example for environment variables.

Install core dependencies

@nestjs/config for environment config.

@nestjs/typeorm + pg for Postgres integration.

@nestjs/axios for external requests.

cache-manager + @nestjs/cache-manager (for Redis later if needed).

@nestjs/passport, passport-jwt, jsonwebtoken for authentication.

ethers or viem for blockchain interactions.

class-validator + class-transformer for DTO validation.

Define base folder structure

src/
├── modules/
│   ├── auth/
│   ├── jobs/
│   ├── escrow/
│   ├── messaging/
│   ├── users/
│   ├── notifications/
│   └── files/
├── common/        # shared decorators, interceptors, guards
├── config/        # env configs, DB configs
├── database/      # migrations & entities
├── utils/         # helpers (e.g. signature verification)
├── main.ts        # bootstrap
└── app.module.ts  # root module

Configure environment variables
Add .env.example with placeholders for:

DATABASE_URL=postgres://user:password@localhost:5432/safegig

JWT_SECRET=your-secret-key

BLOCKCHAIN_RPC=http://127.0.0.1:8545

Set up database connection

Configure TypeORM with Postgres.

Create a sample entity (e.g., User) + migration.

Verify DB connection works with npm run start:dev.

Acceptance Criteria:

✅ NestJS project scaffold created and runs without errors.

✅ ESLint + Prettier enforce formatting rules.

✅ Environment variables load via @nestjs/config.

✅ Postgres connection is established and tested with a sample entity.

✅ Folder structure matches agreed modular layout.

Notes for Contributors:

Keep modules empty for now — just create folder placeholders.

This is a prerequisite step; do not implement Auth/Jobs/Contracts yet.

Ensure project compiles and runs cleanly.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions