{"repo": "bughouse-wizzard/test-nmc-mvp", "files": {"README.md": {"9545a7441f8261a95493a9540a454b40d69af6c9": {"t": 1785746656.0646763, "n": 6643, "h": "cc307c30363f5dbc", "c": "# NMCK Calculation System\n\nA system for calculating the initial maximum contract price (NMCK) by analyzing historical procurement contracts using AI and web scraping.\n\n## Features\n\n- **AI-Powered Contract Analysis**: Uses DeepSeek AI to extract technical specifications from contracts\n- **Web Scraping**: Automatically fetches contract data from zakupki.gov.ru\n- **Specification Comparison**: Compares target specifications with actual contract specifications\n- **NMCK Calculation**: Calculates the initial maximum contract price based on historical data\n- **Debug Logging**: Comprehensive logging of AI responses and parser HTML for debugging\n\n## Prerequisites\n\n- Docker and Docker Compose\n- DeepSeek API key (free tier available)\n\n## Quick Start\n\n### 1. Set up environment variables\n\nCopy the example environment file and configure your settings:\n\n```bash\ncp .env.example .env\n```\n\nEdit the `.env` file and set your DeepSeek API key:\n\n```env\n# DeepSeek AI API Configuration\nDEEPSEEK_API_KEY=your-deepseek-api-key-here\nDEEPSEEK_BASE_URL=https://api.deepseek.com\nDEEPSEEK_MODEL=deepseek-chat\n```\n\n### 2. Get a DeepSeek API Key\n\n1. Go to [DeepSeek Platform](https://platform.deepseek.com/)\n2. Sign up for a free account\n3. Navigate to the API section\n4. Generate a new API key\n5. Copy the key and paste it in your `.env` file\n\n### 3. Run the application\n\nStart the full stack with Docker Compose:\n\n```bash\ndocker-compose up -d\n```\n\nThis will start:\n- **Backend API** (port 8000)\n- **PostgreSQL database** (port 5432)\n- **Redis** (port 6379)\n- **Nginx** (port 80)\n- **Celery worker** for background tasks\n- **Celery beat** for scheduled tasks\n\n### 4. Access the application\n\n- **Frontend**: http://localhost\n- **Backend API**: http://localhost:8000\n- **API Documentation**: http://localhost:8000/docs\n\n## Project Structure\n\n```\n├── backend/ # FastAPI backend application\n│ ├── app/ # Main application code\n│ │ ├── api/ # API endpoints\n│ │ ├── core/ # Core configuration and utilities\n│ │ ├── models/ # Database models\n│ │ ├── schemas/ # Pydantic schemas\n│ │ └── worker/ # Celery worker tasks\n│ ├── services/ # Business logic services\n│ │ ├── ai/ # AI client for DeepSeek API\n│ │ └── parser/ # Web parsers for zakupki.gov.ru\n│ └── tests/ # Test suite\n├── frontend/ # React frontend application\n├── nginx/ # Nginx configuration\n├── alembic/ # Database migrations\n└── docker-compose.yml # Docker Compose configuration\n```\n\n## Configuration\n\n### Environment Variables\n\nKey environment variables to configure:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `DEEPSEEK_API_KEY` | **Required**: Your DeepSeek API key | - |\n| `DEBUG` | Enable debug mode | `false` |\n| `DATABASE_URL` | PostgreSQL connection URL | `postgresql://postgres:postgres@db:5432/nmck_db` |\n| `REDIS_URL` | Redis connection URL | `redis://redis:6379/0` |\n| `ZAKUPKI_BASE_URL` | Base URL for procurement portal | `https://zakupki.gov.ru` |\n| `CRAWL_DELAY` | Delay between requests (respects robots.txt) | `60` |\n| `WORKER_CONCURRENCY` | Number of concurrent worker processes | `2` |\n\n### Database Migrations\n\nThe application uses Alembic for database migrations. To apply migrations:\n\n```bash\n# Run inside the backend container\ndocker-compose exec backend alembic upgrade head\n```\n\nTo create a new migration after model changes:\n\n```bash\ndocker-compose exec backend alembic revision --autogenerate -m \"Description of changes\"\n```\n\n## Debugging and Logging\n\n### AI Response Debugging\n\nThe system logs all AI request and response data for debugging:\n\n1. **Raw AI responses** are stored in the `debug_data` field of `ContractResult` records\n2. **Parser HTML** is stored in both `SearchRequest.debug_data` and `ContractResult.raw_data_json.debug_data`\n3. **Debug data includes**:\n - AI request parameters and response metadata\n - Raw HTML from zakupki.gov.ru (first 5000 characters)\n - Processing timestamps\n - Error information\n\n### Accessing Debug Data\n\nDebug data can be accessed through:\n- Database queries on the `debug_data` JSON field\n- API responses (when debug mode is enabled)\n- Application logs\n\n### Robots.txt Compliance\n\nThe system respects zakupki.gov.ru's robots.txt requirements:\n- **Crawl delay**: 60 seconds between requests (configured via `CRAWL_DELAY`)\n- **Respects allowed/disallowed paths**\n- **Implements exponential backoff** for rate limiting\n\n## API Usage\n\n### Search for Contracts\n\n```bash\ncurl -X POST \"http://localhost:8000/api/v1/search\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"object_name\": \"Laptop\",\n \"ktru_code\": \"32.30.11.110\",\n \"customer_region\": \"СЗФО\",\n \"date_from\": \"2024-01-01\",\n \"date_to\": \"2024-12-31\"\n }'\n```\n\n### Check Search Status\n\n```bash\ncurl \"http://localhost:8000/api/v1/search/{search_id}/status\"\n```\n\n### Get Search Results\n\n```bash\ncurl \"http://localhost:8000/api/v1/search/{search_id}/results\"\n```\n\n## Development\n\n### Running Tests\n\n```bash\n# Run tests inside the backend container\ndocker-compose exec backend pytest\n```\n\n### Code Quality\n\n```bash\n# Format code with black\ndocker-compose exec backend black .\n\n# Check code style with flake8\ndocker-compose exec backend flake8 .\n\n# Type checking with mypy\ndocker-compose exec backend mypy .\n```\n\n### Local Development Without Docker\n\n1. Install Python dependencies:\n ```bash\n cd backend\n pip install -r requirements.txt\n ```\n\n2. Set up environment variables:\n ```bash\n export DEEPSEEK_API_KEY=your-key-here\n export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/nmck_db\n ```\n\n3. Run the application:\n ```bash\n uvicorn app.main:app --reload --host 0.0.0.0 --port 8000\n ```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **AI API errors**: Verify your `DEEPSEEK_API_KEY` is valid and has sufficient credits\n2. **Database connection errors**: Ensure PostgreSQL is running and accessible\n3. **Parser errors**: Check network connectivity to zakupki.gov.ru\n4. **Rate limiting**: The system implements retry logic with exponential backoff\n\n### Logs\n\nView application logs:\n\n```bash\n# Backend logs\ndocker-compose logs backend\n\n# Worker logs\ndocker-compose logs worker\n\n# Database logs\ndocker-compose logs db\n```\n\n### Database Reset\n\nTo reset the database:\n\n```bash\n# Stop containers\ndocker-compose down\n\n# Remove volumes\ndocker-compose down -v\n\n# Restart\ndocker-compose up -d\n```\n\n## License\n\n[Add your license information here]\n\n## Support\n\nFor issues and feature requests, please use the issue tracker or contact the development team."}, "ebc2c99fc8f147e7526c265151df4b35e83d1056": {"t": 1785766638.4093218, "n": 6643, "h": "cc307c30363f5dbc", "c": "# NMCK Calculation System\n\nA system for calculating the initial maximum contract price (NMCK) by analyzing historical procurement contracts using AI and web scraping.\n\n## Features\n\n- **AI-Powered Contract Analysis**: Uses DeepSeek AI to extract technical specifications from contracts\n- **Web Scraping**: Automatically fetches contract data from zakupki.gov.ru\n- **Specification Comparison**: Compares target specifications with actual contract specifications\n- **NMCK Calculation**: Calculates the initial maximum contract price based on historical data\n- **Debug Logging**: Comprehensive logging of AI responses and parser HTML for debugging\n\n## Prerequisites\n\n- Docker and Docker Compose\n- DeepSeek API key (free tier available)\n\n## Quick Start\n\n### 1. Set up environment variables\n\nCopy the example environment file and configure your settings:\n\n```bash\ncp .env.example .env\n```\n\nEdit the `.env` file and set your DeepSeek API key:\n\n```env\n# DeepSeek AI API Configuration\nDEEPSEEK_API_KEY=your-deepseek-api-key-here\nDEEPSEEK_BASE_URL=https://api.deepseek.com\nDEEPSEEK_MODEL=deepseek-chat\n```\n\n### 2. Get a DeepSeek API Key\n\n1. Go to [DeepSeek Platform](https://platform.deepseek.com/)\n2. Sign up for a free account\n3. Navigate to the API section\n4. Generate a new API key\n5. Copy the key and paste it in your `.env` file\n\n### 3. Run the application\n\nStart the full stack with Docker Compose:\n\n```bash\ndocker-compose up -d\n```\n\nThis will start:\n- **Backend API** (port 8000)\n- **PostgreSQL database** (port 5432)\n- **Redis** (port 6379)\n- **Nginx** (port 80)\n- **Celery worker** for background tasks\n- **Celery beat** for scheduled tasks\n\n### 4. Access the application\n\n- **Frontend**: http://localhost\n- **Backend API**: http://localhost:8000\n- **API Documentation**: http://localhost:8000/docs\n\n## Project Structure\n\n```\n├── backend/ # FastAPI backend application\n│ ├── app/ # Main application code\n│ │ ├── api/ # API endpoints\n│ │ ├── core/ # Core configuration and utilities\n│ │ ├── models/ # Database models\n│ │ ├── schemas/ # Pydantic schemas\n│ │ └── worker/ # Celery worker tasks\n│ ├── services/ # Business logic services\n│ │ ├── ai/ # AI client for DeepSeek API\n│ │ └── parser/ # Web parsers for zakupki.gov.ru\n│ └── tests/ # Test suite\n├── frontend/ # React frontend application\n├── nginx/ # Nginx configuration\n├── alembic/ # Database migrations\n└── docker-compose.yml # Docker Compose configuration\n```\n\n## Configuration\n\n### Environment Variables\n\nKey environment variables to configure:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `DEEPSEEK_API_KEY` | **Required**: Your DeepSeek API key | - |\n| `DEBUG` | Enable debug mode | `false` |\n| `DATABASE_URL` | PostgreSQL connection URL | `postgresql://postgres:postgres@db:5432/nmck_db` |\n| `REDIS_URL` | Redis connection URL | `redis://redis:6379/0` |\n| `ZAKUPKI_BASE_URL` | Base URL for procurement portal | `https://zakupki.gov.ru` |\n| `CRAWL_DELAY` | Delay between requests (respects robots.txt) | `60` |\n| `WORKER_CONCURRENCY` | Number of concurrent worker processes | `2` |\n\n### Database Migrations\n\nThe application uses Alembic for database migrations. To apply migrations:\n\n```bash\n# Run inside the backend container\ndocker-compose exec backend alembic upgrade head\n```\n\nTo create a new migration after model changes:\n\n```bash\ndocker-compose exec backend alembic revision --autogenerate -m \"Description of changes\"\n```\n\n## Debugging and Logging\n\n### AI Response Debugging\n\nThe system logs all AI request and response data for debugging:\n\n1. **Raw AI responses** are stored in the `debug_data` field of `ContractResult` records\n2. **Parser HTML** is stored in both `SearchRequest.debug_data` and `ContractResult.raw_data_json.debug_data`\n3. **Debug data includes**:\n - AI request parameters and response metadata\n - Raw HTML from zakupki.gov.ru (first 5000 characters)\n - Processing timestamps\n - Error information\n\n### Accessing Debug Data\n\nDebug data can be accessed through:\n- Database queries on the `debug_data` JSON field\n- API responses (when debug mode is enabled)\n- Application logs\n\n### Robots.txt Compliance\n\nThe system respects zakupki.gov.ru's robots.txt requirements:\n- **Crawl delay**: 60 seconds between requests (configured via `CRAWL_DELAY`)\n- **Respects allowed/disallowed paths**\n- **Implements exponential backoff** for rate limiting\n\n## API Usage\n\n### Search for Contracts\n\n```bash\ncurl -X POST \"http://localhost:8000/api/v1/search\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"object_name\": \"Laptop\",\n \"ktru_code\": \"32.30.11.110\",\n \"customer_region\": \"СЗФО\",\n \"date_from\": \"2024-01-01\",\n \"date_to\": \"2024-12-31\"\n }'\n```\n\n### Check Search Status\n\n```bash\ncurl \"http://localhost:8000/api/v1/search/{search_id}/status\"\n```\n\n### Get Search Results\n\n```bash\ncurl \"http://localhost:8000/api/v1/search/{search_id}/results\"\n```\n\n## Development\n\n### Running Tests\n\n```bash\n# Run tests inside the backend container\ndocker-compose exec backend pytest\n```\n\n### Code Quality\n\n```bash\n# Format code with black\ndocker-compose exec backend black .\n\n# Check code style with flake8\ndocker-compose exec backend flake8 .\n\n# Type checking with mypy\ndocker-compose exec backend mypy .\n```\n\n### Local Development Without Docker\n\n1. Install Python dependencies:\n ```bash\n cd backend\n pip install -r requirements.txt\n ```\n\n2. Set up environment variables:\n ```bash\n export DEEPSEEK_API_KEY=your-key-here\n export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/nmck_db\n ```\n\n3. Run the application:\n ```bash\n uvicorn app.main:app --reload --host 0.0.0.0 --port 8000\n ```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **AI API errors**: Verify your `DEEPSEEK_API_KEY` is valid and has sufficient credits\n2. **Database connection errors**: Ensure PostgreSQL is running and accessible\n3. **Parser errors**: Check network connectivity to zakupki.gov.ru\n4. **Rate limiting**: The system implements retry logic with exponential backoff\n\n### Logs\n\nView application logs:\n\n```bash\n# Backend logs\ndocker-compose logs backend\n\n# Worker logs\ndocker-compose logs worker\n\n# Database logs\ndocker-compose logs db\n```\n\n### Database Reset\n\nTo reset the database:\n\n```bash\n# Stop containers\ndocker-compose down\n\n# Remove volumes\ndocker-compose down -v\n\n# Restart\ndocker-compose up -d\n```\n\n## License\n\n[Add your license information here]\n\n## Support\n\nFor issues and feature requests, please use the issue tracker or contact the development team."}}}}