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¶
-
Clone the Repository
-
Install Dependencies
-
Environment Variables Create a
.envfile 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¶
Production Build¶
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:
API Documentation¶
Once the server is running, you can access the API documentation at:
http://localhost:3000/api-docs
Troubleshooting¶
Common Issues¶
- Redis Connection Error
- Ensure Redis is running and accessible
-
Check REDIS_HOST, REDIS_PORT, and REDIS_PASSWORD in .env
-
Azure Service Authentication
- Verify all Azure connection strings and API keys
-
Check Azure resource access permissions
-
JWT Authentication Issues
- Ensure JWT_SECRET is properly set
- 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