Commit Graph

392 Commits

Author SHA1 Message Date
Mazyar e04cdd1d10 Refactor AI summarization functionality by removing document summarization worker
continuous-integration/drone/push Build is passing
- Removed the DocumentSummarizationWorker and its related scheduling logic from the worker bootstrap.
- Updated the AI summarizer client initialization comment for clarity.
- Added a new error type for cases when tender documents have not been scraped yet, enhancing error handling in the tender service.
- Modified API documentation to reflect changes in AI summary retrieval logic, ensuring accurate descriptions of on-demand summarization behavior.

This update streamlines the AI summarization process by eliminating the document summarization worker, improving overall system efficiency and clarity in error handling.
2026-06-21 11:20:28 +03:30
Mazyar e31bccced6 Add unit tests for dashboard repository and enhance BSON handling
continuous-integration/drone/push Build is passing
2026-06-21 10:03:17 +03:30
Mazyar 45cfa24a72 Enhance document scraper service with AI portal integration and error handling
- Updated the document scraper service to include a new ScrapePortalsProvider interface, allowing for dynamic retrieval of supported scraping portals.
- Modified the ListPendingTenders and GetTenderByNoticeID methods to filter tenders based on document URLs that match the configured portals.
- Introduced new error handling for cases when the scrape portals provider is not configured, returning appropriate service unavailable responses.
- Enhanced API documentation to reflect changes in tender retrieval logic and added error response details for unsupported portal scenarios.

