package app import ( "tercul/internal/app/analytics" "tercul/internal/app/auth" "tercul/internal/app/author" "tercul/internal/app/authz" "tercul/internal/app/book" "tercul/internal/app/bookmark" "tercul/internal/app/category" "tercul/internal/app/collection" "tercul/internal/app/comment" "tercul/internal/app/contribution" "tercul/internal/app/like" "tercul/internal/app/localization" appsearch "tercul/internal/app/search" "tercul/internal/app/tag" "tercul/internal/app/translation" "tercul/internal/app/user" "tercul/internal/app/work" "tercul/internal/domain" domainsearch "tercul/internal/domain/search" platform_auth "tercul/internal/platform/auth" ) // Dependencies holds all external dependencies for the application. type Dependencies struct { WorkRepo domain.WorkRepository UserRepo domain.UserRepository AuthorRepo domain.AuthorRepository TranslationRepo domain.TranslationRepository CommentRepo domain.CommentRepository LikeRepo domain.LikeRepository BookmarkRepo domain.BookmarkRepository CollectionRepo domain.CollectionRepository TagRepo domain.TagRepository CategoryRepo domain.CategoryRepository BookRepo domain.BookRepository PublisherRepo domain.PublisherRepository SourceRepo domain.SourceRepository CopyrightRepo domain.CopyrightRepository MonetizationRepo domain.MonetizationRepository ContributionRepo domain.ContributionRepository UserProfileRepo domain.UserProfileRepository AnalyticsRepo analytics.Repository AuthRepo domain.AuthRepository LocalizationRepo domain.LocalizationRepository SearchClient domainsearch.SearchClient AnalyticsService analytics.Service JWTManager platform_auth.JWTManagement } // Application is a container for all the application-layer services. type Application struct { Author *author.Service Book *book.Service Bookmark *bookmark.Service Category *category.Service Collection *collection.Service Comment *comment.Service Contribution *contribution.Service Like *like.Service Tag *tag.Service Translation *translation.Service User *user.Service Localization *localization.Service Auth *auth.Service Authz *authz.Service Work *work.Service Search appsearch.Service Analytics analytics.Service } func NewApplication(deps Dependencies) *Application { authzService := authz.NewService(deps.WorkRepo, deps.TranslationRepo) authorService := author.NewService(deps.AuthorRepo) bookService := book.NewService(deps.BookRepo, authzService) bookmarkService := bookmark.NewService(deps.BookmarkRepo, deps.AnalyticsService) categoryService := category.NewService(deps.CategoryRepo) collectionService := collection.NewService(deps.CollectionRepo) commentService := comment.NewService(deps.CommentRepo, authzService, deps.AnalyticsService) contributionCommands := contribution.NewCommands(deps.ContributionRepo, authzService) contributionService := contribution.NewService(contributionCommands) likeService := like.NewService(deps.LikeRepo, deps.AnalyticsService) tagService := tag.NewService(deps.TagRepo) translationService := translation.NewService(deps.TranslationRepo, authzService) userService := user.NewService(deps.UserRepo, authzService, deps.UserProfileRepo) localizationService := localization.NewService(deps.LocalizationRepo) authService := auth.NewService(deps.UserRepo, deps.JWTManager) workService := work.NewService(deps.WorkRepo, deps.SearchClient, authzService) searchService := appsearch.NewService(deps.SearchClient, localizationService) return &Application{ Author: authorService, Book: bookService, Bookmark: bookmarkService, Category: categoryService, Collection: collectionService, Comment: commentService, Contribution: contributionService, Like: likeService, Tag: tagService, Translation: translationService, User: userService, Localization: localizationService, Auth: authService, Authz: authzService, Work: workService, Search: searchService, Analytics: deps.AnalyticsService, } }