Skip to content

Latest commit

 

History

History
154 lines (112 loc) · 4.71 KB

README.md

File metadata and controls

154 lines (112 loc) · 4.71 KB

SafeSwap Backend 🚀

A robust backend service built with NestJS, supporting the SafeSwap marketplace's API, business logic, and blockchain integration.

Tech Stack 🛠

Prerequisites 🔧

Before starting, ensure you have the following installed:

Docker Desktop (Required)

☑️ NestJS CLI (Optional, for easier development)

To install NestJS CLI, run:

npm install -g @nestjs/cli

Project Structure 📁

backend/
├── prisma/             # Prisma schema and migrations
│   ├── schema.prisma   # Database schema
├── src/
│   ├── core/           # Global configuration (Prisma, GraphQL, security)
│   ├── modules/        # Feature-based modules
│   │   ├── categories/ # Categories module
│   ├── shared/         # Utilities, decorators, pipes, filters
│   ├── main.ts         # Application entry point
├── test/               # Unit and integration tests
├── dist/               # Compiled output (build)
├── package.json        # Project configuration
├── tsconfig.json       # TypeScript configuration
└── .env.example        # Environment variables template

Getting Started 🚀

  1. Install dependencies:

    npm install
  2. Start the Database with Docker:

    Ensure Docker Desktop is running, then execute:

    docker-compose up -d

    This will start a PostgreSQL database container in the background.

    You can check running containers with:

    docker ps

    For detailed database setup, visit: 📖 PostgreSQL Database Setup

  3. Configure Environment Variables:

    Create a .env file based on .env.example:

    cp .env.example .env

    You can configure the variables as you prefer or leave the default values.

  4. Set Up Database (Prisma & PostgreSQL):

    Run database migrations:

    npm run db:migrate

    Check database records using Prisma Studio:

    npm run db:studio
  5. Run development server:

    npm run dev
  6. Access the API:

    Open http://localhost:4000/graphql in your browser or API client.

Available Scripts 📜

  • npm run build - Compile the application
  • npm run dev - Start the development server
  • npm run start - Start the application in production
  • npm run start:debug - Start the application with debugging
  • npm run test - Run unit tests
  • npm run test:watch - Run tests in watch mode
  • npm run lint - Run ESLint with autofix
  • npm run format - Format the codebase with Prettier
  • npm run db:migrate - Apply database migrations
  • npm run db:push - Update the database schema without migrations
  • npm run db:studio - Open Prisma Studio for database inspection

Development Guidelines 📋

  1. Code Formatting:
    • Use Prettier to ensure consistent code formatting.
    • Run npm run format before committing changes.
  2. Linting:
    • Follow ESLint rules to maintain code quality.
    • Run npm run lint to check for and fix linting issues.
  3. Testing:
    • Write unit tests for all modules and services.
    • Run tests using npm run test.
  4. TypeScript:
    • Use TypeScript features for strong typing and code clarity.
    • Type safety is mandatory across all modules.

Learn More 📚

License

MIT License