Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"github.com/FOR-GAMERS/GAMERS-BE/internal/contest"
"github.com/FOR-GAMERS/GAMERS-BE/internal/discord"
"github.com/FOR-GAMERS/GAMERS-BE/internal/game"
"github.com/FOR-GAMERS/GAMERS-BE/internal/lol"
"github.com/FOR-GAMERS/GAMERS-BE/internal/global/common/router"
"github.com/FOR-GAMERS/GAMERS-BE/internal/global/config"
"github.com/FOR-GAMERS/GAMERS-BE/internal/global/middleware"
authProvider "github.com/FOR-GAMERS/GAMERS-BE/internal/global/security/jwt"
"github.com/FOR-GAMERS/GAMERS-BE/internal/notification"
"github.com/FOR-GAMERS/GAMERS-BE/internal/oauth2"
"github.com/FOR-GAMERS/GAMERS-BE/internal/point"
"github.com/FOR-GAMERS/GAMERS-BE/internal/storage"
Expand Down Expand Up @@ -136,6 +136,9 @@ func main() {
gameDeps.TeamService.SetContestRepository(contestDeps.ContestRepository)
gameDeps.TournamentResultService.SetContestDBPort(contestDeps.ContestRepository)

// LoL module - provides LoL-specific team balancing and custom match sessions
lolDeps := lol.ProvideLolDependencies(appRouter, db, redisClient, tokenService)

commentDeps := comment.ProvideCommentDependencies(db, appRouter, contestDeps.ContestRepository)

// Point module - provides Valorant score table management
Expand All @@ -160,20 +163,13 @@ func main() {
// Banner module - provides main banner management for homepage
bannerDeps := banner.ProvideBannerDependencies(db, appRouter)

// Notification module - provides SSE real-time notifications
notificationDeps := notification.ProvideNotificationDependencies(db, appRouter)

// Wire score table port for point calculation during contest application
contestDeps.ApplicationService.SetScoreTablePort(pointDeps.ScoreTableRepository)

// Wire notification handler to contest and game services
contestDeps.ApplicationService.SetNotificationHandler(notificationDeps.Service)
gameDeps.TeamService.SetNotificationHandler(notificationDeps.Service)

// Start Team Persistence Consumer for Write-Behind pattern
startTeamPersistenceConsumer(ctx, gameDeps)

setupRouter(appRouter, authDeps, userDeps, oauth2Deps, contestDeps, commentDeps, discordDeps, gameDeps, pointDeps, valorantDeps, storageDeps, bannerDeps, notificationDeps)
setupRouter(appRouter, authDeps, userDeps, oauth2Deps, contestDeps, commentDeps, discordDeps, gameDeps, pointDeps, valorantDeps, storageDeps, bannerDeps, lolDeps)

startServer(appRouter.Engine())
}
Expand Down Expand Up @@ -213,7 +209,7 @@ func setupRouter(
valorantDeps *valorant.Dependencies,
storageDeps *storage.Dependencies,
bannerDeps *banner.Dependencies,
notificationDeps *notification.Dependencies,
lolDeps *lol.Dependencies,
) *router.Router {

appRouter.Engine().Use(middleware.PrometheusMetrics())
Expand Down Expand Up @@ -241,8 +237,8 @@ func setupRouter(
if bannerDeps != nil {
bannerDeps.Controller.RegisterRoutes()
}
// Notification routes are registered in provider
_ = notificationDeps
lolDeps.Controller.RegisterRoutes()
lolDeps.SessionController.RegisterRoutes()

return appRouter
}
Expand Down
2 changes: 2 additions & 0 deletions db/migrations/000026_create_lol_custom_matches_table.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP TABLE IF EXISTS lol_custom_match_players;
DROP TABLE IF EXISTS lol_custom_matches;
40 changes: 40 additions & 0 deletions db/migrations/000026_create_lol_custom_matches_table.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
CREATE TABLE lol_custom_matches (
match_id BIGINT AUTO_INCREMENT PRIMARY KEY,
creator_user_id BIGINT NOT NULL,
status VARCHAR(16) NOT NULL DEFAULT 'PENDING',
winner VARCHAR(8) NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
modified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

CONSTRAINT fk_lol_matches_creator
FOREIGN KEY (creator_user_id) REFERENCES users(user_id)
ON DELETE CASCADE,

CONSTRAINT chk_lol_match_status
CHECK (status IN ('PENDING', 'FINISHED', 'CANCELLED')),

CONSTRAINT chk_lol_match_winner
CHECK (winner IN ('TEAM_A', 'TEAM_B') OR winner IS NULL),

INDEX idx_lol_match_creator (creator_user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE lol_custom_match_players (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
match_id BIGINT NOT NULL,
team VARCHAR(8) NOT NULL,
username VARCHAR(64) NOT NULL,
tag VARCHAR(16) NOT NULL,
rank VARCHAR(32) NOT NULL,
position VARCHAR(8) NOT NULL,
position_preference INT NOT NULL,

CONSTRAINT fk_lol_players_match
FOREIGN KEY (match_id) REFERENCES lol_custom_matches(match_id)
ON DELETE CASCADE,

CONSTRAINT chk_lol_player_team
CHECK (team IN ('TEAM_A', 'TEAM_B')),

INDEX idx_lol_players_match (match_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
27 changes: 4 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ module github.com/FOR-GAMERS/GAMERS-BE
go 1.25.5

require (
github.com/aws/aws-sdk-go-v2 v1.41.1
github.com/aws/aws-sdk-go-v2/config v1.32.7
github.com/aws/aws-sdk-go-v2/credentials v1.19.7
github.com/aws/aws-sdk-go-v2/service/s3 v1.95.1
cloud.google.com/go/storage v1.61.3
github.com/gin-contrib/cors v1.7.6
github.com/gin-gonic/gin v1.11.0
github.com/go-sql-driver/mysql v1.9.3
github.com/golang-jwt/jwt/v5 v5.3.0
github.com/golang-migrate/migrate/v4 v4.19.1
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/joho/godotenv v1.5.1
github.com/prometheus/client_golang v1.23.2
github.com/rabbitmq/amqp091-go v1.9.0
github.com/redis/go-redis/v9 v9.17.2
github.com/shirou/gopsutil/v4 v4.25.6
github.com/stretchr/testify v1.11.1
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.1
Expand All @@ -27,6 +26,7 @@ require (
golang.org/x/crypto v0.48.0
golang.org/x/oauth2 v0.36.0
golang.org/x/sync v0.20.0
google.golang.org/api v0.271.0
gorm.io/driver/mysql v1.6.0
gorm.io/gorm v1.31.1
)
Expand All @@ -39,7 +39,6 @@ require (
cloud.google.com/go/compute/metadata v0.9.0 // indirect
cloud.google.com/go/iam v1.5.3 // indirect
cloud.google.com/go/monitoring v1.24.3 // indirect
cloud.google.com/go/storage v1.61.3 // indirect
dario.cat/mergo v1.0.2 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
Expand All @@ -48,21 +47,6 @@ require (
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.55.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.4 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.17 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.17 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.17 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.8 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.17 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.0.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.30.9 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.13 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.41.6 // indirect
github.com/aws/smithy-go v1.24.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.14.2 // indirect
Expand Down Expand Up @@ -110,7 +94,6 @@ require (
github.com/google/s2a-go v0.1.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.14 // indirect
github.com/googleapis/gax-go/v2 v2.17.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
Expand Down Expand Up @@ -144,7 +127,6 @@ require (
github.com/prometheus/procfs v0.16.1 // indirect
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.58.0 // indirect
github.com/shirou/gopsutil/v4 v4.25.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spiffe/go-spiffe/v2 v2.6.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
Expand All @@ -171,7 +153,6 @@ require (
golang.org/x/text v0.34.0 // indirect
golang.org/x/time v0.15.0 // indirect
golang.org/x/tools v0.41.0 // indirect
google.golang.org/api v0.271.0 // indirect
google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260203192932-546029d2fa20 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 // indirect
Expand Down
Loading
Loading