diff --git a/.gitignore b/.gitignore index d4777d2..be13d01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# QuoteForge +config.yaml + # ---> macOS # General .DS_Store @@ -5,7 +8,7 @@ .LSOverride # Icon must end with two \r -Icon +Icon # Thumbnails ._* diff --git a/LICENSE.MD b/LICENSE.MD new file mode 100644 index 0000000..73bedd1 --- /dev/null +++ b/LICENSE.MD @@ -0,0 +1,85 @@ +PROPRIETARY SOFTWARE LICENSE AGREEMENT + +Copyright (c) 2025 Michael Chus. All Rights Reserved. + +NOTICE: This software and all associated documentation, source code, and +compiled binaries ("Software") are the exclusive property of Michael Chus +("Company"). + +1. GRANT OF LICENSE + + This Software is licensed, not sold. Subject to the terms of this Agreement, + Company grants you a limited, non-exclusive, non-transferable license to use + the Software solely for internal business purposes within your organization. + +2. RESTRICTIONS + + You may NOT: + + a) Copy, modify, adapt, translate, reverse engineer, decompile, disassemble, + or create derivative works based on the Software; + + b) Distribute, sublicense, lease, rent, loan, or otherwise transfer the + Software to any third party; + + c) Remove or alter any proprietary notices, labels, or marks on the Software; + + d) Use the Software for any purpose other than as expressly permitted herein; + + e) Use the Software to provide services to third parties (SaaS, hosting, etc.) + without prior written consent from Company. + +3. INTELLECTUAL PROPERTY + + The Software, including all copies, modifications, and derivative works, is + and shall remain the exclusive property of Company. This Agreement does not + grant you any rights to patents, copyrights, trade secrets, trade names, + trademarks, or any other rights in respect to the Software. + +4. CONFIDENTIALITY + + You agree to maintain the confidentiality of the Software and not to disclose + any part of the Software, including source code, algorithms, or documentation, + to any third party without prior written consent from Company. + +5. TERM AND TERMINATION + + This license is effective until terminated. Company may terminate this license + at any time if you fail to comply with any term of this Agreement. Upon + termination, you must destroy all copies of the Software in your possession. + +6. DISCLAIMER OF WARRANTIES + + THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. COMPANY DOES NOT + WARRANT THAT THE SOFTWARE WILL BE ERROR-FREE OR UNINTERRUPTED. + +7. LIMITATION OF LIABILITY + + IN NO EVENT SHALL COMPANY BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF + PROFITS, DATA, OR BUSINESS INTERRUPTION) ARISING OUT OF OR IN CONNECTION + WITH THIS AGREEMENT OR THE USE OF THE SOFTWARE. + +8. GOVERNING LAW + + This Agreement shall be governed by and construed in accordance with the laws + of [Your Jurisdiction], without regard to its conflict of laws principles. + +9. ENTIRE AGREEMENT + + This Agreement constitutes the entire agreement between you and Company + regarding the Software and supersedes all prior agreements and understandings, + whether written or oral. + +10. CONTACT + + For licensing inquiries, please contact: + + Michael Chus + Email: legal@your-company.com + Address: [Your Company Address] + +By using this Software, you acknowledge that you have read this Agreement, +understand it, and agree to be bound by its terms and conditions. diff --git a/README.md b/README.md index d8c7ab8..754a2a2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,233 @@ # QuoteForge +**Server Configuration & Quotation Tool** + +QuoteForge — корпоративный инструмент для конфигурирования серверов и формирования коммерческих предложений. Позволяет быстро собрать спецификацию сервера из каталога компонентов с автоматическим расчётом цен. + +![Go Version](https://img.shields.io/badge/Go-1.22+-00ADD8?style=flat&logo=go) +![License](https://img.shields.io/badge/License-Proprietary-red) +![Status](https://img.shields.io/badge/Status-In%20Development-yellow) + +## Возможности + +### Для пользователей +- 📱 **Mobile-first интерфейс** — удобная работа с телефона и планшета +- 🖥️ **Конфигуратор серверов** — пошаговый выбор компонентов с проверкой совместимости +- 💰 **Автоматический расчёт цен** — актуальные цены на основе истории закупок +- 📊 **Экспорт в CSV/XLSX** — готовые спецификации для клиентов +- 💾 **Сохранение конфигураций** — история и шаблоны для повторного использования +- 📤 **Импорт/экспорт JSON** — обмен конфигурациями между пользователями + +### Для ценовых администраторов +- 📈 **Умный расчёт цен** — медиана, взвешенная медиана, среднее +- 🎯 **Система алертов** — уведомления о популярных компонентах с устаревшими ценами +- 📉 **Аналитика использования** — какие компоненты востребованы в КП +- ⚙️ **Гибкие настройки** — периоды расчёта, методы, ручные переопределения + +### Индикация актуальности цен +| Цвет | Статус | Условие | +|------|--------|---------| +| 🟢 Зелёный | Свежая | < 30 дней, ≥ 3 источника | +| 🟡 Жёлтый | Нормальная | 30-60 дней | +| 🟠 Оранжевый | Устаревающая | 60-90 дней | +| 🔴 Красный | Устаревшая | > 90 дней или нет данных | + +## Технологии + +- **Backend:** Go 1.22+, Gin, GORM +- **Frontend:** HTML, Tailwind CSS, htmx +- **Database:** MariaDB 11+ +- **Export:** excelize (XLSX), encoding/csv + +## Требования + +- Go 1.22 или выше +- MariaDB 11.x (или MySQL 8.x) +- ~50 MB дискового пространства + +## Установка + +### 1. Клонирование репозитория + +```bash +git clone https://github.com/your-company/quoteforge.git +cd quoteforge +``` + +### 2. Настройка конфигурации + +```bash +cp config.example.yaml config.yaml +``` + +Отредактируйте `config.yaml`: + +```yaml +server: + host: "0.0.0.0" + port: 8080 + mode: "release" + +database: + host: "localhost" + port: 3306 + name: "RFQ_LOG" + user: "quoteforge" + password: "your-secure-password" + +auth: + jwt_secret: "your-jwt-secret-min-32-chars" + token_expiry: "24h" +``` + +### 3. Миграции базы данных + +```bash +make migrate +``` + +### 4. Импорт метаданных компонентов + +```bash +make seed +``` + +### 5. Запуск + +```bash +# Development +make run + +# Production +make build +./bin/quoteforge +``` + +Приложение будет доступно по адресу: http://localhost:8080 + +## Docker + +```bash +# Сборка образа +docker build -t quoteforge . + +# Запуск с docker-compose +docker-compose up -d +``` + +## Структура проекта + +``` +quoteforge/ +├── cmd/ +│ ├── server/ # Основной сервер +│ ├── priceupdater/ # Cron job обновления цен +│ └── importer/ # Импорт данных +├── internal/ +│ ├── config/ # Конфигурация +│ ├── models/ # GORM модели +│ ├── handlers/ # HTTP handlers +│ ├── services/ # Бизнес-логика +│ ├── middleware/ # Auth, CORS, etc. +│ └── repository/ # Работа с БД +├── web/ +│ ├── templates/ # HTML шаблоны +│ └── static/ # CSS, JS, изображения +├── migrations/ # SQL миграции +├── config.yaml # Конфигурация +├── Dockerfile +├── docker-compose.yml +└── Makefile +``` + +## Роли пользователей + +| Роль | Описание | +|------|----------| +| `viewer` | Просмотр, создание квот, экспорт | +| `editor` | + сохранение конфигураций | +| `pricing_admin` | + управление ценами и алертами | +| `admin` | Полный доступ, управление пользователями | + +## API + +Документация API доступна по адресу `/api/docs` (в разработке). + +Основные endpoints: + +``` +POST /api/auth/login # Авторизация +GET /api/components # Список компонентов +POST /api/quote/calculate # Расчёт цены +POST /api/export/xlsx # Экспорт в Excel +GET /api/configs # Сохранённые конфигурации +``` + +## Cron Jobs + +Добавьте в crontab: + +```bash +# Обновление цен — каждую ночь в 2:00 +0 2 * * * /opt/quoteforge/bin/priceupdater + +# Генерация алертов — каждый час +0 * * * * /opt/quoteforge/bin/priceupdater --alerts-only +``` + +## Разработка + +```bash +# Запуск в режиме разработки (hot reload) +make dev + +# Запуск тестов +make test + +# Линтер +make lint + +# Сборка для Linux +make build-linux +``` + +## Переменные окружения + +| Переменная | Описание | По умолчанию | +|------------|----------|--------------| +| `QF_DB_HOST` | Хост базы данных | localhost | +| `QF_DB_PORT` | Порт базы данных | 3306 | +| `QF_DB_NAME` | Имя базы данных | RFQ_LOG | +| `QF_DB_USER` | Пользователь БД | — | +| `QF_DB_PASSWORD` | Пароль БД | — | +| `QF_JWT_SECRET` | Секрет для JWT | — | +| `QF_SERVER_PORT` | Порт сервера | 8080 | + +## Интеграция с существующей БД + +QuoteForge интегрируется с существующей базой RFQ_LOG: + +- `lot` — справочник компонентов (только чтение) +- `lot_log` — история цен от поставщиков (только чтение) +- `supplier` — справочник поставщиков (только чтение) + +Новые таблицы QuoteForge имеют префикс `qt_`: + +- `qt_users` — пользователи приложения +- `qt_lot_metadata` — расширенные данные компонентов +- `qt_configurations` — сохранённые конфигурации +- `qt_pricing_alerts` — алерты для администраторов + +## Поддержка + +По вопросам работы приложения обращайтесь: +- Email: support@your-company.com +- Internal: #quoteforge в Slack + +## Лицензия + +Copyright © 2025 Your Company Name. Все права защищены. + +Данное программное обеспечение является собственностью компании и предназначено исключительно для внутреннего использования. Распространение, копирование или модификация без письменного разрешения запрещены. + +См. файл [LICENSE](LICENSE) для подробностей.