This update improves the document scraping functionality by integrating AI portal support, enhancing the overall reliability and flexibility of the tender management system.
2026-06-21 09:58:11 +03:30
m.nazemi 550f11a77e Merge pull request 'Enhance tender estimated value resolution and add unit tests' (#45) from est-value into develop
continuous-integration/drone/push Build is passing
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/45
2026-06-21 09:42:00 +03:30
Mazyar ee5414bc10 Enhance procurement lot estimated value aggregation and add unit tests
- Updated the `AggregateProcurementLotEstimatedValue` function to reject mixed currencies and allow empty lot currencies, ensuring accurate aggregation of estimated values.
- Introduced new unit tests in `entity_test.go` to validate the behavior of the aggregation function under various scenarios, including mixed currencies and empty lot currencies.
- Refactored budget calculation in `budget_test.go` to utilize the new aggregation logic, improving consistency in budget retrieval.

This update improves the handling of estimated values in procurement lots, enhancing the reliability of the tender management system.
2026-06-21 09:41:33 +03:30
m.nazemi a04b3fe1ec Merge branch 'develop' into est-value 2026-06-21 09:37:00 +03:30
Mazyar dfab3e17d2 Enhance dashboard repository and service with caching and aggregation improvements
- Introduced caching mechanisms for summary and statistics in the dashboard service, improving performance by reducing redundant data retrieval.
- Refactored the Summary method to utilize MongoDB aggregation for more efficient data processing and retrieval.
- Added synchronization features using singleflight to prevent duplicate processing of requests for cached data.
- Updated the repository to include a cachedScrapedTendersScope method, enhancing the efficiency of scraped document statistics retrieval.

This update significantly optimizes the dashboard's performance and data handling capabilities, ensuring faster response times and reduced load on the database.
2026-06-21 09:36:12 +03:30
Mazyar 4cfca5aa55 Enhance tender estimated value resolution and add unit tests
- Updated the `ResolvedEstimatedValueAndCurrency` method to aggregate procurement lot values when the tender-level estimated value is not set, improving accuracy in value retrieval.
- Introduced the `AggregateProcurementLotEstimatedValue` function to sum estimated values from procurement lots and return the first found currency.
- Modified the `ToResponseWithLanguage` method to utilize the new estimated value resolution logic.
- Added unit tests for the new functionality, ensuring correct behavior for various scenarios in the `entity_test.go` and `budget_test.go` files.

This update improves the handling of estimated values in tenders, enhancing the overall reliability of the tender management system.
2026-06-20 12:29:47 +03:30
Mazyar 6fb57c41c1 Refactor ScrapePortalsResponse structure and update API documentation
continuous-integration/drone/push Build is passing
- Changed the ScrapePortalsResponse type to return a slice of strings representing portal identifiers instead of a structured object.
- Updated the Swagger documentation for the GetScrapePortals endpoint to reflect the new response format, ensuring clarity in API usage.

This update simplifies the response structure for the scraping portals, enhancing the API's usability and consistency.
2026-06-18 20:56:31 +03:30
Mazyar e5fa0dfe47 Add GetScrapePortals endpoint and related service functionality
continuous-integration/drone/push Build is passing
- Introduced the GetScrapePortals method in the AI pipeline handler to list document scraping portals supported by the Opplens AI service.
- Updated the service layer to include GetScrapePortals, which retrieves the portals from the client and handles errors appropriately.
- Enhanced the routes to register the new endpoint for retrieving scrape portals.
- Added a new error type for invalid date ranges in the document scraper, improving validation and error handling.

This update expands the AI pipeline capabilities, allowing for better management of document scraping portals within the tender management system.
2026-06-18 19:53:07 +03:30
m.nazemi 2f19ecae55 Merge pull request 'Refactor dashboard repository to integrate ProcedureDocumentsLister' (#44) from dashboard-documents into develop
continuous-integration/drone/push Build is passing
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/44
2026-06-17 15:02:23 +03:30
Mazyar 8035118f44 Enhance dashboard statistics repository with scraped tenders scope resolution
- Introduced a new `scrapedTendersScope` type to encapsulate the MongoDB filter for tenders with scraped documents, improving clarity and maintainability.
- Updated the `Statistics` method to utilize the new scope resolution, allowing for more accurate data retrieval based on the presence of scraped documents.
- Implemented multiple tests for the `resolveScrapedTendersScope` method, ensuring correct behavior for various scenarios, including empty and fallback cases.

This update enhances the dashboard's ability to manage scraped document statistics, improving overall data accuracy and system performance.
2026-06-17 15:01:52 +03:30
Mazyar 9676f99304 Refactor dashboard repository to integrate ProcedureDocumentsLister
- Introduced the ProcedureDocumentsLister interface to list contract folders with scraped documents, enhancing the accuracy of document-scrape statistics.
- Updated the dashboard repository to accept ProcedureDocumentsLister as a dependency, allowing for improved data retrieval.
- Implemented tests for the new functionality, ensuring proper handling of scraped document folder IDs and error propagation.

This update enhances the dashboard's capability to manage and report on scraped documents, improving overall system efficiency and data integrity.
2026-06-17 14:17:41 +03:30
m.nazemi 7120a954b6 Merge pull request 'Add security and compliance documentation for ISO/IEC 27001' (#41) from TM-310 into develop
continuous-integration/drone/push Build is passing
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/41
Reviewed-by: Hadi Barzegar <barzagarhadi@gmail.com>
2026-06-17 00:54:48 +03:30
m.nazemi 243f667005 Merge branch 'develop' into TM-310 2026-06-17 00:54:35 +03:30
m.nazemi 58345ac4f3 Merge pull request 'Refactor statistics repository to use created_at for historical data retrieval' (#43) from dashboard-data into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/43
Reviewed-by: Hadi Barzegar <barzagarhadi@gmail.com>
2026-06-17 00:54:01 +03:30
m.nazemi 902cc686a0 Merge branch 'develop' into TM-310 2026-06-15 23:41:11 +03:30
Mazyar 7f84746400 Refactor statistics repository to use created_at for historical data retrieval
- Updated the `Statistics` method to utilize `created_at` instead of `processing_metadata.scraped_at` for fetching daily counts, ensuring accurate historical data representation.
- Removed redundant conditions in the `scrapedDocumentsPerDay` method, streamlining the query logic for better performance and clarity.
- Added a new index on `source` and `created_at` to optimize database queries related to scraped documents.

This update enhances the accuracy of data retrieval in the dashboard statistics, improving the overall efficiency of the tender management system.
2026-06-15 23:39:32 +03:30
Mazyar 31d8efef0b Enhance search functionality by adding NoticePublicationID to SearchForm and updating API documentation
continuous-integration/drone/push Build is passing
- Added `NoticePublicationID` field to the `SearchForm` for filtering tenders by TED notice publication ID.
- Updated Swagger documentation in the handler methods to include the new `notice_publication_id` parameter for relevant endpoints.
- Modified the repository's search filter to incorporate the new `NoticePublicationID` field, allowing for more precise search queries.

This update improves the search capabilities within the tender management system, enhancing user experience and data retrieval accuracy.
2026-06-15 11:22:41 +03:30
Mazyar 2e112fe08c Update MinIO bucket configuration and enhance dashboard service caching
continuous-integration/drone/push Build is passing
- Changed the default MinIO bucket name from "opplens-documents" to "opplens" across multiple configuration files.
- Introduced caching for dashboard statistics in the service layer to improve performance and reduce redundant data fetching.
- Implemented a mutex for thread-safe access to cached statistics, ensuring data integrity during concurrent requests.

This update streamlines the configuration for the AI summarizer and optimizes the dashboard service, enhancing overall system efficiency.
2026-06-14 15:14:02 +03:30
Mazyar ca2a1b4425 Enhance AI pipeline service with document metadata synchronization
continuous-integration/drone/push Build is passing
- Updated the AI pipeline service to include a new `ScrapedDocumentMetadataSyncer` interface for persisting scraped document metadata onto tender records.
- Modified the `NewService` function to accept the new metadata syncer dependency.
- Implemented synchronization of scraped document metadata in the `ScrapeDocuments` and `Run` methods.
- Enhanced the tender service to enrich search filters based on scraped documents and added a new method for syncing scraped documents from storage.
- Updated the `SearchForm` to include `ContractFolderIDsWithDocuments` for better handling of scraped documents in queries.

This update improves the integration of scraped document handling within the AI pipeline, enhancing data consistency and operational efficiency in the tender management system.
2026-06-14 14:59:37 +03:30
Mazyar ca35eb5f15 Enhance worker configuration and error handling for AI summarizer
continuous-integration/drone/push Build is passing
- Added `TranslationEnabled` and `TranslationInterval` fields to the worker configuration to manage automatic translation scheduling.
- Updated the worker initialization to log when the translation worker is disabled.
- Improved error handling in the AI summarizer client by introducing `APIStatusError` for better context on API failures, replacing direct error messages with structured error responses.

This update enhances the configurability of the worker and improves error reporting for AI service interactions, contributing to better maintainability and user experience.
2026-06-14 14:02:35 +03:30
Mazyar 42d64c4ec6 Merge remote-tracking branch 'opplens/dev' into develop
continuous-integration/drone/push Build is passing
2026-06-14 12:58:20 +03:30
Mazyar dcf19b91cd Implement AI pipeline operations in the admin API
- Added new routes and handlers for AI pipeline operations, including scraping documents, batch summarization, translation, and syncing with the Opplens AI service.
- Introduced request forms for handling tender references and batch operations.
- Enhanced the AI service with methods for triggering batch operations and managing pipeline runs.
- Updated Swagger documentation to reflect the new AI pipeline endpoints and their functionalities.

This update integrates comprehensive AI pipeline capabilities into the tender management system, improving operational efficiency and user experience.
2026-06-14 12:54:13 +03:30
Mazyar 6af5cf3c4e Update security documentation to align with ISO/IEC 27001 standards
- Revised the Gap Analysis Report to provide detailed counts of implemented, partial, and not implemented controls, enhancing clarity on compliance status.
- Updated the ISO27001 Roadmap to include a status column for deliverables, improving tracking of progress towards certification.
- Adjusted the Statement of Applicability to reconcile summary counts with control rows and clarify the applicability of outsourced development.

These updates strengthen the documentation framework, ensuring it accurately reflects the current state of security controls and compliance efforts within the Tender Management System.
2026-06-13 23:59:38 +03:30
mazyar 147be11973 Update .drone.yml
continuous-integration/drone/push Build is passing
2026-06-13 13:54:27 +00:00
mazyar 9674d571e2 Update .drone.yml
continuous-integration/drone/push Build is passing
2026-06-13 13:22:26 +00:00
mazyar 2e74af0ce2 Update .drone.yml
continuous-integration/drone/push Build is passing
2026-06-13 13:17:49 +00:00
nima 9f28ac278f Initial commit 2026-06-13 16:27:22 +03:30
m.nazemi 96ec0f8a8f Merge branch 'develop' into TM-310 2026-06-13 14:50:00 +03:30
m.nazemi a825c4a271 Merge pull request 'Enhance notification search functionality and update API documentation' (#40) from TM-616 into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/40
Reviewed-by: Hadi Barzegar <barzagarhadi@gmail.com>
2026-06-13 14:49:25 +03:30
m.nazemi 416b040c2b Merge branch 'develop' into TM-616 2026-06-13 14:49:01 +03:30
m.nazemi 24c57a3ec5 Merge pull request 'Implement AI onboarding and recommendation features in company service' (#39) from TM-599 into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/39
2026-06-13 14:48:44 +03:30
Mazyar 06e663b691 Add security and compliance documentation for ISO/IEC 27001
- Introduced a comprehensive suite of security documents to support ISO/IEC 27001 certification, including the ISMS Foundation, Risk Assessment Matrix, Gap Analysis Report, Statement of Applicability, and ISO27001 Roadmap.
- Updated the README to include links to the new security documentation, enhancing the project's compliance framework and providing clear guidance on security policies and procedures.

This addition strengthens the overall security posture of the Tender Management System and aligns with industry standards for information security management.
2026-06-11 01:53:24 +03:30
Mazyar f16f9fb5a9 Enhance notification search functionality and update API documentation
- Added `search` and `q` query parameters to the `SearchForm` for improved notification searching capabilities.
- Implemented `ResolvedSearch` method to prioritize search term resolution from the new parameters.
- Updated `GetByUserID` repository method to support searching notifications by title and message using regex.
- Enhanced logging in the `GetNotifications` service method to include search parameters.
- Updated Swagger documentation to reflect the new search parameters for the notification API.

This update improves the user experience by allowing more flexible and efficient searching of notifications.
2026-06-11 01:33:47 +03:30
Mazyar 3b26c4f5e1 Implement AI onboarding and recommendation features in company service
- Added new AI onboarding and recommendation endpoints in the company handler for starting onboarding and retrieving ranked tender recommendations.
- Introduced `StartAIOnboarding` and `GetAIRecommendations` methods in the company service to handle AI interactions.
- Updated the company service constructor to include the AI recommendation client.
- Enhanced the AI summarizer client with methods for onboarding and fetching recommendations.
- Added response structures for onboarding and recommended tenders in the company form.

This update enhances the tender management system by integrating AI capabilities for onboarding and tender recommendations, improving user experience and operational efficiency.
2026-06-11 01:08:59 +03:30
Mazyar 4f05516fc2 Update Drone CI configuration and Makefile to remove legacy worker sources and add build target for worker
- Updated `.drone.yml` to remove lingering legacy worker source files after git deletion, ensuring a clean build environment.
- Modified `Makefile` to include a new `build-worker` target that removes deprecated scraper and queue source files, streamlining the worker build process.

This change enhances the build process by eliminating outdated components and ensuring that the worker is built without legacy dependencies.
2026-06-09 11:29:29 +03:30
m.nazemi 35892d5bc0 Merge pull request 'Implement AI analysis trigger endpoint and refactor related components' (#38) from AI-Refactor into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/38
Reviewed-by: Hadi Barzegar <barzagarhadi@gmail.com>
2026-06-08 23:50:36 +03:30
Mazyar 9cd22c24b6 Refactor queue management by removing deprecated components and updating configuration
- Removed the QueueConfig structure and related queue management files as they are no longer in use.
- Updated the worker initialization to reflect the removal of queue-related configurations.
- Cleaned up the bootstrap process by eliminating deprecated logging related to the queue system.

This update streamlines the worker's configuration and prepares the codebase for future enhancements without the legacy queue management components.
2026-06-08 23:49:51 +03:30
Mazyar d07e1c9cf0 Fix summarizer worker infinite loop and map AI trigger errors to safe HTTP responses.
Paginate un-summarized tenders and mark rows missing notice/folder IDs as handled so the worker cannot spin forever. Return 400/404 for validation and not-found cases on AI summarize/analyze triggers instead of leaking internal errors as 500.
2026-06-08 20:24:02 +03:30
Mazyar 7d383c36c3 Implement AI analysis trigger endpoint and refactor related components
- Added a new endpoint to trigger on-demand agentic analysis for tenders via the AI service.
- Introduced `TriggerAIAnalyze` method in the `TenderHandler` to handle requests and responses for AI analysis.
- Updated the `tenderService` to include `TriggerAIAnalyze` method, which validates input and interacts with the AI summarizer client.
- Enhanced the `AIAnalyzeResponse` and `AIAnalyzeDocument` structures to support the new analysis feature.
- Refactored the `DocumentSummarizationWorker` and `TranslationWorker` to remove deprecated MinIO dependencies, streamlining the AI service interactions.

This update improves the functionality of the tender management system by allowing users to trigger AI analysis on-demand, enhancing the overall user experience and system capabilities.
2026-06-08 18:01:15 +03:30
m.nazemi de8de9b5c5 Merge pull request 'Implement phone number validation for customer and user registration and updates' (#35) from Phone-Uniqueness into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/35
2026-06-07 14:41:21 +03:30
Mazyar 3f0935ee3f Enhance duplicate key error handling in MongoDB operations
- Improved the `IsDuplicateKeyError` function to utilize structured error messages for better accuracy in identifying duplicate key errors.
- Introduced `duplicateKeyMessages` and `hasStructuredWriteException` functions to parse and extract relevant information from MongoDB error messages.
- Updated `DuplicateKeyMatchesField` to match duplicate key errors against specific fields by analyzing error messages rather than relying on substring matching.

This refactor enhances the clarity and reliability of duplicate key error handling, ensuring more precise identification of conflicts in MongoDB operations.
2026-06-07 14:40:42 +03:30
m.nazemi 550fd36db1 Merge branch 'develop' into Phone-Uniqueness 2026-06-07 14:33:48 +03:30
m.nazemi a75e4743f0 Merge pull request 'Refactor AI summarizer client initialization to include MongoDB manager and add statistics endpoint' (#36) from TM-602 into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/36
2026-06-07 14:32:37 +03:30
m.nazemi b7e813e972 Merge pull request 'Refactor MongoDB index creation to use NonEmptyStringPartialFilter for improved clarity and consistency. Update GetOJS function to utilize context and user agent for HTTP requests, enhancing error handling and response management.' (#37) from OJS-Date into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/37
2026-06-07 14:31:15 +03:30
Mazyar c91b525e7e Refactor MongoDB index creation to use NonEmptyStringPartialFilter for improved clarity and consistency. Update GetOJS function to utilize context and user agent for HTTP requests, enhancing error handling and response management. 2026-06-06 21:36:43 +03:30
Mazyar 68b170126d Refactor AI summarizer client initialization to include MongoDB manager and add statistics endpoint
- Updated `InitAISummarizerClient` to accept `mongoManager` for tracking translation success.
- Introduced new `Statistics` endpoint in the dashboard to fetch scraping and translation statistics.
- Enhanced `TranslationWorker` to utilize the new success counter for tracking successful translations.
- Added necessary data structures and query forms for statistics reporting.

This refactor improves the tracking of AI translation success and provides new insights through the dashboard statistics.
2026-06-06 21:20:53 +03:30
Mazyar 22487eaef5 fix(user,customer): return 409 on phone duplicate-key races
Map E11000 from the per-collection phone index to friendly conflict
errors and skip redundant GetByPhone when the phone is unchanged.

Not blocking: IAT test DB may need a one-off dedupe for index build;
phone uniqueness is per collection (users vs customers), not global.
2026-06-06 20:34:45 +03:30
Mazyar 0da0c8b8c9 Implement phone number validation for customer and user registration and updates
Added functionality to check for existing customers and users by phone number during registration and updates. Updated the handler, service, and repository layers to include phone number checks, ensuring unique phone numbers across customers and users.
2026-06-06 12:03:04 +03:30