# Tender Management System A comprehensive tender management backend system built with Go, following Clean Architecture principles with Domain-Driven Design (DDD) patterns. ## ๐Ÿ“š Documentation All documentation has been organized in the [`docs/`](./docs/) directory for better structure and maintainability. ### Quick Links - **[๐Ÿ“– Main Documentation](./docs/README.md)** - Comprehensive project overview and guidelines - **[๐Ÿ”ง Setup Guides](./docs/setup/)** - HTTP server and Swagger setup - **[๐Ÿš€ Implementation Details](./docs/implementation/)** - Architecture and implementation overview - **[๐Ÿ“ก API Examples](./docs/examples/)** - API usage examples and endpoints ## ๐Ÿš€ Quick Start 1. **Setup Environment** ```bash # Follow setup guides in docs/setup/ ``` 2. **Run the Application** ```bash make run ``` 3. **Access API Documentation** - Swagger UI: `http://localhost:8081/swagger/index.html` - API Base URL: `http://localhost:8081/api/v1` ## ๐Ÿ—๏ธ Architecture This system implements **Clean Architecture** with: - **Domain Layer**: Business entities and core rules - **Service Layer**: Business logic and use cases - **Handler Layer**: HTTP controllers and request handling - **Repository Layer**: Data access implementations - **Infrastructure Layer**: External dependencies ## ๐Ÿ“‹ Key Features - **Clean Architecture**: DDD principles with clear separation of concerns - **MongoDB Integration**: Robust data persistence with proper indexing - **Structured Logging**: Comprehensive logging with context - **Input Validation**: Govalidator integration for request validation - **Error Handling**: Consistent error responses and logging - **Time Handling**: Unix timestamps throughout the application - **Generic XML Parser**: Parse any XML structure into Go structs using generics ## ๐Ÿšง Phase 1 Implementation Status **Current Completion: 70-75%** - The foundation is excellent with TED integration, company management, and admin panel. Critical gaps exist in mobile app features and feedback system. ### โœ… **Completed Features (100%)** #### 1. **TED Integration** - โœ… TED XML Bulk Import with comprehensive parser - โœ… XML Parser supporting all TED notice types - โœ… Complete data storage with all required fields - โœ… Unique tender ID generation system - โœ… Submission deadline calculation (2 weeks before notice) - โœ… Source tracking and metadata management #### 2. **Company Profile Management** - โœ… Username & password authentication system - โœ… Complete tags system (CPV codes, categories, keywords) - โœ… Company verification and compliance tracking - โœ… Address and contact information management #### 3. **Admin Panel (Web)** - โœ… Complete company CRUD operations - โœ… User management and authentication - โœ… Tag assignment and management - โœ… Tender management and search - โœ… Scraping job control and monitoring ### ๐Ÿ”„ **Partially Implemented (60-80%)** #### 4. **Tender Matching Logic** - โœ… Basic CPV code matching algorithm - โœ… Category tags structure - โŒ Abstract text relevance analysis - โœ… Basic match percentage calculation #### 5. **Mobile App Backend** - โœ… Authentication system (login/logout) - โœ… Basic tender access endpoints - โŒ Advanced filtering capabilities - โŒ Comprehensive search functionality - โŒ Like/Dislike feedback system ### โŒ **Missing Features (0%)** #### 6. **Feedback System** - โŒ Like/Dislike functionality - โŒ Interest tracking and history - โŒ Company-tender feedback relationships #### 7. **Advanced Mobile Features** - โŒ Comprehensive filtering (date, status, location) - โŒ Advanced search (title, abstract, buyer) - โŒ Detailed tender information endpoints - โŒ Feedback and rating system ## ๐Ÿ“‹ **TODO List - Phase 1 Completion** ### ๐Ÿ”ด **High Priority - Critical Features** #### 1. **Feedback System Implementation** - [ ] Create new domain `internal/feedback/` - [ ] Implement `TenderFeedback` entity - [ ] Add repository for feedback storage - [ ] Implement feedback management service - [ ] Add API endpoints for like/dislike - [ ] Implement authentication middleware for feedback #### 2. **Enhanced Tender Matching Algorithm** - [ ] Improve `CalculateMatchPercentage` function - [ ] Add abstract text analysis for relevance scoring - [ ] Implement matching based on keywords and specializations - [ ] Add weighting system for different match criteria - [ ] Optimize matching algorithm performance #### 3. **Database Optimization** - [ ] Create indexes for search fields in MongoDB - [ ] Add compound indexes for complex queries - [ ] Optimize queries for better performance - [ ] Add text indexes for text search ### ๐ŸŸก **Medium Priority - Mobile Features** #### 4. **Advanced Mobile APIs** - [ ] Add endpoint for company-matched tenders - [ ] Implement advanced filtering (date, status, location) - [ ] Add search by title and abstract - [ ] Implement pagination for long lists - [ ] Add sorting by match percentage and date #### 5. **Advanced Filtering System** - [ ] Filter by deadline time range - [ ] Filter by tender status - [ ] Filter by country and region - [ ] Filter by tender type - [ ] Filter by estimated value - [ ] Filter by CPV codes #### 6. **Advanced Search System** - [ ] Search in tender titles - [ ] Search in abstract text - [ ] Search in buyer organization names - [ ] Combined search (title + text + location) - [ ] Fuzzy search for better results ### ๐ŸŸข **Low Priority - Enhancements** #### 7. **Recommendation System** - [ ] Implement recommendation algorithm based on feedback history - [ ] Add "similar tenders" based on CPV codes - [ ] Implement "suggested tenders" for companies - [ ] Add scoring system for prioritization #### 8. **Analytics and Reporting** - [ ] Add feedback statistics to admin panel - [ ] Report companies with most feedback activity - [ ] Statistics on popular and unpopular tenders - [ ] Company matching effectiveness reports #### 9. **Performance Optimization** - [ ] Add caching for matching results - [ ] Optimize queries using aggregation pipelines - [ ] Implement background jobs for match calculations - [ ] Add rate limiting for APIs ### ๐Ÿ”ง **Testing and Documentation** #### 10. **Testing** - [ ] Write unit tests for feedback system - [ ] Integration tests for new APIs - [ ] Performance tests for matching algorithm - [ ] Load tests for mobile endpoints #### 11. **Documentation** - [ ] Update Swagger documentation - [ ] API documentation for mobile - [ ] Implementation guide for feedback system - [ ] Matching algorithm documentation ### ๐Ÿ“ฑ **Mobile-Specific Features** #### 12. **Authentication and Security** - [ ] Improve JWT token management - [ ] Add refresh token rotation - [ ] Implement rate limiting for login attempts - [ ] Add device tracking #### 13. **Push Notifications** - [ ] Implement notification system for new tenders - [ ] Notifications for high-match tenders - [ ] Deadline approaching notifications - [ ] Personalized notification settings ### ๐Ÿ—„๏ธ **Data Management** #### 14. **Data Migration** - [ ] Migration scripts for new tables - [ ] Update existing schemas - [ ] Data cleanup and validation - [ ] Backup and restore procedures #### 15. **Monitoring and Logging** - [ ] Add metrics for feedback system - [ ] Logging for matching operations - [ ] Alerting for critical errors - [ ] Performance monitoring ## ๐Ÿ“Š **Project Status Summary** - **Completed**: 70-75% - **In Progress**: 0% - **Remaining**: 25-30% ## โฑ๏ธ **Estimated Completion Time** - **High Priority**: 2-3 weeks - **Medium Priority**: 3-4 weeks - **Low Priority**: 2-3 weeks - **Total Estimated Time**: 7-10 weeks ## ๐Ÿš€ **Next Steps** To complete Phase 1, start with the **Feedback System** implementation because: 1. It's the foundation for other features 2. Has lower complexity 3. Directly impacts user experience ## ๐Ÿ”ง New Features ### Generic XML Parser A powerful, generic XML parser built with Go generics that can parse any XML structure into Go structs. Perfect for handling complex XML formats like TED (Tenders Electronic Daily) notices. #### Features - **Generic Support**: Parse any XML structure that implements the `Parseable` interface - **Flexible Configuration**: Customizable parsing options for different use cases - **Built-in Validation**: Automatic validation of parsed structures - **Metadata Extraction**: Extract XML metadata and parsing information - **TED XML Support**: Pre-built models for TED contract notices - **Error Reporting**: Detailed error and warning reporting #### Quick Example ```go // Define your XML structure type Contract struct { XMLName xml.Name `xml:"Contract"` ID string `xml:"id,attr"` Name string `xml:"name"` Value string `xml:"value"` } func (c Contract) Validate() error { /* validation logic */ } func (c Contract) GetID() string { return c.ID } // Parse XML parser := xmlparser.NewParser[Contract](nil) contract, err := parser.ParseString(xmlData) ``` See [pkg/xmlparser/README.md](pkg/xmlparser/README.md) for complete documentation and examples. ## ๐Ÿ“ฆ Package Structure ``` โ”œโ”€โ”€ cmd/ # Application entry points โ”œโ”€โ”€ internal/ # Private application code โ”‚ โ”œโ”€โ”€ company/ # Company domain โ”‚ โ”œโ”€โ”€ customer/ # Customer domain โ”‚ โ””โ”€โ”€ user/ # User domain โ”œโ”€โ”€ pkg/ # Public packages โ”‚ โ”œโ”€โ”€ authorization/ # Authorization utilities โ”‚ โ”œโ”€โ”€ logger/ # Structured logging โ”‚ โ”œโ”€โ”€ mongo/ # MongoDB utilities โ”‚ โ”œโ”€โ”€ redis/ # Redis utilities โ”‚ โ”œโ”€โ”€ response/ # HTTP response utilities โ”‚ โ””โ”€โ”€ xmlparser/ # Generic XML parser โ”œโ”€โ”€ infra/ # Infrastructure configuration โ””โ”€โ”€ docs/ # Documentation ``` ## ๐Ÿงช Testing ```bash # Run all tests make test # Test specific package go test ./pkg/xmlparser/... # Test with coverage make test-coverage ``` ## ๐Ÿ› ๏ธ Development ### Prerequisites - Go 1.23+ - MongoDB - Redis (optional) ### Local Development ```bash # Clone repository git clone cd tm_back # Install dependencies go mod tidy # Run tests make test # Start development server make dev ``` ### Adding New Features 1. Follow Clean Architecture principles 2. Implement proper logging in service layer 3. Add comprehensive validation 4. Write unit tests 5. Update documentation ## ๐Ÿ“ Contributing 1. Fork the repository 2. Create a feature branch 3. Follow coding standards 4. Add tests for new features 5. Update documentation 6. Submit a pull request ## ๐Ÿ“„ License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.