Skip to content

Backend Setup and Configuration

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn package manager
  • Redis (for caching and queue management)
  • Git
  • Docker and Docker Compose (for containerized deployment)

Installation Steps

  1. Clone the Repository

    git clone https://github.com/BidScript/bidssappserver-nestjs
    cd bidssappserver-nestjs
    

  2. Install Dependencies

    npm install
    

  3. Environment Variables Create a .env file in the root directory with the following variables:

# Server Configuration
PORT=3000
NODE_ENV=development

# JWT Authentication
JWT_SECRET=your_jwt_secret
JWT_EXPIRATION=8h

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_password

# Azure Configuration
AZURE_STORAGE_CONNECTION_STRING=your_azure_connection_string
AZURE_FORM_RECOGNIZER_KEY=your_form_recognizer_key
AZURE_FORM_RECOGNIZER_ENDPOINT=your_form_recognizer_endpoint
AZURE_OPENAI_API_KEY=your_azure_openai_key
AZURE_OPENAI_ENDPOINT=your_azure_openai_endpoint
AZURE_OPENAI_DEPLOYMENT_NAME=your_deployment_name
AZURE_SQL_SERVER=your_sql_server
AZURE_SQL_DATABASE=your_sql_database
AZURE_SQL_USERNAME=your_sql_username
AZURE_SQL_PASSWORD=your_sql_password

# Vector Database
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_ENVIRONMENT=your_pinecone_environment
PINECONE_INDEX=your_pinecone_index

Development Scripts

Local Development

# Start development server with hot-reload
npm run start:dev
# OR
npm run dev

Production Build

# Create production build
npm run build
# Start production server
npm run start:prod

Testing

# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Run e2e tests
npm run test:e2e
# Generate test coverage
npm run test:cov

Docker Deployment

The backend includes Docker configuration for containerized deployment.

Build and Run with Docker

# Build the Docker image
docker build -t bidssappserver-nestjs .

# Run the container
docker run -p 3000:3000 --env-file .env bidssappserver-nestjs

Docker Compose

The project includes a docker-compose.yml file that sets up the entire environment, including Redis:

# Start all services
docker-compose up -d

# Stop all services
docker-compose down

API Documentation

Once the server is running, you can access the API documentation at: http://localhost:3000/api-docs

Troubleshooting

Common Issues

  1. Redis Connection Error
  2. Ensure Redis is running and accessible
  3. Check REDIS_HOST, REDIS_PORT, and REDIS_PASSWORD in .env

  4. Azure Service Authentication

  5. Verify all Azure connection strings and API keys
  6. Check Azure resource access permissions

  7. JWT Authentication Issues

  8. Ensure JWT_SECRET is properly set
  9. Check token expiration settings

Logs

In development mode, detailed logs are printed to the console. In production, logs are stored in /logs directory.

Health Checks

The server provides health check endpoints: - GET /health - Basic service health - GET /health/redis - Redis connection status - GET /health/azure - Azure services status