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" "tercul/internal/app/tag" "tercul/internal/app/translation" "tercul/internal/app/user" "tercul/internal/app/work" "tercul/internal/domain" auth_domain "tercul/internal/domain/auth" localization_domain "tercul/internal/domain/localization" "tercul/internal/domain/search" work_domain "tercul/internal/domain/work" platform_auth "tercul/internal/platform/auth" ) // Dependencies holds all external dependencies for the application. type Dependencies struct { WorkRepo work_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 AnalyticsRepo analytics.Repository AuthRepo auth_domain.AuthRepository LocalizationRepo localization_domain.LocalizationRepository SearchClient search.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 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) localizationService := localization.NewService(deps.LocalizationRepo) authService := auth.NewService(deps.UserRepo, deps.JWTManager) workService := work.NewService(deps.WorkRepo, deps.SearchClient, authzService) 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, Analytics: deps.AnalyticsService, } }