mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Repository Structure:
- Move files from cluttered root directory into organized structure
- Create archive/ for archived data and scraper results
- Create bugulma/ for the complete application (frontend + backend)
- Create data/ for sample datasets and reference materials
- Create docs/ for comprehensive documentation structure
- Create scripts/ for utility scripts and API tools
Backend Implementation:
- Implement 3 missing backend endpoints identified in gap analysis:
* GET /api/v1/organizations/{id}/matching/direct - Direct symbiosis matches
* GET /api/v1/users/me/organizations - User organizations
* POST /api/v1/proposals/{id}/status - Update proposal status
- Add complete proposal domain model, repository, and service layers
- Create database migration for proposals table
- Fix CLI server command registration issue
API Documentation:
- Add comprehensive proposals.md API documentation
- Update README.md with Users and Proposals API sections
- Document all request/response formats, error codes, and business rules
Code Quality:
- Follow existing Go backend architecture patterns
- Add proper error handling and validation
- Match frontend expected response schemas
- Maintain clean separation of concerns (handler -> service -> repository)
68 lines
2.3 KiB
Go
68 lines
2.3 KiB
Go
package service
|
|
|
|
import (
|
|
"bugulma/backend/internal/domain"
|
|
"bugulma/backend/internal/graph"
|
|
"context"
|
|
)
|
|
|
|
// GraphTraversalService provides advanced graph database operations for industrial symbiosis analysis
|
|
// This service wraps the graph package Calculator interface
|
|
type GraphTraversalService struct {
|
|
calculator graph.Calculator
|
|
}
|
|
|
|
// NewGraphTraversalService creates a new graph traversal service
|
|
func NewGraphTraversalService(calculator graph.Calculator) *GraphTraversalService {
|
|
return &GraphTraversalService{
|
|
calculator: calculator,
|
|
}
|
|
}
|
|
|
|
// FindResourceChains finds chains of resource flows from waste to reuse
|
|
func (s *GraphTraversalService) FindResourceChains(
|
|
ctx context.Context,
|
|
startResourceType domain.ResourceType,
|
|
maxChainLength int,
|
|
minValue float64,
|
|
) ([]*graph.ResourceChain, error) {
|
|
return s.calculator.FindResourceChains(ctx, startResourceType, maxChainLength, minValue)
|
|
}
|
|
|
|
// FindSymbiosisNetworks identifies interconnected industrial symbiosis networks
|
|
func (s *GraphTraversalService) FindSymbiosisNetworks(
|
|
ctx context.Context,
|
|
minOrganizations int,
|
|
maxNetworkSize int,
|
|
) ([]*graph.SymbiosisNetwork, error) {
|
|
return s.calculator.FindSymbiosisNetworks(ctx, minOrganizations, maxNetworkSize)
|
|
}
|
|
|
|
// FindOptimalResourcePaths finds the most cost-effective paths for resource flows
|
|
func (s *GraphTraversalService) FindOptimalResourcePaths(
|
|
ctx context.Context,
|
|
sourceOrgID string,
|
|
targetOrgID string,
|
|
resourceType domain.ResourceType,
|
|
maxHops int,
|
|
) ([]*graph.ResourceChain, error) {
|
|
return s.calculator.FindOptimalResourcePaths(ctx, sourceOrgID, targetOrgID, resourceType, maxHops)
|
|
}
|
|
|
|
// AnalyzeNetworkCentrality calculates centrality measures for organizations
|
|
func (s *GraphTraversalService) AnalyzeNetworkCentrality(
|
|
ctx context.Context,
|
|
) (map[string]*graph.CentralityMetrics, error) {
|
|
return s.calculator.AnalyzeNetworkCentrality(ctx)
|
|
}
|
|
|
|
// GetNetworkStatistics provides overall network statistics
|
|
func (s *GraphTraversalService) GetNetworkStatistics(ctx context.Context) (*graph.NetworkStatistics, error) {
|
|
return s.calculator.GetNetworkStatistics(ctx)
|
|
}
|
|
|
|
// FindCircularEconomyCycles finds circular resource flow cycles
|
|
func (s *GraphTraversalService) FindCircularEconomyCycles(ctx context.Context) ([]*graph.CircularEconomyCycle, error) {
|
|
return s.calculator.FindCircularEconomyCycles(ctx)
|
|
}
|