├── game-result-screen.md ├── hero-section-design.md ├── wager-battleground-screen.md ├── answer-selection-submission.md ├── backend ├── .gitignore ├── src │ ├── challenges │ │ ├── enums │ │ │ ├── reward-type.enum.ts │ │ │ └── challenge-type.enum.ts │ │ ├── jobs │ │ │ └── daily-reset.job.ts │ │ ├── dto │ │ │ └── update-progress.dto.ts │ │ ├── entities │ │ │ ├── challenge.entity.ts │ │ │ └── challenge-progress.entity.ts │ │ ├── services │ │ │ ├── challenge.service.ts │ │ │ ├── reward.service.ts │ │ │ ├── notification.service.ts │ │ │ └── challenge-generator.service.ts │ │ └── controllers │ │ │ └── challenge.controller.ts │ ├── game-session │ │ ├── enums │ │ │ ├── game-status-enum.ts │ │ │ └── game-status.enum.ts │ │ ├── providers │ │ │ ├── game-session.service.ts │ │ │ └── game-session.service.spec.ts │ │ ├── game-session.controller.spec.ts │ │ ├── game-session.module.ts │ │ └── dto │ │ │ └── game-session.dto.ts │ ├── wager │ │ ├── entities │ │ │ └── wager.entity.ts │ │ ├── dto │ │ │ ├── update-wager-dto.dto.ts │ │ │ └── create-wager-dto.dto.ts │ │ ├── wager.module.ts │ │ ├── provider │ │ │ ├── wager.service.spec.ts │ │ │ └── wager.service.ts │ │ └── wager.controller.spec.ts │ ├── song │ │ ├── entities │ │ │ └── song.entity.ts │ │ ├── dto │ │ │ ├── update-song-dto.dto.ts │ │ │ └── create-song-dto.dto.ts │ │ ├── song.module.ts │ │ ├── providers │ │ │ ├── song.service.spec.ts │ │ │ └── song.service.ts │ │ └── song.controller.spec.ts │ ├── auth │ │ ├── constant │ │ │ └── auth-constant.ts │ │ ├── http │ │ │ └── sign-in.endpoint.http │ │ ├── decorators │ │ │ ├── public.decorator.ts │ │ │ └── current-user.decorator.ts │ │ ├── dtos │ │ │ ├── forgot-password.dto.ts │ │ │ ├── refresh-token.dto.ts │ │ │ ├── signIn.dto.ts │ │ │ └── reset-password.dto.ts │ │ ├── guard │ │ │ ├── jwt-auth.guard.ts │ │ │ └── throttler.guard.ts │ │ ├── providers │ │ │ ├── hashing-provider.ts │ │ │ └── bcrypt-provider.ts │ │ └── authConfig │ │ │ └── jwt.config.ts │ ├── chat-room │ │ ├── dto │ │ │ ├── create-chat-room.dto.ts │ │ │ └── update-chat-room.dto.ts │ │ ├── chat-room.module.ts │ │ ├── chat-room.entity.ts │ │ └── chat-room.service.ts │ ├── .DS_Store │ ├── state-recovery │ │ ├── dto │ │ │ ├── create-state-recovery.dto.ts │ │ │ └── update-state-recovery.dto.ts │ │ ├── state-recovery.module.ts │ │ ├── entities │ │ │ ├── state-audit.entity.ts │ │ │ └── game-state.entity.ts │ │ ├── state-recovery.service.spec.ts │ │ ├── state-recovery.controller.spec.ts │ │ └── state-recovery.service.ts │ ├── common │ │ ├── enums │ │ │ └── role.enum.ts │ │ ├── decorators │ │ │ └── roles.decorator.ts │ │ └── pagination │ │ │ ├── pagination.module.ts │ │ │ ├── pagination-query-dto.dto.ts │ │ │ └── interfaces │ │ │ └── pagination-interface.ts │ ├── social │ │ ├── services │ │ │ ├── profile.service.ts │ │ │ ├── activity.service.ts │ │ │ ├── challenge.service.ts │ │ │ └── notification.service.ts │ │ ├── controllers │ │ │ ├── profile.controller.ts │ │ │ ├── activity.controller.ts │ │ │ ├── challenge.controller.ts │ │ │ └── notification.controller.ts │ │ ├── dto │ │ │ └── create-challenge.dto.ts │ │ ├── friend │ │ │ ├── friend.service.spec.ts │ │ │ └── friend.controller.spec.ts │ │ ├── profile │ │ │ ├── profile.service.spec.ts │ │ │ └── profile.controller.spec.ts │ │ ├── activity │ │ │ ├── activity.service.spec.ts │ │ │ └── activity.controller.spec.ts │ │ ├── challenge │ │ │ ├── challenge.service.spec.ts │ │ │ └── challenge.controller.spec.ts │ │ ├── notification │ │ │ ├── notification.gateway.spec.ts │ │ │ ├── notification.service.spec.ts │ │ │ └── notification.controller.spec.ts │ │ └── entities │ │ │ └── profile.entity.ts │ ├── analytics │ │ ├── enums │ │ │ └── analytics-role.enum.ts │ │ ├── decorators │ │ │ └── analytics-roles.decorator.ts │ │ ├── dto │ │ │ ├── date-range.dto.ts │ │ │ ├── analytics-response.dto.ts │ │ │ ├── player-engagement.dto.ts │ │ │ └── aggregated-analytics.dto.ts │ │ ├── guards │ │ │ ├── analytics-auth.guard.ts │ │ │ └── analytics-roles.guard.ts │ │ ├── constants │ │ │ └── analytics.constants.ts │ │ └── entities │ │ │ ├── player-engagement.entity.ts │ │ │ ├── token.entity.ts │ │ │ ├── user-progression.entity.ts │ │ │ └── song-category.entity.ts │ ├── game │ │ ├── strategies │ │ │ └── scoring │ │ │ │ ├── scoring-strategy.interface.ts │ │ │ │ ├── classic-scoring.strategy.ts │ │ │ │ ├── endless-scoring.strategy.ts │ │ │ │ └── time-attack-scoring.strategy.ts │ │ ├── dtos │ │ │ ├── queue-player.dto.ts │ │ │ └── start-game.dto.ts │ │ ├── interfaces │ │ │ ├── game-result.interface.ts │ │ │ └── game-mode.interface.ts │ │ ├── decorators │ │ │ └── user.decorator.ts │ │ └── game-modes │ │ │ └── battle-royale-scoring.strategy.ts │ ├── notification │ │ ├── enums │ │ │ ├── notification-type.enum.ts │ │ │ └── notifcation-status.enum.ts │ │ ├── notification.module.ts │ │ ├── providers │ │ │ ├── notification.service.ts │ │ │ └── notification.service.spec.ts │ │ ├── dto │ │ │ └── notiication.dto.ts │ │ ├── notification.entity.ts │ │ └── notification.controller.spec.ts │ ├── app.service.ts │ ├── modules │ │ ├── share │ │ │ ├── enums │ │ │ │ ├── platform-type.enum.ts │ │ │ │ └── share-type.enum.ts │ │ │ ├── entities │ │ │ │ └── share-analytics.entity.ts │ │ │ └── dto │ │ │ │ └── create-share.dto.ts │ │ ├── auth │ │ │ ├── guards │ │ │ │ └── jwt-auth.guard.ts │ │ │ ├── auth.module.ts │ │ │ └── strategies │ │ │ │ └── jwt.strategy.ts │ │ ├── activity │ │ │ ├── dto │ │ │ │ └── create-activity-item.dto.ts │ │ │ ├── activity.module.ts │ │ │ └── entities │ │ │ │ └── activity-item.entity.ts │ │ └── notification │ │ │ ├── dto │ │ │ └── create-notification.dto.ts │ │ │ ├── notification.module.ts │ │ │ └── entities │ │ │ └── notification.entity.ts │ ├── coupons │ │ ├── dto │ │ │ ├── apply-coupon.dto.ts │ │ │ ├── update-coupon.dto.ts │ │ │ └── generate-bulk-coupons.dto.ts │ │ └── controllers │ │ │ └── coupon.controller.ts │ ├── room │ │ ├── dto │ │ │ ├── update-room.dto.ts │ │ │ ├── create-room.dto.ts │ │ │ └── get-room-base-dto.dto.ts │ │ ├── entities │ │ │ └── room.entity.ts │ │ └── room.module.ts │ ├── songs │ │ ├── dto │ │ │ ├── update-song.dto.ts │ │ │ └── get-songs-base-dto.dto.ts │ │ ├── songs.service.spec.ts │ │ ├── songs.controller.spec.ts │ │ └── songs.module.ts │ ├── power-ups │ │ ├── dtos │ │ │ ├── purchase-power-up.dto.ts │ │ │ ├── create-power-up.dto.ts │ │ │ └── update-power-up.dto.ts │ │ ├── entities │ │ │ ├── power-up.entity.ts │ │ │ └── power-up-purchase.entity.ts │ │ ├── power-up-validation.middleware.ts │ │ └── power-up.module.ts │ ├── scoring │ │ ├── dto │ │ │ ├── update-scoring.dto.ts │ │ │ └── create-scoring.dto.ts │ │ ├── constants │ │ │ └── scoring.constants.ts │ │ ├── types │ │ │ └── scoring.types.ts │ │ ├── events │ │ │ └── scoring.events.ts │ │ ├── entities │ │ │ └── scoring.entity.ts │ │ ├── scoring.controller.spec.ts │ │ └── scoring.module.ts │ ├── store │ │ ├── dto │ │ │ ├── purchase.dto.ts │ │ │ └── create-item.dto.ts │ │ ├── store.module.ts │ │ ├── entities │ │ │ ├── inventory.entity.ts │ │ │ ├── transaction.entity.ts │ │ │ └── store-item.entity.ts │ │ └── controllers │ │ │ └── store.controller.ts │ ├── game-mode │ │ ├── dto │ │ │ ├── update-game-mode.dto.ts │ │ │ └── create-game-mode.dto.ts │ │ ├── game-mode.module.ts │ │ ├── game-mode.service.spec.ts │ │ ├── game-mode.controller.ts │ │ ├── entities │ │ │ └── game-mode.entity.ts │ │ └── game-mode.controller.spec.ts │ ├── questions │ │ ├── dto │ │ │ ├── update-question.dto.ts │ │ │ ├── question-filters.dto.ts │ │ │ └── get-question-base-dto.dto.ts │ │ ├── questions.module.ts │ │ ├── questions.controller.spec.ts │ │ └── exceptions │ │ │ └── question.exception.ts │ ├── reward │ │ ├── dto │ │ │ ├── update-reward-dto.dto.ts │ │ │ └── create-reward-dto.dto.ts │ │ ├── reward.module.ts │ │ ├── providers │ │ │ ├── reward.service.ts │ │ │ └── reward.service.spec.ts │ │ └── reward.controller.spec.ts │ ├── song-genre │ │ ├── dtos │ │ │ ├── update-song-genre.dto.ts │ │ │ └── create-song.dto.ts │ │ ├── entities │ │ │ ├── tag.entity.ts │ │ │ ├── genre-challenge.entity.ts │ │ │ ├── genre.entity.ts │ │ │ └── user-genre-preference.entity.ts │ │ ├── services │ │ │ └── song.service.spec.ts │ │ └── controllers │ │ │ └── song.controller.spec.ts │ ├── game-results │ │ ├── dto │ │ │ ├── leaderboard-entry.dto.ts │ │ │ ├── game-result.dto.ts │ │ │ └── get-gamesresult-base-dto.dto.ts │ │ ├── events │ │ │ └── game-result.event.ts │ │ ├── entities │ │ │ └── game-result.entity.ts │ │ ├── game-results.module.ts │ │ └── game-results.controller.spec.ts │ ├── music-education │ │ ├── music-theory-lesson.service.ts │ │ ├── genre-history │ │ │ ├── entities │ │ │ │ └── genre-history.entity.ts │ │ │ ├── providers │ │ │ │ └── genre-history.service.ts │ │ │ └── genre-history.controller.ts │ │ ├── quiz │ │ │ ├── entities │ │ │ │ └── quiz.entity.ts │ │ │ ├── providers │ │ │ │ └── quiz.service.ts │ │ │ └── quiz.controller.ts │ │ ├── artists │ │ │ ├── entities │ │ │ │ └── artist.entity.ts │ │ │ ├── providers │ │ │ │ └── artist.service.ts │ │ │ └── artist.controller.ts │ │ ├── music-lessons │ │ │ ├── entities │ │ │ │ └── music-theory-lesson.entity.ts │ │ │ ├── providers │ │ │ │ └── music-theory-lesson.service.ts │ │ │ └── music.controller.ts │ │ ├── music-theory-lesson.controller.ts │ │ ├── user-progress │ │ │ ├── entities │ │ │ │ └── user-progress.entity.ts │ │ │ ├── user-progress.controller.ts │ │ │ └── providers │ │ │ │ └── user-progress.service.ts │ │ ├── music-theory-lesson.service.spec.ts │ │ └── music-education.controller.spec.ts │ ├── room-movement │ │ ├── dtos │ │ │ ├── join-room.dto.ts │ │ │ ├── leave-room.dto.ts │ │ │ └── update-player-status.dto.ts │ │ └── entities │ │ │ └── room.entity.ts │ ├── logger │ │ └── logger.module.ts │ ├── redis │ │ ├── redis.module.ts │ │ ├── redis.service.spec.ts │ │ └── redis.service.ts │ ├── websocket-game comms │ │ └── game.module.ts │ ├── exceptions │ │ └── ws.exception.ts │ ├── db-migration │ │ ├── db-migration.constants.ts │ │ ├── entities │ │ │ ├── migration-lock.entity.ts │ │ │ └── backup-metadata.entity.ts │ │ └── interfaces │ │ │ └── validator.interface.ts │ ├── voice │ │ ├── dto │ │ │ ├── join-room.dto.ts │ │ │ ├── voice-settings.dto.ts │ │ │ └── create-room.dto.ts │ │ ├── interfaces │ │ │ ├── room.interface.ts │ │ │ └── participant.interface.ts │ │ └── entities │ │ │ └── room.entity.ts │ ├── practice │ │ ├── dto │ │ │ ├── update-practice-item.dto.ts │ │ │ ├── submit-result.dto.ts │ │ │ └── create-session.dto.ts │ │ └── controllers │ │ │ └── user-progress.controller.ts │ ├── game-insights │ │ ├── DTO │ │ │ ├── CreateGameSessionDto.ts │ │ │ ├── CreateUserBehaviorDto.ts │ │ │ └── CreatePlayerPerformanceDto.ts │ │ ├── GameSession.entity.ts │ │ ├── PlayerPerformance.ts │ │ ├── UserBehavior.ts │ │ └── game-insights.module.ts │ ├── app.controller.ts │ ├── sync │ │ ├── interfaces │ │ │ ├── mergeable.interface.ts │ │ │ └── sync-strategy.interface.ts │ │ ├── dto │ │ │ ├── delta-update.dto.ts │ │ │ └── sync-response.dto.ts │ │ └── sync.module.ts │ ├── config-manager │ │ ├── config-manager.module.ts │ │ └── entities │ │ │ ├── config-audit.entity.ts │ │ │ └── config.entity.ts │ ├── difficulty │ │ ├── entities │ │ │ └── difficulty.entity.ts │ │ └── difficulty.service.ts │ ├── leaderboard │ │ ├── leaderboard.module.ts │ │ ├── leaderboard-entry.entity.ts │ │ ├── leaderboard.entity.ts │ │ ├── dto │ │ │ └── leaderboard.dto.ts │ │ ├── providers │ │ │ └── leaderboard.service.spec.ts │ │ └── leaderboard.controller.spec.ts │ ├── user │ │ ├── providers │ │ │ └── hashing.provider.ts │ │ └── dtos │ │ │ └── get-users-base-dto.dto.ts │ ├── content-generator │ │ ├── processors │ │ │ └── content-queue.processor.ts │ │ └── content-generator.module.ts │ ├── referral │ │ ├── dto │ │ │ ├── claim-referral.dto.ts │ │ │ └── create-referral.dto.ts │ │ └── referral.module.ts │ ├── config │ │ ├── validation.schema.ts │ │ ├── configuration.ts │ │ ├── test.controller.ts │ │ ├── config.module.ts │ │ └── providers │ │ │ └── game.service.spec.ts │ ├── player-engagement │ │ └── dto │ │ │ └── player-engagement.dto.ts │ ├── progression │ │ ├── dtos │ │ │ └── xp-event.dto.ts │ │ ├── entities │ │ │ ├── player-skill.entity.ts │ │ │ └── player-level.entity.ts │ │ ├── gateways │ │ │ └── progression.gateway.ts │ │ └── controllers │ │ │ └── progression.controller.ts │ ├── interceptors │ │ └── global.interceptor.ts │ ├── tournament │ │ ├── tournament.module.ts │ │ ├── tournament.service.spec.ts │ │ ├── tournament.entity.ts │ │ └── scheduling.service.ts │ ├── achievement │ │ ├── achievement.service.spec.ts │ │ ├── achievement.gateway.ts │ │ ├── achievement.controller.spec.ts │ │ ├── dto │ │ │ └── create-achievement.dto.ts │ │ ├── entities │ │ │ └── user-achievement.entity.ts │ │ └── achievement.module.ts │ ├── transports │ │ └── custom-transport.ts │ ├── filters │ │ └── ws-exception.filter.ts │ ├── app.controller.spec.ts │ ├── replay-analysis │ │ ├── entities │ │ │ └── pattern.entity.ts │ │ └── replay-analysis.module.ts │ └── http-yac │ │ ├── app.http │ │ ├── profile.http │ │ ├── activity.http │ │ ├── challenge.http │ │ ├── notification.http │ │ └── test.http ├── .prettierrc ├── .DS_Store ├── tsconfig.build.json ├── .env.development ├── .env.production ├── nest-cli.json ├── test │ ├── jest-e2e.json │ └── app.e2e-spec.ts ├── tsconfig.json └── .eslintrc.js ├── .tool-versions ├── onchain ├── .gitignore ├── src │ └── lib.cairo └── Scarb.toml ├── frontend ├── .prettierignore ├── .prettierrc ├── src │ ├── store │ │ ├── index.ts │ │ ├── game-store.ts │ │ ├── modal-store.ts │ │ └── GameStores.ts │ ├── lib │ │ ├── dojo │ │ │ ├── index.ts │ │ │ ├── types │ │ │ │ └── manifest.d.ts │ │ │ └── world.ts │ │ └── react-query.ts │ ├── app │ │ ├── favicon.ico │ │ ├── metadata.tsx │ │ ├── metadata.ts │ │ └── admin │ │ │ └── page.tsx │ ├── fonts │ │ └── inter-v.ttf │ ├── types │ │ └── wasm.d.ts │ ├── __mocks__ │ │ ├── types.ts │ │ └── dojoCore.ts │ ├── hooks │ │ ├── useSongs.ts │ │ ├── useCategories.ts │ │ ├── useLeaderboard.ts │ │ └── useGameService.ts │ ├── components │ │ ├── providers │ │ │ └── client-provider.tsx │ │ └── atoms │ │ │ ├── counter-badge.tsx │ │ │ └── score-badge.tsx │ └── __tests__ │ │ └── alias.test.ts ├── public │ ├── rot.png │ ├── Frame.png │ ├── Noise.png │ ├── failed.png │ ├── image1.png │ ├── image2.png │ ├── image3.png │ ├── success.png │ ├── trophy.png │ ├── warning.png │ ├── newbadge.png │ ├── images │ │ └── set-username-noise-image.png │ ├── Star 78.svg │ └── dropdown.svg ├── postcss.config.mjs ├── next.config.ts ├── tailwind.config.ts ├── eslint.config.mjs ├── .gitignore ├── tsconfig.json └── jest.config.js ├── notification-center-achievement-and-badge-screen-user-profile.md ├── .DS_Store ├── assets └── LyricsFlipLogo.png ├── .gitignore ├── docs └── notion-link.md ├── Contributors Figma Design ├── package.json └── .github └── workflows └── cairo.yml /game-result-screen.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hero-section-design.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /wager-battleground-screen.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /answer-selection-submission.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | .env.* -------------------------------------------------------------------------------- /backend/src/challenges/enums/reward-type.enum.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/challenges/jobs/daily-reset.job.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | starknet-foundry 0.31.0 2 | scarb 2.8.4 -------------------------------------------------------------------------------- /backend/src/challenges/dto/update-progress.dto.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/challenges/entities/challenge.entity.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/challenges/enums/challenge-type.enum.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/challenges/services/challenge.service.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/challenges/services/reward.service.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/game-session/enums/game-status-enum.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /onchain/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .snfoundry_cache/ 3 | -------------------------------------------------------------------------------- /backend/src/challenges/controllers/challenge.controller.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/challenges/services/notification.service.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | build/ -------------------------------------------------------------------------------- /backend/src/challenges/entities/challenge-progress.entity.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/challenges/services/challenge-generator.service.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/src/wager/entities/wager.entity.ts: -------------------------------------------------------------------------------- 1 | export class Wager{} -------------------------------------------------------------------------------- /backend/src/song/entities/song.entity.ts: -------------------------------------------------------------------------------- 1 | export class Song {} 2 | -------------------------------------------------------------------------------- /notification-center-achievement-and-badge-screen-user-profile.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/.DS_Store -------------------------------------------------------------------------------- /backend/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /backend/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/backend/.DS_Store -------------------------------------------------------------------------------- /backend/src/auth/constant/auth-constant.ts: -------------------------------------------------------------------------------- 1 | export const REQUEST_USER_KEY = 'user'; 2 | -------------------------------------------------------------------------------- /backend/src/chat-room/dto/create-chat-room.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateChatRoomDto {} 2 | -------------------------------------------------------------------------------- /frontend/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /frontend/src/store/index.ts: -------------------------------------------------------------------------------- 1 | export * from './GameStores'; 2 | export * from './Types'; -------------------------------------------------------------------------------- /frontend/src/lib/dojo/index.ts: -------------------------------------------------------------------------------- 1 | export * from './world'; 2 | export * from './DojoProvider'; -------------------------------------------------------------------------------- /backend/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/backend/src/.DS_Store -------------------------------------------------------------------------------- /backend/src/state-recovery/dto/create-state-recovery.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateStateRecoveryDto {} 2 | -------------------------------------------------------------------------------- /frontend/public/rot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/rot.png -------------------------------------------------------------------------------- /assets/LyricsFlipLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/assets/LyricsFlipLogo.png -------------------------------------------------------------------------------- /frontend/public/Frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/Frame.png -------------------------------------------------------------------------------- /frontend/public/Noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/Noise.png -------------------------------------------------------------------------------- /frontend/public/failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/failed.png -------------------------------------------------------------------------------- /frontend/public/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/image1.png -------------------------------------------------------------------------------- /frontend/public/image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/image2.png -------------------------------------------------------------------------------- /frontend/public/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/image3.png -------------------------------------------------------------------------------- /frontend/public/success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/success.png -------------------------------------------------------------------------------- /frontend/public/trophy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/trophy.png -------------------------------------------------------------------------------- /frontend/public/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/warning.png -------------------------------------------------------------------------------- /frontend/public/newbadge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/newbadge.png -------------------------------------------------------------------------------- /frontend/src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/src/app/favicon.ico -------------------------------------------------------------------------------- /backend/src/auth/http/sign-in.endpoint.http: -------------------------------------------------------------------------------- 1 | POST https://localhost:3000/auth/sign-in 2 | Content-Type: application/JSON -------------------------------------------------------------------------------- /frontend/src/fonts/inter-v.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/src/fonts/inter-v.ttf -------------------------------------------------------------------------------- /frontend/src/types/wasm.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.wasm' { 2 | const content: string; 3 | export default content; 4 | } -------------------------------------------------------------------------------- /frontend/src/lib/dojo/types/manifest.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.json" { 2 | const value: any; 3 | export default value; 4 | } -------------------------------------------------------------------------------- /backend/src/common/enums/role.enum.ts: -------------------------------------------------------------------------------- 1 | 2 | export enum UserRole { 3 | ADMIN = 'admin', 4 | PLAYER = 'player', 5 | USER = 'user', 6 | } -------------------------------------------------------------------------------- /backend/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /backend/node_modules 2 | 3 | /frontend/node_modules 4 | 5 | /backend/.env 6 | node_modules 7 | backend/dist/ 8 | backend/dist/ 9 | -------------------------------------------------------------------------------- /backend/src/social/services/profile.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class ProfileService {} 5 | -------------------------------------------------------------------------------- /frontend/src/app/metadata.tsx: -------------------------------------------------------------------------------- 1 | export const metadata = { 2 | title: "Create Next App", 3 | description: "Generated by create next app", 4 | }; -------------------------------------------------------------------------------- /backend/src/social/services/activity.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class ActivityService {} 5 | -------------------------------------------------------------------------------- /backend/src/social/services/challenge.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class ChallengeService {} 5 | -------------------------------------------------------------------------------- /frontend/public/images/set-username-noise-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songifi/lyricsflip/HEAD/frontend/public/images/set-username-noise-image.png -------------------------------------------------------------------------------- /backend/src/social/services/notification.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class NotificationService {} 5 | -------------------------------------------------------------------------------- /backend/src/analytics/enums/analytics-role.enum.ts: -------------------------------------------------------------------------------- 1 | export enum AnalyticsRole { 2 | VIEWER = "viewer", 3 | ANALYST = "analyst", 4 | ADMIN = "admin", 5 | } 6 | 7 | -------------------------------------------------------------------------------- /frontend/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | const config = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /backend/src/game/strategies/scoring/scoring-strategy.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ScoringStrategy { 2 | calculateScore(gameData: any, playerId: string): number; 3 | } -------------------------------------------------------------------------------- /backend/src/notification/enums/notification-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum NotificationType { 2 | INFO = 'info', 3 | SUCCESS = 'success', 4 | WARNING = 'warning', 5 | } 6 | -------------------------------------------------------------------------------- /backend/src/social/controllers/profile.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller } from '@nestjs/common'; 2 | 3 | @Controller('profile') 4 | export class ProfileController {} 5 | -------------------------------------------------------------------------------- /backend/.env.development: -------------------------------------------------------------------------------- 1 | NODE_ENV=development 2 | PORT=3000 3 | DATABASE_URL=postgresql://postgres:uwais7@localhost:5432/dev-db 4 | JWT_SECRET=devsecret 5 | STARKNET_NETWORK=alpha -------------------------------------------------------------------------------- /backend/.env.production: -------------------------------------------------------------------------------- 1 | NODE_ENV=production 2 | PORT=8080 3 | DATABASE_URL=postgres://user:password@prod-db-host/prod-db 4 | JWT_SECRET=supersecret 5 | STARKNET_NETWORK=mainnet -------------------------------------------------------------------------------- /backend/src/social/controllers/activity.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller } from '@nestjs/common'; 2 | 3 | @Controller('activity') 4 | export class ActivityController {} 5 | -------------------------------------------------------------------------------- /backend/src/social/controllers/challenge.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller } from '@nestjs/common'; 2 | 3 | @Controller('challenge') 4 | export class ChallengeController {} 5 | -------------------------------------------------------------------------------- /backend/src/social/controllers/notification.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller } from '@nestjs/common'; 2 | 3 | @Controller('notification') 4 | export class NotificationController {} 5 | -------------------------------------------------------------------------------- /frontend/next.config.ts: -------------------------------------------------------------------------------- 1 | import type { NextConfig } from "next"; 2 | 3 | const nextConfig: NextConfig = { 4 | /* config options here */ 5 | }; 6 | 7 | export default nextConfig; 8 | -------------------------------------------------------------------------------- /docs/notion-link.md: -------------------------------------------------------------------------------- 1 | ## Notion Documentation 2 | 3 | The project documentation is available [here](https://www.notion.so/LyricFlip-Documentation-188644d19c538007af9be7fafb912b9c?pvs=4). 4 | -------------------------------------------------------------------------------- /Contributors Figma Design: -------------------------------------------------------------------------------- 1 | ## Design on contributors page for both moblie and web Design. 2 | 3 | https://www.figma.com/design/cUgNi0Ck7HS6QHLim7xOTY/Projects?node-id=89-259&t=VGBgLi8VhPgV9N5u-1 4 | -------------------------------------------------------------------------------- /frontend/src/app/metadata.ts: -------------------------------------------------------------------------------- 1 | import type { Metadata } from "next"; 2 | 3 | export const metadata: Metadata = { 4 | title: "LyricsFlip", 5 | description: "A decentralized lyrics game", 6 | }; -------------------------------------------------------------------------------- /backend/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /backend/src/modules/share/enums/platform-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum PlatformType { 2 | TWITTER = 'twitter', 3 | FACEBOOK = 'facebook', 4 | DISCORD = 'discord', 5 | INTERNAL = 'internal', 6 | } 7 | -------------------------------------------------------------------------------- /backend/src/auth/decorators/public.decorator.ts: -------------------------------------------------------------------------------- 1 | import { SetMetadata } from '@nestjs/common'; 2 | 3 | export const IS_PUBLIC_KEY = 'isPublic'; 4 | export const Public = () => SetMetadata(IS_PUBLIC_KEY, true); -------------------------------------------------------------------------------- /backend/src/auth/dtos/forgot-password.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsEmail, IsNotEmpty } from 'class-validator'; 2 | 3 | export class ForgotPasswordDto { 4 | @IsEmail() 5 | @IsNotEmpty() 6 | email: string; 7 | } -------------------------------------------------------------------------------- /backend/src/auth/dtos/refresh-token.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString, } from "class-validator"; 2 | 3 | export class RefreshTokenDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | refreshToken: string 7 | } -------------------------------------------------------------------------------- /backend/src/coupons/dto/apply-coupon.dto.ts: -------------------------------------------------------------------------------- 1 | // src/coupons/dto/apply-coupon.dto.ts 2 | import { IsString } from 'class-validator'; 3 | 4 | export class ApplyCouponDto { 5 | @IsString() 6 | code: string; 7 | } 8 | -------------------------------------------------------------------------------- /backend/src/modules/share/enums/share-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum ShareType { 2 | LYRIC_CARD = 'lyric_card', 3 | GAME_RESULT = 'game_result', 4 | ACHIEVEMENT = 'achievement', 5 | PLAYLIST = 'playlist', 6 | } 7 | -------------------------------------------------------------------------------- /backend/src/room/dto/update-room.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/swagger'; 2 | import { CreateRoomDto } from './create-room.dto'; 3 | 4 | export class UpdateRoomDto extends PartialType(CreateRoomDto) {} -------------------------------------------------------------------------------- /backend/src/songs/dto/update-song.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/swagger'; 2 | import { CreateSongDto } from './create-song.dto'; 3 | 4 | export class UpdateSongDto extends PartialType(CreateSongDto) {} -------------------------------------------------------------------------------- /backend/src/power-ups/dtos/purchase-power-up.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNumber, IsPositive } from 'class-validator'; 2 | 3 | export class PurchasePowerUpDto { 4 | @IsNumber() 5 | @IsPositive() 6 | powerUpId: number; 7 | } 8 | -------------------------------------------------------------------------------- /backend/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src", 5 | "compilerOptions": { 6 | "deleteOutDir": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /backend/src/common/decorators/roles.decorator.ts: -------------------------------------------------------------------------------- 1 | import { SetMetadata } from '@nestjs/common'; 2 | 3 | export const ROLES_KEY = 'roles'; 4 | 5 | export const Roles = (...roles: string[]) => 6 | SetMetadata(ROLES_KEY, roles); 7 | -------------------------------------------------------------------------------- /backend/src/song/dto/update-song-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateSongDto } from './create-song-dto.dto'; 3 | 4 | export class UpdateSongDto extends PartialType(CreateSongDto) {} 5 | -------------------------------------------------------------------------------- /backend/src/scoring/dto/update-scoring.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/swagger'; 2 | import { CreateScoringDto } from './create-scoring.dto'; 3 | 4 | export class UpdateScoringDto extends PartialType(CreateScoringDto) {} 5 | -------------------------------------------------------------------------------- /backend/src/store/dto/purchase.dto.ts: -------------------------------------------------------------------------------- 1 | // src/store/dto/purchase.dto.ts 2 | export class PurchaseDto { 3 | @IsString() 4 | @IsNotEmpty() 5 | itemId: string; 6 | 7 | @IsNumber() 8 | @Min(1) 9 | quantity: number; 10 | } -------------------------------------------------------------------------------- /backend/src/wager/dto/update-wager-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateWagerDto } from './create-wager-dto.dto'; 3 | 4 | export class UpdateWagerDto extends PartialType(CreateWagerDto) {} 5 | -------------------------------------------------------------------------------- /backend/src/chat-room/dto/update-chat-room.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/swagger'; 2 | import { CreateChatRoomDto } from './create-chat-room.dto'; 3 | 4 | export class UpdateChatRoomDto extends PartialType(CreateChatRoomDto) {} 5 | -------------------------------------------------------------------------------- /backend/src/game-mode/dto/update-game-mode.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/swagger'; 2 | import { CreateGameModeDto } from './create-game-mode.dto'; 3 | 4 | export class UpdateGameModeDto extends PartialType(CreateGameModeDto) {} 5 | -------------------------------------------------------------------------------- /backend/src/questions/dto/update-question.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/swagger'; 2 | import { CreateQuestionDto } from './create-question.dto'; 3 | 4 | export class UpdateQuestionDto extends PartialType(CreateQuestionDto) {} 5 | -------------------------------------------------------------------------------- /backend/src/reward/dto/update-reward-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateRewardDto } from './create-reward-dto.dto'; 3 | 4 | export class UpdateRewardDto extends PartialType(CreateRewardDto) {} 5 | -------------------------------------------------------------------------------- /backend/src/song-genre/dtos/update-song-genre.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/swagger'; 2 | import { CreateSongGenreDto } from './create-song.dto'; 3 | 4 | export class UpdateSongGenreDto extends PartialType(CreateSongGenreDto) {} 5 | -------------------------------------------------------------------------------- /backend/src/game-results/dto/leaderboard-entry.dto.ts: -------------------------------------------------------------------------------- 1 | export class LeaderboardEntryDto { 2 | userId: string; 3 | username: string; 4 | score: number; 5 | rank: number; 6 | achievements: string[]; 7 | gameId: string; 8 | } -------------------------------------------------------------------------------- /backend/src/questions/dto/question-filters.dto.ts: -------------------------------------------------------------------------------- 1 | // src/questions/dto/question-filters.dto.ts 2 | export class QuestionFilters { 3 | difficulty?: number; 4 | songId?: string; 5 | minPoints?: number; 6 | maxPoints?: number; 7 | } 8 | -------------------------------------------------------------------------------- /frontend/public/Star 78.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /backend/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontend/src/__mocks__/types.ts: -------------------------------------------------------------------------------- 1 | export type Account = { 2 | address: string; 3 | publicKey: string; 4 | privateKey: string; 5 | sign: () => Promise; 6 | }; 7 | 8 | export type World = { 9 | config: any; 10 | components: any; 11 | }; -------------------------------------------------------------------------------- /frontend/src/lib/dojo/world.ts: -------------------------------------------------------------------------------- 1 | import { DojoProvider } from "@dojoengine/core"; 2 | import { setupWorld } from "./typescript/contracts.gen"; 3 | 4 | export const initializeWorld = async (provider: DojoProvider) => { 5 | return setupWorld(provider); 6 | }; -------------------------------------------------------------------------------- /backend/src/music-education/music-theory-lesson.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class MusicEducationService { 5 | getWelcomeMessage() { 6 | return 'Welcome to the Music Education API!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /backend/src/notification/enums/notifcation-status.enum.ts: -------------------------------------------------------------------------------- 1 | export enum NotificationStatus { 2 | READ = 'read', 3 | UNREAD = 'unread', 4 | DELETED = 'deleted', 5 | SENT = 'sent', 6 | PENDING = 'pending', 7 | RECIPIENT_DELETED = 'recipient_deleted', 8 | } 9 | -------------------------------------------------------------------------------- /backend/src/state-recovery/dto/update-state-recovery.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/swagger'; 2 | import { CreateStateRecoveryDto } from './create-state-recovery.dto'; 3 | 4 | export class UpdateStateRecoveryDto extends PartialType(CreateStateRecoveryDto) {} 5 | -------------------------------------------------------------------------------- /frontend/src/hooks/useSongs.ts: -------------------------------------------------------------------------------- 1 | import { useQuery } from '@tanstack/react-query'; 2 | import { fetchSongs } from '../mock/musicService'; 3 | 4 | export const useSongs = () => { 5 | return useQuery({ 6 | queryKey: ['songs'], 7 | queryFn: fetchSongs, 8 | }); 9 | }; -------------------------------------------------------------------------------- /backend/src/analytics/decorators/analytics-roles.decorator.ts: -------------------------------------------------------------------------------- 1 | import { SetMetadata } from "@nestjs/common" 2 | import type { AnalyticsRole } from "../enums/analytics-role.enum" 3 | 4 | export const AnalyticsRoles = (...roles: AnalyticsRole[]) => SetMetadata("roles", roles) 5 | 6 | -------------------------------------------------------------------------------- /backend/src/auth/dtos/signIn.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsEmail, IsNotEmpty, IsString } from 'class-validator'; 2 | 3 | export class SignInDto { 4 | @IsEmail() 5 | @IsNotEmpty() 6 | email: string; 7 | 8 | @IsString() 9 | @IsNotEmpty() 10 | password: string; 11 | } 12 | -------------------------------------------------------------------------------- /backend/src/coupons/dto/update-coupon.dto.ts: -------------------------------------------------------------------------------- 1 | // src/coupons/dto/update-coupon.dto.ts 2 | import { PartialType } from '@nestjs/mapped-types'; 3 | import { CreateCouponDto } from './create-coupon.dto'; 4 | 5 | export class UpdateCouponDto extends PartialType(CreateCouponDto) {} 6 | -------------------------------------------------------------------------------- /backend/src/room-movement/dtos/join-room.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsUUID, IsNotEmpty } from 'class-validator'; 2 | 3 | export class JoinRoomDto { 4 | @IsUUID() 5 | @IsNotEmpty() 6 | playerId: string; 7 | 8 | @IsUUID() 9 | @IsNotEmpty() 10 | roomId: string; 11 | } 12 | -------------------------------------------------------------------------------- /backend/src/auth/dtos/reset-password.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString } from 'class-validator'; 2 | 3 | export class ResetPasswordDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | token: string; 7 | 8 | @IsString() 9 | @IsNotEmpty() 10 | newPassword: string; 11 | } -------------------------------------------------------------------------------- /backend/src/logger/logger.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CustomLoggerService } from './custom-logger.service'; 3 | 4 | @Module({ 5 | providers: [CustomLoggerService], 6 | exports: [CustomLoggerService], 7 | }) 8 | export class LoggerModule {} 9 | -------------------------------------------------------------------------------- /backend/src/redis/redis.module.ts: -------------------------------------------------------------------------------- 1 | import { Module, Global } from '@nestjs/common'; 2 | import { RedisService } from './redis.service'; 3 | 4 | @Global() 5 | @Module({ 6 | providers: [RedisService], 7 | exports: [RedisService], 8 | }) 9 | export class RedisModule {} 10 | -------------------------------------------------------------------------------- /backend/src/room-movement/dtos/leave-room.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsUUID, IsNotEmpty } from 'class-validator'; 2 | 3 | export class LeaveRoomDto { 4 | @IsUUID() 5 | @IsNotEmpty() 6 | playerId: string; 7 | 8 | @IsUUID() 9 | @IsNotEmpty() 10 | roomId: string; 11 | } 12 | -------------------------------------------------------------------------------- /backend/src/websocket-game comms/game.module.ts: -------------------------------------------------------------------------------- 1 | import {Module} from "@nestjs/common"; 2 | import { GameGateway, } from "./providers/gamegateway"; 3 | 4 | 5 | @Module({ 6 | providers: [GameGateway], 7 | exports:[GameGateway] 8 | }) 9 | 10 | export class GameModule {} -------------------------------------------------------------------------------- /backend/src/exceptions/ws.exception.ts: -------------------------------------------------------------------------------- 1 | export class WsException extends Error { 2 | constructor( 3 | public readonly message: string, 4 | public readonly code?: number 5 | ) { 6 | super(message); 7 | this.name = 'WsException'; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /backend/src/db-migration/db-migration.constants.ts: -------------------------------------------------------------------------------- 1 | // src/db-migration/db-migration.constants.ts 2 | export const DB_MIGRATION_DIR = 'DB_MIGRATION_DIR'; 3 | export const DB_MIGRATION_BACKUP_DIR = 'DB_MIGRATION_BACKUP_DIR'; 4 | export const DB_MIGRATION_DEFAULT_PROVIDER = 'DB_MIGRATION_DEFAULT_PROVIDER'; -------------------------------------------------------------------------------- /backend/src/game-session/enums/game-status.enum.ts: -------------------------------------------------------------------------------- 1 | export enum GameStatus { 2 | WAITING = 'waiting', 3 | IN_PROGRESS = 'in_progress', 4 | COMPLETED = 'completed', 5 | CANCELLED = 'cancelled', 6 | EXPIRED = 'expired', 7 | ABANDONED = 'abandoned', 8 | PAUSED = 'paused', 9 | } 10 | -------------------------------------------------------------------------------- /frontend/src/hooks/useCategories.ts: -------------------------------------------------------------------------------- 1 | import { useQuery } from '@tanstack/react-query'; 2 | import { fetchCategories } from '../mock/musicService'; 3 | 4 | export const useCategories = () => { 5 | return useQuery({ 6 | queryKey: ['categories'], 7 | queryFn: fetchCategories, 8 | }); 9 | }; -------------------------------------------------------------------------------- /backend/src/common/pagination/pagination.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from "@nestjs/common"; 2 | import { PaginationProvider } from "./provider/pagination.provider"; 3 | 4 | @Module({ 5 | providers: [PaginationProvider], 6 | exports: [PaginationProvider], 7 | }) 8 | export class PaginationModule {} 9 | -------------------------------------------------------------------------------- /backend/src/room-movement/dtos/update-player-status.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsEnum, IsNotEmpty } from 'class-validator'; 2 | import { PlayerStatus } from '../entities/player.entity'; 3 | 4 | export class UpdatePlayerStatusDto { 5 | @IsEnum(PlayerStatus) 6 | @IsNotEmpty() 7 | status: PlayerStatus; 8 | } 9 | -------------------------------------------------------------------------------- /backend/src/game-results/events/game-result.event.ts: -------------------------------------------------------------------------------- 1 | export class GameResultCreatedEvent { 2 | constructor( 3 | public readonly userId: string, 4 | public readonly gameId: string, 5 | public readonly score: number, 6 | public readonly achievements: any[], 7 | ) {} 8 | } 9 | -------------------------------------------------------------------------------- /backend/src/game/dtos/queue-player.dto.ts: -------------------------------------------------------------------------------- 1 | // src/game/dtos/queue-player.dto.ts 2 | import { IsString, IsOptional, IsNumber } from 'class-validator'; 3 | 4 | export class QueuePlayerDto { 5 | @IsString() 6 | preferredMode: string; 7 | 8 | @IsOptional() 9 | @IsNumber() 10 | skill?: number; 11 | } -------------------------------------------------------------------------------- /backend/src/voice/dto/join-room.dto.ts: -------------------------------------------------------------------------------- 1 | // src/voice/dto/join-room.dto.ts 2 | import { IsString, IsNotEmpty, IsUUID } from 'class-validator'; 3 | 4 | export class JoinRoomDto { 5 | @IsUUID() 6 | @IsNotEmpty() 7 | roomId: string; 8 | 9 | @IsString() 10 | @IsNotEmpty() 11 | username: string; 12 | } -------------------------------------------------------------------------------- /backend/src/practice/dto/update-practice-item.dto.ts: -------------------------------------------------------------------------------- 1 | // src/practice/dto/update-practice-item.dto.ts 2 | import { PartialType } from '@nestjs/mapped-types'; 3 | import { CreatePracticeItemDto } from './create-practice-item.dto'; 4 | 5 | export class UpdatePracticeItemDto extends PartialType(CreatePracticeItemDto) {} 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@nestjs/platform-socket.io": "^11.0.10", 4 | "@nestjs/swagger": "^11.0.2", 5 | "@nestjs/throttler": "^6.4.0", 6 | "@nestjs/websockets": "^11.0.10", 7 | "@react-navigation/drawer": "^7.1.1", 8 | "swagger-ui-express": "^5.0.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /backend/src/song/song.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { SongController } from './song.controller'; 3 | import { SongService } from './providers/song.service'; 4 | 5 | @Module({ 6 | controllers: [SongController], 7 | providers: [SongService] 8 | }) 9 | export class SongModule {} 10 | -------------------------------------------------------------------------------- /frontend/src/lib/react-query.ts: -------------------------------------------------------------------------------- 1 | import { QueryClient } from '@tanstack/react-query'; 2 | 3 | export const queryClient = new QueryClient({ 4 | defaultOptions: { 5 | queries: { 6 | staleTime: 1000 * 60 * 5, // 5 minutes 7 | refetchOnWindowFocus: false, 8 | retry: 2, 9 | }, 10 | }, 11 | }); -------------------------------------------------------------------------------- /backend/src/game/interfaces/game-result.interface.ts: -------------------------------------------------------------------------------- 1 | export interface GameResult { 2 | gameSessionId: string; 3 | gameMode: string; 4 | startTime: Date; 5 | endTime: Date; 6 | players: Array<{ 7 | id: string; 8 | score: number; 9 | rank: number; 10 | }>; 11 | winner: string; 12 | } -------------------------------------------------------------------------------- /backend/src/song-genre/entities/tag.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'; 2 | 3 | @Entity() 4 | export class Tag { 5 | @PrimaryGeneratedColumn('uuid') 6 | id: string; 7 | 8 | @Column({ unique: true }) 9 | name: string; 10 | 11 | @Column() 12 | category: string; 13 | } 14 | -------------------------------------------------------------------------------- /backend/src/wager/wager.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { WagerController } from './wager.controller'; 3 | import { WagerService } from './provider/wager.service'; 4 | 5 | @Module({ 6 | controllers: [WagerController], 7 | providers: [WagerService] 8 | }) 9 | export class WagerModule {} 10 | -------------------------------------------------------------------------------- /backend/src/practice/dto/submit-result.dto.ts: -------------------------------------------------------------------------------- 1 | // src/practice/dto/submit-result.dto.ts 2 | import { IsNumber, IsObject, Min } from 'class-validator'; 3 | 4 | export class SubmitResultDto { 5 | @IsObject() 6 | userResponse: Record; 7 | 8 | @IsNumber() 9 | @Min(0) 10 | timeSpentSeconds: number; 11 | } 12 | -------------------------------------------------------------------------------- /backend/src/reward/reward.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { RewardController } from './reward.controller'; 3 | import { RewardService } from './providers/reward.service'; 4 | 5 | @Module({ 6 | controllers: [RewardController], 7 | providers: [RewardService] 8 | }) 9 | export class RewardModule {} 10 | -------------------------------------------------------------------------------- /backend/src/store/store.module.ts: -------------------------------------------------------------------------------- 1 | // src/store/store.module.ts 2 | @Module({ 3 | imports: [ 4 | TypeOrmModule.forFeature([StoreItem, Transaction, Inventory]), 5 | UserModule, 6 | ], 7 | controllers: [StoreController], 8 | providers: [StoreService], 9 | exports: [StoreService], 10 | }) 11 | export class StoreModule {} -------------------------------------------------------------------------------- /backend/src/game-insights/DTO/CreateGameSessionDto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsDate } from 'class-validator'; 2 | 3 | export class CreateGameSessionDto { 4 | @IsString() 5 | playerId: string; 6 | 7 | @IsString() 8 | gameTitle: string; 9 | 10 | @IsDate() 11 | startTime: Date; 12 | 13 | @IsDate() 14 | endTime?: Date; 15 | } 16 | -------------------------------------------------------------------------------- /backend/src/chat-room/chat-room.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ChatRoomService } from './chat-room.service'; 3 | import { ChatRoomController } from './chat-room.controller'; 4 | 5 | @Module({ 6 | controllers: [ChatRoomController], 7 | providers: [ChatRoomService], 8 | }) 9 | export class ChatRoomModule {} 10 | -------------------------------------------------------------------------------- /backend/src/game-mode/game-mode.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { GameModeService } from './game-mode.service'; 3 | import { GameModeController } from './game-mode.controller'; 4 | 5 | @Module({ 6 | controllers: [GameModeController], 7 | providers: [GameModeService], 8 | }) 9 | export class GameModeModule {} 10 | -------------------------------------------------------------------------------- /backend/src/music-education/genre-history/entities/genre-history.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; 2 | 3 | @Entity() 4 | export class GenreHistory { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | genre: string; 10 | 11 | @Column('text') 12 | history: string; 13 | } 14 | -------------------------------------------------------------------------------- /backend/src/game-insights/DTO/CreateUserBehaviorDto.ts: -------------------------------------------------------------------------------- 1 | import { IsString } from 'class-validator'; 2 | 3 | export class CreateUserBehaviorDto { 4 | @IsString() 5 | playerId: string; 6 | 7 | @IsString() 8 | gameTitle: string; 9 | 10 | @IsString() 11 | actionType: string; 12 | 13 | @IsString() 14 | genrePreference: string; 15 | } 16 | -------------------------------------------------------------------------------- /backend/src/modules/auth/guards/jwt-auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, ExecutionContext } from '@nestjs/common'; 2 | import { AuthGuard } from '@nestjs/passport'; 3 | 4 | @Injectable() 5 | export class JwtAuthGuard extends AuthGuard('jwt') { 6 | canActivate(context: ExecutionContext) { 7 | return super.canActivate(context); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /backend/src/questions/questions.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { QuestionsService } from './questions.service'; 3 | import { QuestionsController } from './questions.controller'; 4 | 5 | @Module({ 6 | controllers: [QuestionsController], 7 | providers: [QuestionsService], 8 | }) 9 | export class QuestionsModule {} 10 | -------------------------------------------------------------------------------- /backend/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /backend/src/sync/interfaces/mergeable.interface.ts: -------------------------------------------------------------------------------- 1 | // src/sync/interfaces/mergeable.interface.ts 2 | export interface Mergeable { 3 | merge(other: T, base?: T): T; 4 | diff(other: T): Partial; 5 | getVersion(): number; 6 | setVersion(version: number): void; 7 | getLastSyncedAt(): Date | null; 8 | setLastSyncedAt(date: Date): void; 9 | } -------------------------------------------------------------------------------- /onchain/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod interfaces { 2 | pub mod lyricsflip; 3 | } 4 | 5 | pub mod contracts { 6 | pub mod lyricsflip; 7 | pub mod lyricsflipNFT; 8 | } 9 | 10 | pub mod utils { 11 | pub mod errors; 12 | pub mod types; 13 | } 14 | 15 | #[cfg(test)] 16 | mod tests { 17 | mod test_lyricsflip; 18 | mod test_lyricsflipNFT; 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/scoring/constants/scoring.constants.ts: -------------------------------------------------------------------------------- 1 | export const SCORING_CONSTANTS = { 2 | BASE_SCORE: 1000, 3 | MAX_TIME_BONUS: 500, 4 | MAX_STREAK_BONUS_MULTIPLIER: 2, 5 | MAX_DIFFICULTY_MULTIPLIER: 2, 6 | MAX_RESPONSE_TIME_MS: 20000, // 20 seconds 7 | MIN_RESPONSE_TIME_MS: 500, // 0.5 seconds 8 | STREAK_BONUS_INCREMENT: 0.1, // 10% per streak 9 | }; 10 | -------------------------------------------------------------------------------- /backend/src/state-recovery/state-recovery.module.ts: -------------------------------------------------------------------------------- 1 | @Module({ 2 | imports: [ 3 | TypeOrmModule.forFeature([GameState, StateAudit]), 4 | RedisModule 5 | ], 6 | controllers: [StateRecoveryController], 7 | providers: [ 8 | StateRecoveryService, 9 | Logger 10 | ], 11 | exports: [StateRecoveryService] 12 | }) 13 | export class StateRecoveryModule {} -------------------------------------------------------------------------------- /backend/src/auth/guard/jwt-auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class JwtAuthGuard implements CanActivate { 5 | canActivate(context: ExecutionContext): boolean { 6 | // Static guard: Always allow access (replace with real authentication later) 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /backend/src/config-manager/config-manager.module.ts: -------------------------------------------------------------------------------- 1 | @Module({ 2 | imports: [ 3 | TypeOrmModule.forFeature([ConfigEntry, ConfigAudit]), 4 | EventEmitterModule.forRoot() 5 | ], 6 | controllers: [ConfigManagerController], 7 | providers: [ConfigManagerService], 8 | exports: [ConfigManagerService] 9 | }) 10 | export class ConfigManagerModule { } -------------------------------------------------------------------------------- /backend/src/store/dto/create-item.dto.ts: -------------------------------------------------------------------------------- 1 | // src/store/dto/create-item.dto.ts 2 | export class CreateItemDto { 3 | @IsString() 4 | @IsNotEmpty() 5 | name: string; 6 | 7 | @IsString() 8 | description: string; 9 | 10 | @IsNumber() 11 | @Min(0) 12 | price: number; 13 | 14 | @IsString() 15 | type: string; 16 | 17 | @IsString() 18 | image: string; 19 | } -------------------------------------------------------------------------------- /frontend/tailwind.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'tailwindcss' 2 | 3 | const config: Config = { 4 | content: [ 5 | './src/pages/**/*.{js,ts,jsx,tsx,mdx}', 6 | './src/components/**/*.{js,ts,jsx,tsx,mdx}', 7 | './src/app/**/*.{js,ts,jsx,tsx,mdx}', 8 | ], 9 | theme: { 10 | extend: {}, 11 | }, 12 | plugins: [], 13 | } 14 | export default config -------------------------------------------------------------------------------- /backend/src/difficulty/entities/difficulty.entity.ts: -------------------------------------------------------------------------------- 1 | import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; 2 | 3 | @Entity('difficulties') 4 | export class Difficulty { 5 | @PrimaryGeneratedColumn('uuid') 6 | id: string; 7 | 8 | @Column({ unique: true }) 9 | value: number; 10 | 11 | @Column() 12 | name: string; // Easy, Medium or Hard 13 | } -------------------------------------------------------------------------------- /backend/src/leaderboard/leaderboard.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { LeaderboardController } from './leaderboard.controller'; 3 | import { LeaderboardService } from './providers/leaderboard.service'; 4 | 5 | @Module({ 6 | controllers: [LeaderboardController], 7 | providers: [LeaderboardService] 8 | }) 9 | export class LeaderboardModule {} 10 | -------------------------------------------------------------------------------- /backend/src/user/providers/hashing.provider.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import * as bcrypt from 'bcrypt'; 3 | 4 | @Injectable() 5 | export class HashingProvider { 6 | // hashing 7 | public async hashPassword(data: string | Buffer): Promise { 8 | const salt = await bcrypt.genSalt(); 9 | return bcrypt.hash(data, salt); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontend/src/store/game-store.ts: -------------------------------------------------------------------------------- 1 | import { create } from 'zustand'; 2 | import { BigNumberish } from 'starknet'; 3 | 4 | interface GameState { 5 | roundId: BigNumberish | null; 6 | setRoundId: (roundId: BigNumberish) => void; 7 | } 8 | 9 | export const useGameStore = create((set) => ({ 10 | roundId: null, 11 | setRoundId: (roundId) => set({ roundId }), 12 | })); 13 | -------------------------------------------------------------------------------- /backend/src/notification/notification.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { NotificationController } from './notification.controller'; 3 | import { NotificationService } from './providers/notification.service'; 4 | 5 | @Module({ 6 | controllers: [NotificationController], 7 | providers: [NotificationService] 8 | }) 9 | export class NotificationModule {} 10 | -------------------------------------------------------------------------------- /backend/src/power-ups/dtos/create-power-up.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNumber, IsPositive } from 'class-validator'; 2 | 3 | export class CreatePowerUpDto { 4 | @IsString() 5 | name: string; 6 | 7 | @IsString() 8 | description: string; 9 | 10 | @IsNumber() 11 | @IsPositive() 12 | duration: number; 13 | 14 | @IsNumber() 15 | @IsPositive() 16 | price: number; 17 | } 18 | -------------------------------------------------------------------------------- /backend/src/content-generator/processors/content-queue.processor.ts: -------------------------------------------------------------------------------- 1 | @Processor('content-generation') 2 | export class ContentQueueProcessor { 3 | constructor(private contentGeneratorService: ContentGeneratorService) {} 4 | 5 | @Process('validate') 6 | async validateContent(job: Job<{ contentId: string }>) { 7 | await this.contentGeneratorService.validateContent(job.data.contentId); 8 | } 9 | } -------------------------------------------------------------------------------- /backend/src/music-education/quiz/entities/quiz.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; 2 | 3 | @Entity() 4 | export class Quiz { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | question: string; 10 | 11 | @Column('text', { array: true }) 12 | options: string[]; 13 | 14 | @Column() 15 | correctAnswer: string; 16 | } 17 | -------------------------------------------------------------------------------- /backend/src/modules/activity/dto/create-activity-item.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString, IsObject, IsOptional } from 'class-validator'; 2 | 3 | export class CreateActivityItemDto { 4 | @IsNotEmpty() 5 | @IsString() 6 | userId: string; 7 | 8 | @IsNotEmpty() 9 | @IsString() 10 | type: string; 11 | 12 | @IsOptional() 13 | @IsObject() 14 | metadata?: Record; 15 | } 16 | -------------------------------------------------------------------------------- /backend/src/power-ups/entities/power-up.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; 2 | 3 | @Entity() 4 | export class PowerUp { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | name: string; 10 | 11 | @Column() 12 | description: string; 13 | 14 | @Column() 15 | duration: number; 16 | 17 | @Column() 18 | price: number; 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/auth/decorators/current-user.decorator.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 2 | import { REQUEST_USER_KEY } from '../constant/auth-constant'; 3 | 4 | export const CurrentUser = createParamDecorator( 5 | (data: unknown, context: ExecutionContext) => { 6 | const request = context.switchToHttp().getRequest(); 7 | return request[REQUEST_USER_KEY]; 8 | }, 9 | ); -------------------------------------------------------------------------------- /backend/src/auth/providers/hashing-provider.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export abstract class HashingProvider { 5 | // hash during signUp 6 | abstract hashPassword(impPassword: string | Buffer): Promise 7 | 8 | // compare during signIn 9 | abstract comparePasswords(passwordData: string, encryptedPassword: string): Promise 10 | } -------------------------------------------------------------------------------- /backend/src/game-insights/DTO/CreatePlayerPerformanceDto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNumber } from 'class-validator'; 2 | 3 | export class CreatePlayerPerformanceDto { 4 | @IsString() 5 | playerId: string; 6 | 7 | @IsString() 8 | gameTitle: string; 9 | 10 | @IsNumber() 11 | score: number; 12 | 13 | @IsNumber() 14 | accuracy: number; 15 | 16 | @IsNumber() 17 | responseTime: number; 18 | } 19 | -------------------------------------------------------------------------------- /backend/src/common/pagination/pagination-query-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsOptional, IsPositive } from 'class-validator'; 2 | 3 | import { Type } from 'class-transformer'; 4 | 5 | export class PaginationQueryDto { 6 | // @Type(() => Number) //coverting strings to numbers 7 | @IsOptional() 8 | @IsPositive() 9 | limit?: number = 10; 10 | 11 | @IsOptional() 12 | @IsPositive() 13 | page?: number = 1; 14 | } 15 | -------------------------------------------------------------------------------- /backend/src/music-education/artists/entities/artist.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; 2 | 3 | @Entity() 4 | export class Artist { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | name: string; 10 | 11 | @Column('text') 12 | biography: string; 13 | 14 | @Column() 15 | genre: string; 16 | 17 | @Column() 18 | birthYear: number; 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/scoring/dto/create-scoring.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsNumber, IsString, IsOptional } from 'class-validator'; 2 | 3 | export class CreateScoringDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | userId: string; 7 | 8 | @IsNumber() 9 | @IsNotEmpty() 10 | score: number; 11 | 12 | @IsNumber() 13 | @IsOptional() // Optional since rankings are usually calculated 14 | ranking?: number; 15 | } 16 | -------------------------------------------------------------------------------- /backend/src/store/entities/inventory.entity.ts: -------------------------------------------------------------------------------- 1 | // src/store/entities/inventory.entity.ts 2 | @Entity() 3 | export class Inventory { 4 | @PrimaryGeneratedColumn('uuid') 5 | id: string; 6 | 7 | @ManyToOne(() => User) 8 | user: User; 9 | 10 | @ManyToOne(() => StoreItem) 11 | item: StoreItem; 12 | 13 | @Column({ default: 1 }) 14 | quantity: number; 15 | 16 | @CreateDateColumn() 17 | acquiredAt: Date; 18 | } -------------------------------------------------------------------------------- /backend/src/referral/dto/claim-referral.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString } from 'class-validator'; 2 | import { ApiProperty } from '@nestjs/swagger'; 3 | 4 | export class ClaimReferralDto { 5 | @ApiProperty({ description: 'The referral code to claim' }) 6 | @IsString() 7 | referralCode: string; 8 | 9 | @ApiProperty({ description: 'ID of the user claiming the referral' }) 10 | @IsString() 11 | refereeId: string; 12 | } 13 | -------------------------------------------------------------------------------- /backend/src/reward/dto/create-reward-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsNotEmpty, 3 | IsString, 4 | IsNumber, 5 | Min, 6 | IsOptional, 7 | } from 'class-validator'; 8 | 9 | export class CreateRewardDto { 10 | @IsNotEmpty() 11 | @IsString() 12 | name: string; 13 | 14 | @IsNotEmpty() 15 | @IsNumber() 16 | @Min(0) 17 | points: number; 18 | 19 | @IsOptional() 20 | @IsString() 21 | description?: string; 22 | } 23 | -------------------------------------------------------------------------------- /backend/src/scoring/types/scoring.types.ts: -------------------------------------------------------------------------------- 1 | export interface ScoreCalculationDto { 2 | playerId: string; 3 | questionId: string; 4 | isCorrect: boolean; 5 | responseTimeMs: number; 6 | currentStreak: number; 7 | difficultyLevel: number; 8 | } 9 | 10 | export interface ScoreResult { 11 | baseScore: number; 12 | timeBonus: number; 13 | streakBonus: number; 14 | totalScore: number; 15 | newStreak: number; 16 | } 17 | -------------------------------------------------------------------------------- /backend/src/leaderboard/leaderboard-entry.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; 2 | 3 | @Entity('leaderboard_entries') 4 | export class LeaderboardEntry { 5 | @PrimaryGeneratedColumn('uuid') 6 | id: string; 7 | 8 | @Column({ unique: true }) 9 | playerId: string; 10 | 11 | @Column() 12 | playerName: string; 13 | 14 | @Column({ type: 'int', default: 0 }) 15 | score: number; 16 | } 17 | -------------------------------------------------------------------------------- /backend/src/reward/providers/reward.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | // Service responsible for managing rewards. 4 | @Injectable() 5 | export class RewardService { 6 | // Retrieve the list of available rewards. 7 | getRewards() { 8 | // Implement get rewards logic 9 | } 10 | 11 | // Claim a specific reward. 12 | claimReward() { 13 | // Implement claim reward logic 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /frontend/src/components/providers/client-provider.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import { QueryClientProvider } from '@tanstack/react-query'; 4 | import { queryClient } from '@/lib/react-query'; 5 | 6 | export function ClientProvider({ 7 | children, 8 | }: { 9 | children: React.ReactNode; 10 | }) { 11 | return ( 12 | 13 | {children} 14 | 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /backend/src/music-education/music-lessons/entities/music-theory-lesson.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; 2 | 3 | @Entity() 4 | export class MusicLesson { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | title: string; 10 | 11 | @Column('text') 12 | content: string; 13 | 14 | @Column() 15 | genre: string; 16 | 17 | @Column() 18 | difficulty: string; 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/sync/dto/delta-update.dto.ts: -------------------------------------------------------------------------------- 1 | // src/sync/dto/delta-update.dto.ts 2 | import { IsNotEmpty, IsNumber, IsObject, IsString } from 'class-validator'; 3 | 4 | export class DeltaUpdateDto { 5 | @IsString() 6 | @IsNotEmpty() 7 | userId: string; 8 | 9 | @IsString() 10 | @IsNotEmpty() 11 | dataType: string; 12 | 13 | @IsNumber() 14 | baseVersion: number; 15 | 16 | @IsObject() 17 | changes: Partial; 18 | } -------------------------------------------------------------------------------- /backend/src/auth/authConfig/jwt.config.ts: -------------------------------------------------------------------------------- 1 | import { registerAs } from '@nestjs/config'; 2 | 3 | export default registerAs('jwt', () => { 4 | return { 5 | secret: process.env.JWT_SECRET, 6 | audience: process.env.JWT_TOKEN_AUDIENCE, 7 | issuer: process.env.JWT_TOKEN_ISSUER, 8 | ttl: parseInt(process.env.JWT_ACCESS_TOKEN_TTL ?? '3600'), 9 | refreshttl: parseInt(process.env.JWT_REFRESH_TOKEN_TTL ?? '7776000'), 10 | }; 11 | }); -------------------------------------------------------------------------------- /backend/src/config-manager/entities/config-audit.entity.ts: -------------------------------------------------------------------------------- 1 | @Entity() 2 | export class ConfigAudit { 3 | @PrimaryGeneratedColumn('uuid') 4 | id: string; 5 | 6 | @ManyToOne(() => ConfigEntry) 7 | config: ConfigEntry; 8 | 9 | @Column('json') 10 | oldValue: any; 11 | 12 | @Column('json') 13 | newValue: any; 14 | 15 | @Column() 16 | changedBy: string; 17 | 18 | @CreateDateColumn() 19 | timestamp: Date; 20 | } -------------------------------------------------------------------------------- /backend/src/analytics/dto/date-range.dto.ts: -------------------------------------------------------------------------------- 1 | import { ApiProperty } from "@nestjs/swagger" 2 | import { IsDate, IsNotEmpty } from "class-validator" 3 | import { Type } from "class-transformer" 4 | 5 | export class DateRangeDto { 6 | @ApiProperty() 7 | @Type(() => Date) 8 | @IsDate() 9 | @IsNotEmpty() 10 | startDate: Date 11 | 12 | @ApiProperty() 13 | @Type(() => Date) 14 | @IsDate() 15 | @IsNotEmpty() 16 | endDate: Date 17 | } 18 | 19 | -------------------------------------------------------------------------------- /backend/src/modules/activity/activity.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TypeOrmModule } from '@nestjs/typeorm'; 3 | import { ActivityService } from './activity.service'; 4 | import { ActivityItem } from './entities/activity-item.entity'; 5 | 6 | @Module({ 7 | imports: [TypeOrmModule.forFeature([ActivityItem])], 8 | providers: [ActivityService], 9 | exports: [ActivityService], 10 | }) 11 | export class ActivityModule {} 12 | -------------------------------------------------------------------------------- /backend/src/room/dto/create-room.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString } from 'class-validator'; 2 | import { ApiProperty } from '@nestjs/swagger'; 3 | 4 | export class CreateRoomDto { 5 | @ApiProperty() 6 | @IsNotEmpty() 7 | @IsString() 8 | name: string; 9 | 10 | @ApiProperty() 11 | @IsNotEmpty() 12 | @IsString() 13 | description: string; 14 | 15 | // @ApiProperty() 16 | // @IsNotEmpty() 17 | // @IsString() 18 | // code: string; 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/voice/dto/voice-settings.dto.ts: -------------------------------------------------------------------------------- 1 | // src/voice/dto/voice-settings.dto.ts 2 | import { IsBoolean, IsEnum, IsOptional } from 'class-validator'; 3 | 4 | export class VoiceSettingsDto { 5 | @IsBoolean() 6 | @IsOptional() 7 | muted?: boolean; 8 | 9 | @IsEnum(['low', 'medium', 'high']) 10 | @IsOptional() 11 | qualityPreference?: 'low' | 'medium' | 'high'; 12 | 13 | @IsBoolean() 14 | @IsOptional() 15 | isRecording?: boolean; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /backend/src/config/validation.schema.ts: -------------------------------------------------------------------------------- 1 | import * as Joi from 'joi'; 2 | 3 | export const validationSchema = Joi.object({ 4 | NODE_ENV: Joi.string() 5 | .valid('development', 'production', 'test', 'staging') 6 | .default('development'), 7 | PORT: Joi.number().default(3000), 8 | DATABASE_URL: Joi.string().required(), 9 | JWT_SECRET: Joi.string().required(), 10 | STARKNET_NETWORK: Joi.string() 11 | .valid('alpha', 'mainnet') 12 | .required(), 13 | }); -------------------------------------------------------------------------------- /backend/src/game/dtos/start-game.dto.ts: -------------------------------------------------------------------------------- 1 | // src/game/dtos/start-game.dto.ts 2 | import { IsString, IsArray, ArrayMinSize, IsOptional, IsNumber } from 'class-validator'; 3 | 4 | export class StartGameDto { 5 | @IsString() 6 | modeId: string; 7 | 8 | @IsArray() 9 | @ArrayMinSize(1) 10 | playerIds: string[]; 11 | 12 | @IsOptional() 13 | @IsNumber() 14 | difficulty?: number; 15 | 16 | @IsOptional() 17 | @IsNumber() 18 | timeLimit?: number; 19 | } -------------------------------------------------------------------------------- /backend/src/modules/notification/dto/create-notification.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString, IsObject, IsOptional } from 'class-validator'; 2 | 3 | export class CreateNotificationDto { 4 | @IsNotEmpty() 5 | @IsString() 6 | userId: string; 7 | 8 | @IsNotEmpty() 9 | @IsString() 10 | type: string; 11 | 12 | @IsNotEmpty() 13 | @IsString() 14 | message: string; 15 | 16 | @IsOptional() 17 | @IsObject() 18 | metadata?: Record; 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/analytics/dto/analytics-response.dto.ts: -------------------------------------------------------------------------------- 1 | import { ApiProperty } from "@nestjs/swagger" 2 | import { IsDate, IsObject, IsOptional } from "class-validator" 3 | 4 | export class AnalyticsResponseDto { 5 | @ApiProperty() 6 | @IsDate() 7 | timestamp: Date 8 | 9 | @ApiProperty() 10 | @IsObject() 11 | data: Record 12 | 13 | @ApiProperty({ required: false }) 14 | @IsObject() 15 | @IsOptional() 16 | metadata?: Record 17 | } 18 | 19 | -------------------------------------------------------------------------------- /backend/src/state-recovery/entities/state-audit.entity.ts: -------------------------------------------------------------------------------- 1 | @Entity() 2 | export class StateAudit { 3 | @PrimaryGeneratedColumn('uuid') 4 | id: string; 5 | 6 | @ManyToOne(() => GameState) 7 | gameState: GameState; 8 | 9 | @Column() 10 | action: string; 11 | 12 | @Column('json') 13 | previousState: any; 14 | 15 | @Column('json') 16 | newState: any; 17 | 18 | @Column() 19 | triggeredBy: string; 20 | 21 | @CreateDateColumn() 22 | timestamp: Date; 23 | } -------------------------------------------------------------------------------- /backend/src/voice/dto/create-room.dto.ts: -------------------------------------------------------------------------------- 1 | // src/voice/dto/create-room.dto.ts 2 | import { IsString, IsNotEmpty, IsInt, IsOptional, Min, Max } from 'class-validator'; 3 | import { Transform } from 'class-transformer'; 4 | 5 | export class CreateRoomDto { 6 | @IsString() 7 | @IsNotEmpty() 8 | name: string; 9 | 10 | @IsInt() 11 | @IsOptional() 12 | @Min(2) 13 | @Max(50) 14 | @Transform(({ value }) => parseInt(value, 10)) 15 | maxParticipants?: number = 10; 16 | } 17 | -------------------------------------------------------------------------------- /backend/src/modules/notification/notification.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TypeOrmModule } from '@nestjs/typeorm'; 3 | import { NotificationService } from './notification.service'; 4 | import { Notification } from './entities/notification.entity'; 5 | 6 | @Module({ 7 | imports: [TypeOrmModule.forFeature([Notification])], 8 | providers: [NotificationService], 9 | exports: [NotificationService], 10 | }) 11 | export class NotificationModule {} 12 | -------------------------------------------------------------------------------- /backend/src/power-ups/dtos/update-power-up.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNumber, IsPositive, IsOptional } from 'class-validator'; 2 | 3 | export class UpdatePowerUpDto { 4 | @IsOptional() 5 | @IsString() 6 | name?: string; 7 | 8 | @IsOptional() 9 | @IsString() 10 | description?: string; 11 | 12 | @IsOptional() 13 | @IsNumber() 14 | @IsPositive() 15 | duration?: number; 16 | 17 | @IsOptional() 18 | @IsNumber() 19 | @IsPositive() 20 | price?: number; 21 | } 22 | -------------------------------------------------------------------------------- /backend/src/practice/dto/create-session.dto.ts: -------------------------------------------------------------------------------- 1 | // src/practice/dto/create-session.dto.ts 2 | import { IsEnum, IsOptional } from 'class-validator'; 3 | import { Difficulty } from '../enums/difficulty.enum'; 4 | import { Genre } from '../enums/genre.enum'; 5 | 6 | export class CreateSessionDto { 7 | @IsEnum(Difficulty) 8 | @IsOptional() 9 | difficulty?: Difficulty = Difficulty.MEDIUM; 10 | 11 | @IsEnum(Genre) 12 | @IsOptional() 13 | genre?: Genre = Genre.GENERAL; 14 | } 15 | -------------------------------------------------------------------------------- /frontend/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { dirname } from "path"; 2 | import { fileURLToPath } from "url"; 3 | import { FlatCompat } from "@eslint/eslintrc"; 4 | 5 | const __filename = fileURLToPath(import.meta.url); 6 | const __dirname = dirname(__filename); 7 | 8 | const compat = new FlatCompat({ 9 | baseDirectory: __dirname, 10 | }); 11 | 12 | const eslintConfig = [ 13 | ...compat.extends("next/core-web-vitals", "next/typescript"), 14 | ]; 15 | 16 | export default eslintConfig; 17 | -------------------------------------------------------------------------------- /backend/src/game/decorators/user.decorator.ts: -------------------------------------------------------------------------------- 1 | // src/decorators/user.decorator.ts 2 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 3 | 4 | export const User = createParamDecorator( 5 | (data: string, ctx: ExecutionContext) => { 6 | const request = ctx.switchToHttp().getRequest(); 7 | const user = request.user; 8 | 9 | // If a specific property is requested and the user object exists 10 | return data && user ? user[data] : user; 11 | }, 12 | ); -------------------------------------------------------------------------------- /backend/src/notification/providers/notification.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | // Service responsible for managing notifications. 4 | @Injectable() 5 | export class NotificationService { 6 | // Retrieve all notifications. 7 | getNotifications() { 8 | // Implement get notifications logic 9 | } 10 | // Mark specified notifications as read. 11 | markNotificationsRead() { 12 | // Implement mark notifications as read logic 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /backend/src/room/entities/room.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm'; 2 | 3 | @Entity('rooms') 4 | export class Room { 5 | @PrimaryGeneratedColumn('uuid') 6 | id: string; 7 | 8 | @Column() 9 | name: string; 10 | 11 | @Column('text') 12 | description: string; 13 | 14 | @Column() 15 | code: string; 16 | 17 | @CreateDateColumn() 18 | createdAt: Date; 19 | 20 | @UpdateDateColumn() 21 | updatedAt: Date; 22 | } -------------------------------------------------------------------------------- /backend/src/state-recovery/entities/game-state.entity.ts: -------------------------------------------------------------------------------- 1 | @Entity() 2 | export class GameState { 3 | @PrimaryGeneratedColumn('uuid') 4 | id: string; 5 | 6 | @Column() 7 | gameId: string; 8 | 9 | @Column() 10 | playerId: string; 11 | 12 | @Column('json') 13 | state: any; 14 | 15 | @Column() 16 | version: number; 17 | 18 | @Column() 19 | checksum: string; 20 | 21 | @CreateDateColumn() 22 | createdAt: Date; 23 | 24 | @Column({ default: true }) 25 | isValid: boolean; 26 | } -------------------------------------------------------------------------------- /backend/src/modules/activity/entities/activity-item.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm'; 2 | 3 | @Entity('activity_items') 4 | export class ActivityItem { 5 | @PrimaryGeneratedColumn('uuid') 6 | id: string; 7 | 8 | @Column() 9 | userId: string; 10 | 11 | @Column() 12 | type: string; 13 | 14 | @Column({ type: 'json', nullable: true }) 15 | metadata: Record; 16 | 17 | @CreateDateColumn() 18 | timestamp: Date; 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/music-education/music-theory-lesson.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller('music-education') 4 | export class MusicEducationController { 5 | @Get('overview') 6 | getOverview() { 7 | return { 8 | message: 'Welcome to the Music Education API!', 9 | features: [ 10 | 'Quiz', 11 | 'Music Lessons', 12 | 'Genre History', 13 | 'Artists', 14 | 'User Progress', 15 | ], 16 | }; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /backend/src/room/room.module.ts: -------------------------------------------------------------------------------- 1 | // src/room/room.module.ts 2 | import { Module } from '@nestjs/common'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { RoomService } from './room.service'; 5 | import { RoomController } from './room.controller'; 6 | import { Room } from './entities/room.entity'; 7 | 8 | @Module({ 9 | imports: [TypeOrmModule.forFeature([Room])], 10 | controllers: [RoomController], 11 | providers: [RoomService], 12 | exports: [RoomService], 13 | }) 14 | export class RoomModule {} -------------------------------------------------------------------------------- /backend/src/auth/guard/throttler.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, ExecutionContext } from '@nestjs/common'; 2 | import { ThrottlerGuard } from '@nestjs/throttler'; 3 | 4 | @Injectable() 5 | export class CustomThrottlerGuard extends ThrottlerGuard { 6 | protected generateKey(context: ExecutionContext): string { 7 | const request = context.switchToHttp().getRequest(); 8 | const user = request.user; 9 | return user ? `user-${user.id}` : request.ip; // Use user ID if authenticated, else use IP 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /backend/src/game-mode/dto/create-game-mode.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsBoolean, IsObject, IsNotEmpty } from 'class-validator'; 2 | 3 | export class GameModeDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | name: string; 7 | 8 | @IsObject() 9 | @IsNotEmpty() 10 | rules: { 11 | timeLimit: number; 12 | pointSystem: Record; 13 | powerUpsAllowed: string[]; 14 | minimumPlayers: number; 15 | specialConditions: string[]; 16 | }; 17 | 18 | @IsBoolean() 19 | isPublic: boolean; 20 | } -------------------------------------------------------------------------------- /backend/src/game/strategies/scoring/classic-scoring.strategy.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { ScoringStrategy } from '../strategies/scoring/scoring-strategy.interface'; 3 | 4 | @Injectable() 5 | export class ClassicScoringStrategy implements ScoringStrategy { 6 | calculateScore(gameData: any, playerId: string): number { 7 | // Implementation based on classic mode rules 8 | // Points for completed objectives, bonuses, etc. 9 | return gameData.playerStats[playerId].points; 10 | } 11 | } -------------------------------------------------------------------------------- /backend/src/scoring/events/scoring.events.ts: -------------------------------------------------------------------------------- 1 | import { ScoreResult } from '../types/scoring.types'; 2 | 3 | export class ScoreCalculatedEvent { 4 | constructor( 5 | public readonly playerId: string, 6 | public readonly scoreResult: ScoreResult, 7 | public readonly timestamp: Date, 8 | ) {} 9 | } 10 | 11 | export class StreakUpdatedEvent { 12 | constructor( 13 | public readonly playerId: string, 14 | public readonly newStreak: number, 15 | public readonly timestamp: Date, 16 | ) {} 17 | } 18 | -------------------------------------------------------------------------------- /frontend/src/hooks/useLeaderboard.ts: -------------------------------------------------------------------------------- 1 | import { useQuery } from '@tanstack/react-query'; 2 | 3 | 4 | export function useLeaderboard() { 5 | return useQuery({ 6 | queryKey: ['leaderboard'], 7 | queryFn: async () => { 8 | const response = await fetch('/api/leaderboard'); 9 | const data = await response.json(); 10 | return data.map((user: { id: number; username: string; points: number }, index: number) => ({ 11 | ...user, 12 | rank: index + 1, 13 | })); 14 | }, 15 | }); 16 | } -------------------------------------------------------------------------------- /backend/src/store/entities/transaction.entity.ts: -------------------------------------------------------------------------------- 1 | // src/store/entities/transaction.entity.ts 2 | @Entity() 3 | export class Transaction { 4 | @PrimaryGeneratedColumn('uuid') 5 | id: string; 6 | 7 | @ManyToOne(() => User) 8 | user: User; 9 | 10 | @ManyToOne(() => StoreItem) 11 | item: StoreItem; 12 | 13 | @Column() 14 | amount: number; 15 | 16 | @Column() 17 | currency: string; 18 | 19 | @CreateDateColumn() 20 | createdAt: Date; 21 | 22 | @Column({ default: 'COMPLETED' }) 23 | status: string; 24 | } -------------------------------------------------------------------------------- /backend/src/game-insights/GameSession.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm'; 2 | 3 | @Entity() 4 | export class GameSession { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | playerId: string; 10 | 11 | @Column() 12 | gameTitle: string; 13 | 14 | @Column({ type: 'timestamp' }) 15 | startTime: Date; 16 | 17 | @Column({ type: 'timestamp', nullable: true }) 18 | endTime: Date; 19 | 20 | @CreateDateColumn() 21 | createdAt: Date; 22 | } 23 | -------------------------------------------------------------------------------- /frontend/src/components/atoms/counter-badge.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils'; 2 | 3 | interface CounterBadgeProps { 4 | count: number 5 | label: string 6 | className?: string 7 | } 8 | 9 | export function CounterBadge({ count, label, className }: CounterBadgeProps) { 10 | return ( 11 |
12 | {count} 13 | {label} 14 |
15 | ); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /backend/src/game-insights/PlayerPerformance.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm'; 2 | 3 | @Entity() 4 | export class PlayerPerformance { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | playerId: string; 10 | 11 | @Column() 12 | gameTitle: string; 13 | 14 | @Column() 15 | score: number; 16 | 17 | @Column() 18 | accuracy: number; 19 | 20 | @Column() 21 | responseTime: number; 22 | 23 | @CreateDateColumn() 24 | createdAt: Date; 25 | } 26 | -------------------------------------------------------------------------------- /backend/src/voice/interfaces/room.interface.ts: -------------------------------------------------------------------------------- 1 | // src/voice/interfaces/room.interface.ts 2 | import { Participant } from './participant.interface'; 3 | 4 | export interface Room { 5 | id: string; // Unique room ID 6 | name: string; // Room display name 7 | participants: Map; // Map of participants by ID 8 | maxParticipants: number; // Max number of allowed participants 9 | createdAt: Date; // Room creation timestamp 10 | } -------------------------------------------------------------------------------- /backend/src/common/pagination/interfaces/pagination-interface.ts: -------------------------------------------------------------------------------- 1 | // an interface is a way to define the shape of an object, describing the structure and types of its properties 2 | export class paginated { 3 | data: T[]; 4 | meta: { 5 | itemsPerPage: number; 6 | totalItemsPerPage: number; 7 | currentPage: number; 8 | totalPages: number; 9 | }; 10 | links: { 11 | firstPage: string; 12 | lastPage: string; 13 | previousPage: string; 14 | currentPage: string; 15 | nextPage: string; 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /backend/src/social/dto/create-challenge.dto.ts: -------------------------------------------------------------------------------- 1 | // dto/create-challenge.dto.ts 2 | import { IsString, IsArray, IsDate, IsEnum, ValidateNested } from 'class-validator'; 3 | import { Type } from 'class-transformer'; 4 | 5 | export class CreateChallengeDto { 6 | @IsString() 7 | type: ChallengeType; 8 | 9 | @IsArray() 10 | @IsString({ each: true }) 11 | participants: string[]; 12 | 13 | @IsDate() 14 | @Type(() => Date) 15 | deadline: Date; 16 | 17 | @ValidateNested() 18 | @Type(() => RewardDto) 19 | reward: RewardDto; 20 | } -------------------------------------------------------------------------------- /backend/src/scoring/entities/scoring.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm'; 2 | 3 | @Entity() 4 | export class Scoring { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | userId: string; 10 | 11 | @Column({ type: 'int', default: 0 }) 12 | score: number; 13 | 14 | @Column({ type: 'int', default: 0 }) 15 | ranking: number; 16 | 17 | @CreateDateColumn() 18 | createdAt: Date; 19 | 20 | @UpdateDateColumn() 21 | updatedAt: Date; 22 | } 23 | -------------------------------------------------------------------------------- /backend/src/song/dto/create-song-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsNotEmpty, 3 | IsString, 4 | IsNumber, 5 | Min, 6 | IsOptional, 7 | } from 'class-validator'; 8 | 9 | export class CreateSongDto { 10 | @IsNotEmpty() 11 | @IsString() 12 | title: string; 13 | 14 | @IsNotEmpty() 15 | @IsString() 16 | artist: string; 17 | 18 | @IsOptional() 19 | @IsString() 20 | album?: string; 21 | 22 | // Duration in seconds; must be at least 1 second. 23 | @IsNotEmpty() 24 | @IsNumber() 25 | @Min(1) 26 | duration: number; 27 | } 28 | -------------------------------------------------------------------------------- /backend/src/config/configuration.ts: -------------------------------------------------------------------------------- 1 | export default () => ({ 2 | rateLimit: { 3 | ttl: parseInt(process.env.RATE_LIMIT_TTL, 10) || 60, // Default 60 seconds 4 | limit: parseInt(process.env.RATE_LIMIT_LIMIT, 10) || 10, // Default 10 requests per user/IP 5 | }, 6 | nodeEnv: process.env.NODE_ENV, 7 | port: parseInt(process.env.PORT, 10), 8 | database: { 9 | url: process.env.DATABASE_URL, 10 | }, 11 | jwt: { 12 | secret: process.env.JWT_SECRET, 13 | }, 14 | starknet: { 15 | network: process.env.STARKNET_NETWORK, 16 | }, 17 | }); -------------------------------------------------------------------------------- /backend/src/modules/auth/auth.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { JwtModule } from '@nestjs/jwt'; 3 | import { PassportModule } from '@nestjs/passport'; 4 | import { JwtStrategy } from './strategies/jwt.strategy'; 5 | 6 | @Module({ 7 | imports: [ 8 | PassportModule, 9 | JwtModule.register({ 10 | secret: process.env.JWT_SECRET || 'your-secret-key', 11 | signOptions: { expiresIn: '1h' }, 12 | }), 13 | ], 14 | providers: [JwtStrategy], 15 | exports: [JwtModule], 16 | }) 17 | export class AuthModule {} 18 | -------------------------------------------------------------------------------- /backend/src/game-insights/UserBehavior.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm'; 2 | 3 | @Entity() 4 | export class UserBehavior { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | playerId: string; 10 | 11 | @Column() 12 | gameTitle: string; 13 | 14 | @Column() 15 | actionType: string; // e.g., "click", "purchase", "abandon" 16 | 17 | @Column() 18 | genrePreference: string; // e.g., "FPS", "RPG", "Strategy" 19 | 20 | @CreateDateColumn() 21 | createdAt: Date; 22 | } 23 | -------------------------------------------------------------------------------- /backend/src/game-results/dto/game-result.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsNumber, IsObject, IsOptional, IsUUID } from 'class-validator'; 2 | 3 | export class CreateGameResultDto { 4 | @IsNotEmpty() 5 | @IsUUID() 6 | userId: string; 7 | 8 | @IsNotEmpty() 9 | @IsUUID() 10 | gameId: string; 11 | 12 | @IsNotEmpty() 13 | @IsObject() 14 | gameData: any; 15 | 16 | @IsNumber() 17 | @IsOptional() 18 | score?: number; 19 | 20 | @IsNumber() 21 | timeSpent: number; 22 | 23 | @IsOptional() 24 | achievements?: any[]; 25 | } -------------------------------------------------------------------------------- /backend/src/game/interfaces/game-mode.interface.ts: -------------------------------------------------------------------------------- 1 | export interface GameMode { 2 | id: string; 3 | name: string; 4 | description: string; 5 | rules: string[]; 6 | maxPlayers: number; 7 | minPlayers: number; 8 | scoringStrategy: string; 9 | timeLimit?: number; // in seconds, optional for endless mode 10 | initialize(): void; 11 | startGame(players: string[]): string; // returns game session id 12 | endGame(gameSessionId: string): GameResult; 13 | calculateScore(gameSessionId: string, playerId: string): number; 14 | } -------------------------------------------------------------------------------- /backend/src/player-engagement/dto/player-engagement.dto.ts: -------------------------------------------------------------------------------- 1 | export class PlayerEngagementDto { 2 | totalSessions: number; 3 | activeUsers: number; 4 | averageSessionDuration: number; 5 | retentionRate: number; 6 | peakActivityHours: number[]; 7 | dailyRetention: number; 8 | weeklyRetention: number; 9 | monthlyRetention: number; 10 | nDayRetention: Record; // { 1: %, 7: %, 30: % } 11 | churnRiskScore: number; 12 | engagementDepth: string[]; 13 | cohortGroup: string; 14 | timestamp: Date; 15 | } 16 | -------------------------------------------------------------------------------- /backend/src/redis/redis.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { RedisService } from './redis.service'; 3 | 4 | describe('RedisService', () => { 5 | let service: RedisService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [RedisService], 10 | }).compile(); 11 | 12 | service = module.get(RedisService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/songs/songs.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { SongsService } from './songs.service'; 3 | 4 | describe('SongsService', () => { 5 | let service: SongsService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [SongsService], 10 | }).compile(); 11 | 12 | service = module.get(SongsService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/song/providers/song.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { SongService } from './song.service'; 3 | 4 | describe('SongService', () => { 5 | let service: SongService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [SongService], 10 | }).compile(); 11 | 12 | service = module.get(SongService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/chat-room/chat-room.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, OneToMany, CreateDateColumn, UpdateDateColumn } from "typeorm"; 2 | import { Player } from "../player/player.entity"; 3 | 4 | @Entity('chat_rooms') 5 | export class ChatRoom { 6 | @PrimaryGeneratedColumn('uuid') 7 | id: string; 8 | 9 | @Column() 10 | name: string; 11 | 12 | @CreateDateColumn() 13 | createdAt: Date; 14 | 15 | @UpdateDateColumn() 16 | updatedAt: Date; 17 | 18 | @OneToMany(() => Player, player => player.chatRoom) 19 | players: Player[]; 20 | 21 | } -------------------------------------------------------------------------------- /backend/src/content-generator/content-generator.module.ts: -------------------------------------------------------------------------------- 1 | @Module({ 2 | imports: [ 3 | TypeOrmModule.forFeature([Template, GeneratedContent, ContentValidation]), 4 | BullModule.registerQueue({ 5 | name: 'content-generation' 6 | }) 7 | ], 8 | controllers: [ContentGeneratorController], 9 | providers: [ 10 | ContentGeneratorService, 11 | TemplateService, 12 | ValidationService, 13 | ContentQueueProcessor 14 | ], 15 | exports: [ContentGeneratorService] 16 | }) 17 | export class ContentGeneratorModule {} -------------------------------------------------------------------------------- /backend/src/progression/dtos/xp-event.dto.ts: -------------------------------------------------------------------------------- 1 | // src/progression/dtos/xp-event.dto.ts 2 | import { IsString, IsNumber, IsEnum, IsOptional } from 'class-validator'; 3 | 4 | export enum XpSource { 5 | GAME_WIN = 'GAME_WIN', 6 | ACHIEVEMENT = 'ACHIEVEMENT', 7 | QUEST = 'QUEST', 8 | DAILY_BONUS = 'DAILY_BONUS', 9 | } 10 | 11 | export class XpEventDto { 12 | @IsString() 13 | userId: string; 14 | 15 | @IsNumber() 16 | amount: number; 17 | 18 | @IsEnum(XpSource) 19 | source: XpSource; 20 | 21 | @IsOptional() 22 | @IsString() 23 | metadata?: string; 24 | } -------------------------------------------------------------------------------- /backend/src/voice/interfaces/participant.interface.ts: -------------------------------------------------------------------------------- 1 | // src/voice/interfaces/participant.interface.ts 2 | export interface Participant { 3 | id: string; // Unique ID for the participant 4 | socketId: string; // Socket connection ID 5 | username: string; // Display name 6 | muted: boolean; // Whether the participant is muted 7 | roomId: string; // ID of the room they're in 8 | qualityPreference: 'low' | 'medium' | 'high'; // Audio quality setting 9 | isRecording: boolean; // Whether participant is recording 10 | } 11 | -------------------------------------------------------------------------------- /backend/src/wager/provider/wager.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { WagerService } from './wager.service'; 3 | 4 | describe('WagerService', () => { 5 | let service: WagerService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [WagerService], 10 | }).compile(); 11 | 12 | service = module.get(WagerService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/interceptors/global.interceptor.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CallHandler, 3 | ExecutionContext, 4 | Injectable, 5 | NestInterceptor, 6 | } from '@nestjs/common'; 7 | import { map, Observable } from 'rxjs'; 8 | 9 | @Injectable() 10 | export class GlobalInterceptor implements NestInterceptor { 11 | intercept(context: ExecutionContext, next: CallHandler): Observable { 12 | return next.handle().pipe( 13 | map((data) => ({ 14 | success: true, 15 | data: data, 16 | message: 'test message', 17 | })), 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /backend/src/room/dto/get-room-base-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsDate, IsOptional } from 'class-validator'; 2 | 3 | import { IntersectionType } from '@nestjs/swagger'; 4 | import { Type } from 'class-transformer'; 5 | import { PaginationQueryDto } from 'src/common/pagination/pagination-query-dto.dto'; 6 | 7 | class GetRoomBaseDto { 8 | @IsDate() 9 | @IsOptional() 10 | startDate?: Date; 11 | 12 | @IsDate() 13 | @IsOptional() 14 | endDate?: Date; 15 | } 16 | 17 | export class GetRoomDto extends IntersectionType( 18 | GetRoomBaseDto, 19 | PaginationQueryDto, 20 | ) {} 21 | -------------------------------------------------------------------------------- /backend/src/reward/providers/reward.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { RewardService } from './reward.service'; 3 | 4 | describe('RewardService', () => { 5 | let service: RewardService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [RewardService], 10 | }).compile(); 11 | 12 | service = module.get(RewardService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/songs/dto/get-songs-base-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsDate, IsOptional } from 'class-validator'; 2 | 3 | import { IntersectionType } from '@nestjs/swagger'; 4 | import { Type } from 'class-transformer'; 5 | import { PaginationQueryDto } from 'src/common/pagination/pagination-query-dto.dto'; 6 | 7 | class GetSongsBaseDto { 8 | @IsDate() 9 | @IsOptional() 10 | startDate?: Date; 11 | 12 | @IsDate() 13 | @IsOptional() 14 | endDate?: Date; 15 | } 16 | 17 | export class GetSongsDto extends IntersectionType( 18 | GetSongsBaseDto, 19 | PaginationQueryDto, 20 | ) {} 21 | -------------------------------------------------------------------------------- /backend/src/tournament/tournament.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TypeOrmModule } from '@nestjs/typeorm'; 3 | import { TournamentService } from './tournament.service'; 4 | import { Tournament } from './tournament.entity'; 5 | import { User } from '../user/user.entity'; 6 | import { GameSession } from '../game-session/game-session.entity'; 7 | 8 | @Module({ 9 | imports: [TypeOrmModule.forFeature([Tournament, User, GameSession])], 10 | providers: [TournamentService], 11 | exports: [TournamentService], 12 | }) 13 | export class TournamentModule {} 14 | -------------------------------------------------------------------------------- /backend/src/user/dtos/get-users-base-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsDate, IsOptional } from 'class-validator'; 2 | 3 | import { IntersectionType } from '@nestjs/swagger'; 4 | import { Type } from 'class-transformer'; 5 | import { PaginationQueryDto } from 'src/common/pagination/pagination-query-dto.dto'; 6 | 7 | class GetUsersBaseDto { 8 | @IsDate() 9 | @IsOptional() 10 | startDate?: Date; 11 | 12 | @IsDate() 13 | @IsOptional() 14 | endDate?: Date; 15 | } 16 | 17 | export class GetUsersDto extends IntersectionType( 18 | GetUsersBaseDto, 19 | PaginationQueryDto, 20 | ) {} 21 | -------------------------------------------------------------------------------- /frontend/src/__mocks__/dojoCore.ts: -------------------------------------------------------------------------------- 1 | export const DojoProvider = { 2 | setup: jest.fn(), 3 | config: { 4 | rpcUrl: 'mock-rpc-url', 5 | toriiUrl: 'mock-torii-url', 6 | masterAddress: 'mock-master-address', 7 | masterPrivateKey: 'mock-private-key', 8 | accountClassHash: 'mock-class-hash', 9 | } 10 | }; 11 | 12 | export const setupDojoConfig = jest.fn(() => ({ 13 | rpcUrl: 'mock-rpc-url', 14 | toriiUrl: 'mock-torii-url', 15 | masterAddress: 'mock-master-address', 16 | masterPrivateKey: 'mock-private-key', 17 | accountClassHash: 'mock-class-hash', 18 | })); -------------------------------------------------------------------------------- /backend/src/config/test.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { ConfigService } from './providers/config.service'; 3 | 4 | @Controller('config-test') 5 | export class TestConfigController { 6 | constructor(private configService: ConfigService) {} 7 | 8 | @Get() 9 | getConfig() { 10 | return { 11 | environment: this.configService.get('nodeEnv'), 12 | port: this.configService.getPort(), 13 | starknetNetwork: this.configService.getStarknetNetwork(), 14 | isDev: this.configService.isDevelopment() 15 | }; 16 | } 17 | } -------------------------------------------------------------------------------- /backend/src/coupons/dto/generate-bulk-coupons.dto.ts: -------------------------------------------------------------------------------- 1 | // src/coupons/dto/generate-bulk-coupons.dto.ts 2 | import { IsNumber, IsString, IsOptional, Min, ValidateNested } from 'class-validator'; 3 | import { Type } from 'class-transformer'; 4 | import { CreateCouponDto } from './create-coupon.dto'; 5 | 6 | export class GenerateBulkCouponsDto { 7 | @IsNumber() 8 | @Min(1) 9 | count: number; 10 | 11 | @IsOptional() 12 | @IsString() 13 | prefix?: string; 14 | 15 | @ValidateNested() 16 | @Type(() => CreateCouponDto) 17 | baseProperties: Omit; 18 | } 19 | -------------------------------------------------------------------------------- /backend/src/game-mode/game-mode.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { GameModeService } from './game-mode.service'; 3 | 4 | describe('GameModeService', () => { 5 | let service: GameModeService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [GameModeService], 10 | }).compile(); 11 | 12 | service = module.get(GameModeService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/leaderboard/leaderboard.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne } from "typeorm"; 2 | import { Player } from "../player/player.entity"; 3 | 4 | @Entity('leaderboards') 5 | export class Leaderboard { 6 | @PrimaryGeneratedColumn('uuid') 7 | id: string; 8 | 9 | @Column({ type: "int", default: 0 }) 10 | rank: number; 11 | 12 | @Column({ type: "decimal", default: 0 }) 13 | score: number; 14 | 15 | @CreateDateColumn() 16 | createdAt: Date; 17 | 18 | @UpdateDateColumn() 19 | updatedAt: Date; 20 | } 21 | -------------------------------------------------------------------------------- /backend/src/social/friend/friend.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { FriendService } from '../services/friend.service'; 3 | 4 | describe('FriendService', () => { 5 | let service: FriendService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [FriendService], 10 | }).compile(); 11 | 12 | service = module.get(FriendService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/song/song.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { SongController } from './song.controller'; 3 | 4 | describe('SongController', () => { 5 | let controller: SongController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [SongController], 10 | }).compile(); 11 | 12 | controller = module.get(SongController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/questions/dto/get-question-base-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsDate, IsOptional } from 'class-validator'; 2 | 3 | import { IntersectionType } from '@nestjs/swagger'; 4 | import { Type } from 'class-transformer'; 5 | import { PaginationQueryDto } from 'src/common/pagination/pagination-query-dto.dto'; 6 | 7 | class GetQuestionBaseDto { 8 | @IsDate() 9 | @IsOptional() 10 | startDate?: Date; 11 | 12 | @IsDate() 13 | @IsOptional() 14 | endDate?: Date; 15 | } 16 | 17 | export class GetQuestionDto extends IntersectionType( 18 | GetQuestionBaseDto, 19 | PaginationQueryDto, 20 | ) {} 21 | -------------------------------------------------------------------------------- /backend/src/social/profile/profile.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ProfileService } from '../services/profile.service'; 3 | 4 | describe('ProfileService', () => { 5 | let service: ProfileService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [ProfileService], 10 | }).compile(); 11 | 12 | service = module.get(ProfileService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/song-genre/dtos/create-song.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNumber, IsObject, IsUUID, IsArray, IsOptional } from 'class-validator'; 2 | 3 | export class CreateSongDto { 4 | @IsString() 5 | title: string; 6 | 7 | @IsString() 8 | artist: string; 9 | 10 | @IsNumber() 11 | durationSeconds: number; 12 | 13 | @IsNumber() 14 | baseDifficulty: number; 15 | 16 | @IsObject() 17 | difficultyFactors: Record; 18 | 19 | @IsUUID() 20 | genreId: string; 21 | 22 | @IsOptional() 23 | @IsArray() 24 | @IsString({ each: true }) 25 | tagIds?: string[]; 26 | } -------------------------------------------------------------------------------- /backend/src/song/providers/song.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | // Service responsible for managing songs. 4 | @Injectable() 5 | export class SongService { 6 | // Retrieve the list of available rewards. 7 | getSongs() { 8 | // Implement get songs logic 9 | } 10 | 11 | // Add a new song. 12 | addSong() { 13 | // Implement add song logic 14 | } 15 | // Update a song. 16 | updateSong() { 17 | // Implement update song logic 18 | } 19 | 20 | // Delete a song. 21 | deleteSong() { 22 | // Implement delete song logic 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /backend/src/wager/wager.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { WagerController } from './wager.controller'; 3 | 4 | describe('WagerController', () => { 5 | let controller: WagerController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [WagerController], 10 | }).compile(); 11 | 12 | controller = module.get(WagerController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/referral/referral.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TypeOrmModule } from '@nestjs/typeorm'; 3 | import { ReferralService } from './referral.service'; 4 | import { ReferralController } from './referral.controller'; 5 | import { Referral } from './entities/referral.entity'; 6 | import { User } from '../user/entities/user.entity'; 7 | 8 | @Module({ 9 | imports: [TypeOrmModule.forFeature([Referral, User])], 10 | controllers: [ReferralController], 11 | providers: [ReferralService], 12 | exports: [ReferralService], 13 | }) 14 | export class ReferralModule {} 15 | -------------------------------------------------------------------------------- /backend/src/song-genre/services/song.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { SongGenreService } from './song.service'; 3 | 4 | describe('SongGenreService', () => { 5 | let service: SongGenreService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [SongGenreService], 10 | }).compile(); 11 | 12 | service = module.get(SongGenreService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/game-results/dto/get-gamesresult-base-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsDate, IsOptional } from 'class-validator'; 2 | import { IntersectionType } from '@nestjs/swagger'; 3 | import { Type } from 'class-transformer'; 4 | import { PaginationQueryDto } from 'src/common/pagination/pagination-query-dto.dto'; 5 | 6 | class GetGamesResultBaseDto { 7 | @IsDate() 8 | @IsOptional() 9 | startDate?: Date; 10 | 11 | @IsDate() 12 | @IsOptional() 13 | endDate?: Date; 14 | } 15 | 16 | export class GetGamesResultsDto extends IntersectionType( 17 | GetGamesResultBaseDto, 18 | PaginationQueryDto, 19 | ) {} 20 | -------------------------------------------------------------------------------- /backend/src/game-session/providers/game-session.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | // Service responsible for managing game sessions. 4 | @Injectable() 5 | export class GameSessionService { 6 | // Start a new game session. 7 | startGameSession() { 8 | // Implement start game session logic 9 | } 10 | // Submit a guess for an ongoing game session. 11 | submitGuess() { 12 | // Implement submit guess logic 13 | } 14 | // Retrieve the details of a specific game session. 15 | getSessionDetails() { 16 | // Implement get session details logic 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /backend/src/leaderboard/dto/leaderboard.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsUUID, 3 | IsInt, 4 | IsNumber, 5 | IsISO8601, 6 | IsNotEmpty, 7 | } from 'class-validator'; 8 | 9 | export class LeaderboardDto { 10 | @IsUUID() 11 | @IsNotEmpty() 12 | id: string; 13 | 14 | @IsUUID() 15 | @IsNotEmpty() 16 | playerId: string; 17 | 18 | @IsInt() 19 | @IsNotEmpty() 20 | rank: number; 21 | 22 | @IsNumber() 23 | @IsNotEmpty() 24 | score: number; 25 | 26 | @IsISO8601() 27 | @IsNotEmpty() 28 | createdAt: string; 29 | 30 | @IsISO8601() 31 | @IsNotEmpty() 32 | updatedAt: string; 33 | } 34 | -------------------------------------------------------------------------------- /backend/src/reward/reward.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { RewardController } from './reward.controller'; 3 | 4 | describe('RewardController', () => { 5 | let controller: RewardController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [RewardController], 10 | }).compile(); 11 | 12 | controller = module.get(RewardController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/social/activity/activity.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ActivityService } from '../services/activity.service'; 3 | 4 | describe('ActivityService', () => { 5 | let service: ActivityService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [ActivityService], 10 | }).compile(); 11 | 12 | service = module.get(ActivityService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/tournament/tournament.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { TournamentService } from './tournament.service'; 3 | 4 | describe('TournamentService', () => { 5 | let service: TournamentService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [TournamentService], 10 | }).compile(); 11 | 12 | service = module.get(TournamentService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/achievement/achievement.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { AchievementService } from './achievement.service'; 3 | 4 | describe('AchievementService', () => { 5 | let service: AchievementService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [AchievementService], 10 | }).compile(); 11 | 12 | service = module.get(AchievementService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/notification/dto/notiication.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsEnum, IsNotEmpty } from 'class-validator'; 2 | import { NotificationType } from '../enums/notification-type.enum'; 3 | import { NotificationStatus } from '../enums/notifcation-status.enum'; 4 | 5 | export class NotificationDto { 6 | @IsString() 7 | @IsNotEmpty() 8 | playerId: string; 9 | 10 | @IsString() 11 | @IsNotEmpty() 12 | message: string; 13 | 14 | @IsEnum(NotificationType) 15 | @IsNotEmpty() 16 | type: NotificationType; 17 | 18 | @IsEnum(NotificationStatus) 19 | @IsNotEmpty() 20 | status: NotificationStatus; 21 | } 22 | -------------------------------------------------------------------------------- /backend/src/social/challenge/challenge.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ChallengeService } from '../services/challenge.service'; 3 | 4 | describe('ChallengeService', () => { 5 | let service: ChallengeService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [ChallengeService], 10 | }).compile(); 11 | 12 | service = module.get(ChallengeService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/store/entities/store-item.entity.ts: -------------------------------------------------------------------------------- 1 | // src/store/entities/store-item.entity.ts 2 | @Entity() 3 | export class StoreItem { 4 | @PrimaryGeneratedColumn('uuid') 5 | id: string; 6 | 7 | @Column() 8 | name: string; 9 | 10 | @Column() 11 | description: string; 12 | 13 | @Column() 14 | price: number; 15 | 16 | @Column() 17 | type: string; // POWER_UP, COSMETIC, etc. 18 | 19 | @Column() 20 | image: string; 21 | 22 | @Column({ default: true }) 23 | isActive: boolean; 24 | 25 | @CreateDateColumn() 26 | createdAt: Date; 27 | 28 | @UpdateDateColumn() 29 | updatedAt: Date; 30 | } -------------------------------------------------------------------------------- /backend/src/modules/notification/entities/notification.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm'; 2 | 3 | @Entity('notifications') 4 | export class Notification { 5 | @PrimaryGeneratedColumn('uuid') 6 | id: string; 7 | 8 | @Column() 9 | userId: string; 10 | 11 | @Column() 12 | type: string; 13 | 14 | @Column() 15 | message: string; 16 | 17 | @Column({ type: 'json', nullable: true }) 18 | metadata: Record; 19 | 20 | @Column({ default: false }) 21 | isRead: boolean; 22 | 23 | @CreateDateColumn() 24 | createdAt: Date; 25 | } 26 | -------------------------------------------------------------------------------- /backend/src/power-ups/entities/power-up-purchase.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm'; 2 | import { PowerUp } from './power-up.entity'; 3 | import { User } from 'src/user/user.entity'; 4 | 5 | @Entity() 6 | export class PowerUpPurchase { 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @ManyToOne(() => PowerUp) 11 | powerUp: PowerUp; 12 | 13 | @ManyToOne(() => User) 14 | user: User; 15 | 16 | @Column() 17 | purchaseDate: Date; 18 | 19 | @Column() 20 | expirationDate: Date; 21 | 22 | @Column({ default: false }) 23 | isUsed: boolean; 24 | } 25 | -------------------------------------------------------------------------------- /backend/src/referral/dto/create-referral.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsOptional, IsObject } from 'class-validator'; 2 | import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; 3 | 4 | export class CreateReferralDto { 5 | @ApiProperty({ description: 'ID of the user creating the referral' }) 6 | @IsString() 7 | referrerId: string; 8 | 9 | @ApiPropertyOptional({ 10 | description: 'Additional metadata about the referral', 11 | }) 12 | @IsOptional() 13 | @IsObject() 14 | metadata?: { 15 | conversionSource?: string; 16 | browserInfo?: string; 17 | ipAddress?: string; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/transports/custom-transport.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as Transport from 'winston-transport'; 3 | 4 | export class CustomTransport extends Transport { 5 | constructor(opts?: Transport.TransportStreamOptions) { 6 | super(opts); 7 | } 8 | 9 | log(info: any, callback: () => void) { 10 | setImmediate(() => { 11 | this.emit('logged', info); 12 | }); 13 | 14 | // Process the log entry 15 | const { level, message, ...meta } = info; 16 | 17 | // Implement your custom logging logic here 18 | // Example: Send to a custom service, database, etc. 19 | 20 | callback(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /backend/src/leaderboard/providers/leaderboard.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { LeaderboardService } from './leaderboard.service'; 3 | 4 | describe('LeaderboardService', () => { 5 | let service: LeaderboardService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [LeaderboardService], 10 | }).compile(); 11 | 12 | service = module.get(LeaderboardService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/modules/share/entities/share-analytics.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm'; 2 | 3 | @Entity('share_analytics') 4 | export class ShareAnalytics { 5 | @PrimaryGeneratedColumn('uuid') 6 | id: string; 7 | 8 | @Column() 9 | shareId: string; 10 | 11 | @Column({ default: 0 }) 12 | views: number; 13 | 14 | @Column({ default: 0 }) 15 | clicks: number; 16 | 17 | @Column({ default: 0 }) 18 | reshares: number; 19 | 20 | @CreateDateColumn() 21 | createdAt: Date; 22 | 23 | @UpdateDateColumn() 24 | updatedAt: Date; 25 | } 26 | -------------------------------------------------------------------------------- /backend/src/social/friend/friend.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { FriendController } from '../controllers/friend.controller'; 3 | 4 | describe('FriendController', () => { 5 | let controller: FriendController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [FriendController], 10 | }).compile(); 11 | 12 | controller = module.get(FriendController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/filters/ws-exception.filter.ts: -------------------------------------------------------------------------------- 1 | import { Catch, ArgumentsHost } from '@nestjs/common'; 2 | import { BaseWsExceptionFilter } from '@nestjs/websockets'; 3 | import { WsException } from '../exceptions/ws.exception'; 4 | import { Socket } from 'socket.io'; 5 | 6 | @Catch(WsException) 7 | export class WsExceptionFilter extends BaseWsExceptionFilter { 8 | catch(exception: WsException, host: ArgumentsHost) { 9 | const client = host.switchToWs().getClient(); 10 | 11 | client.emit('error', { 12 | code: exception.code || 'INTERNAL_ERROR', 13 | message: exception.message 14 | }); 15 | } 16 | } -------------------------------------------------------------------------------- /backend/src/game-session/providers/game-session.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { GameSessionService } from './game-session.service'; 3 | 4 | describe('GameSessionService', () => { 5 | let service: GameSessionService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [GameSessionService], 10 | }).compile(); 11 | 12 | service = module.get(GameSessionService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/notification/notification.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne } from "typeorm"; 2 | import { Player } from "../player/player.entity"; 3 | 4 | @Entity('notifications') 5 | export class Notification { 6 | @PrimaryGeneratedColumn('uuid') 7 | id: string; 8 | 9 | @Column({ type: "text" }) 10 | message: string; 11 | 12 | @Column({ type: "enum", enum: ["info", "warning", "alert"], default: "info" }) 13 | type: string; 14 | 15 | @Column({ type: "boolean", default: false }) 16 | isRead: boolean; 17 | 18 | @CreateDateColumn() 19 | createdAt: Date; 20 | } 21 | -------------------------------------------------------------------------------- /backend/src/sync/interfaces/sync-strategy.interface.ts: -------------------------------------------------------------------------------- 1 | // src/sync/interfaces/sync-strategy.interface.ts 2 | import { Mergeable } from './mergeable.interface'; 3 | 4 | export interface SyncStrategy { 5 | /** 6 | * Resolves conflicts between local and remote versions 7 | * @param local Local version of the data 8 | * @param remote Remote version of the data 9 | * @param base Common ancestor version (if available) 10 | * @returns Merged result 11 | */ 12 | resolve>(local: T, remote: T, base?: T): T; 13 | 14 | /** 15 | * Name of the strategy 16 | */ 17 | getName(): string; 18 | } -------------------------------------------------------------------------------- /backend/src/music-education/user-progress/entities/user-progress.entity.ts: -------------------------------------------------------------------------------- 1 | import { MusicLesson } from 'src/music-education/music-lessons/entities/music-theory-lesson.entity'; 2 | import { User } from 'src/user/user.entity'; 3 | import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm'; 4 | 5 | @Entity() 6 | export class UserProgress { 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @ManyToOne(() => User, { eager: true }) 11 | user: User; 12 | 13 | @ManyToOne(() => MusicLesson, { eager: true }) 14 | lesson: MusicLesson; 15 | 16 | @Column({ default: false }) 17 | completed: boolean; 18 | } 19 | -------------------------------------------------------------------------------- /backend/src/notification/providers/notification.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { NotificationService } from './notification.service'; 3 | 4 | describe('NotificationService', () => { 5 | let service: NotificationService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [NotificationService], 10 | }).compile(); 11 | 12 | service = module.get(NotificationService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/progression/entities/player-skill.entity.ts: -------------------------------------------------------------------------------- 1 | // src/progression/entities/player-skill.entity.ts 2 | import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'; 3 | import { PlayerStats } from './player-stats.entity'; 4 | 5 | @Entity() 6 | export class PlayerSkill { 7 | @PrimaryGeneratedColumn('uuid') 8 | id: string; 9 | 10 | @ManyToOne(() => PlayerStats, stats => stats.skills) 11 | playerStats: PlayerStats; 12 | 13 | @Column() 14 | name: string; 15 | 16 | @Column({ type: 'int', default: 0 }) 17 | level: number; 18 | 19 | @Column({ type: 'int', default: 0 }) 20 | experience: number; 21 | } -------------------------------------------------------------------------------- /backend/src/social/profile/profile.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ProfileController } from '../controllers/profile.controller'; 3 | 4 | describe('ProfileController', () => { 5 | let controller: ProfileController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [ProfileController], 10 | }).compile(); 11 | 12 | controller = module.get(ProfileController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/state-recovery/state-recovery.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { StateRecoveryService } from './state-recovery.service'; 3 | 4 | describe('StateRecoveryService', () => { 5 | let service: StateRecoveryService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [StateRecoveryService], 10 | }).compile(); 11 | 12 | service = module.get(StateRecoveryService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/achievement/achievement.gateway.ts: -------------------------------------------------------------------------------- 1 | // src/achievement/achievement.gateway.ts 2 | import { WebSocketGateway, WebSocketServer } from '@nestjs/websockets'; 3 | import { Server } from 'socket.io'; 4 | import { OnEvent } from '@nestjs/event-emitter'; 5 | 6 | @WebSocketGateway() 7 | export class AchievementGateway { 8 | @WebSocketServer() 9 | server: Server; 10 | 11 | @OnEvent('achievement.unlocked') 12 | handleAchievementUnlocked(payload: any) { 13 | this.server.to(payload.userId).emit('achievementUnlocked', { 14 | achievement: payload.achievement, 15 | unlockedAt: payload.unlockedAt, 16 | }); 17 | } 18 | } -------------------------------------------------------------------------------- /backend/src/social/notification/notification.gateway.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { NotificationGateway } from '../gateways/notification.gateway'; 3 | 4 | describe('NotificationGateway', () => { 5 | let gateway: NotificationGateway; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [NotificationGateway], 10 | }).compile(); 11 | 12 | gateway = module.get(NotificationGateway); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(gateway).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/social/notification/notification.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { NotificationService } from '../services/notification.service'; 3 | 4 | describe('NotificationService', () => { 5 | let service: NotificationService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [NotificationService], 10 | }).compile(); 11 | 12 | service = module.get(NotificationService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /onchain/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lyricsflip" 3 | version = "0.1.0" 4 | edition = "2023_11" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.4" 10 | openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.19.0" } 11 | 12 | 13 | [dev-dependencies] 14 | snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.31.0" } 15 | 16 | [[target.starknet-contract]] 17 | sierra = true 18 | 19 | [scripts] 20 | test = "snforge test" 21 | 22 | [tool.fmt] 23 | sort-module-level-items = true -------------------------------------------------------------------------------- /backend/src/social/activity/activity.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ActivityController } from '../controllers/activity.controller'; 3 | 4 | describe('ActivityController', () => { 5 | let controller: ActivityController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [ActivityController], 10 | }).compile(); 11 | 12 | controller = module.get(ActivityController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/wager/dto/create-wager-dto.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsNotEmpty, 3 | IsNumber, 4 | Min, 5 | IsUUID, 6 | IsOptional, 7 | IsString, 8 | } from 'class-validator'; 9 | 10 | export class CreateWagerDto { 11 | @IsNotEmpty() 12 | @IsNumber() 13 | @Min(0.01, { message: 'Wager amount must be at least 0.01' }) 14 | amount: number; 15 | 16 | // Assuming each wager is linked to a user 17 | @IsNotEmpty() 18 | @IsUUID() 19 | userId: string; 20 | 21 | // And to a specific event or game 22 | @IsNotEmpty() 23 | @IsUUID() 24 | eventId: string; 25 | 26 | @IsOptional() 27 | @IsString() 28 | status?: string; 29 | } 30 | -------------------------------------------------------------------------------- /backend/src/achievement/achievement.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { AchievementController } from './achievement.controller'; 3 | 4 | describe('AchievementController', () => { 5 | let controller: AchievementController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [AchievementController], 10 | }).compile(); 11 | 12 | controller = module.get(AchievementController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/leaderboard/leaderboard.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { LeaderboardController } from './leaderboard.controller'; 3 | 4 | describe('LeaderboardController', () => { 5 | let controller: LeaderboardController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [LeaderboardController], 10 | }).compile(); 11 | 12 | controller = module.get(LeaderboardController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "ES2021", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true, 15 | "strictNullChecks": false, 16 | "noImplicitAny": false, 17 | "strictBindCallApply": false, 18 | "forceConsistentCasingInFileNames": false, 19 | "noFallthroughCasesInSwitch": false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /backend/src/analytics/guards/analytics-auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, type CanActivate, type ExecutionContext } from "@nestjs/common" 2 | import type { Observable } from "rxjs" 3 | 4 | @Injectable() 5 | export class AnalyticsAuthGuard implements CanActivate { 6 | canActivate(context: ExecutionContext): boolean | Promise | Observable { 7 | const request = context.switchToHttp().getRequest() 8 | // Implement your authentication logic here 9 | // This is a simple example - you should implement proper authentication 10 | return request.headers["x-analytics-key"] === process.env.ANALYTICS_API_KEY 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /backend/src/config-manager/entities/config.entity.ts: -------------------------------------------------------------------------------- 1 | @Entity() 2 | export class ConfigEntry { 3 | @PrimaryGeneratedColumn('uuid') 4 | id: string; 5 | 6 | @Column({ unique: true }) 7 | key: string; 8 | 9 | @Column('json') 10 | value: any; 11 | 12 | @Column() 13 | version: number; 14 | 15 | @Column({ default: true }) 16 | isActive: boolean; 17 | 18 | @Column('json', { nullable: true }) 19 | validationRules: any; 20 | 21 | @Column({ nullable: true }) 22 | description: string; 23 | 24 | @CreateDateColumn() 25 | createdAt: Date; 26 | 27 | @UpdateDateColumn() 28 | updatedAt: Date; 29 | } -------------------------------------------------------------------------------- /backend/src/game-session/game-session.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { GameSessionController } from './game-session.controller'; 3 | 4 | describe('GameSessionController', () => { 5 | let controller: GameSessionController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [GameSessionController], 10 | }).compile(); 11 | 12 | controller = module.get(GameSessionController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/modules/auth/strategies/jwt.strategy.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { PassportStrategy } from '@nestjs/passport'; 3 | import { ExtractJwt, Strategy } from 'passport-jwt'; 4 | 5 | @Injectable() 6 | export class JwtStrategy extends PassportStrategy(Strategy) { 7 | constructor() { 8 | super({ 9 | jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), 10 | ignoreExpiration: false, 11 | secretOrKey: process.env.JWT_SECRET || 'your-secret-key', 12 | }); 13 | } 14 | 15 | async validate(payload: any) { 16 | return { userId: payload.sub, username: payload.username }; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /backend/src/music-education/music-theory-lesson.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { MusicEducationService } from './music-theory-lesson.service'; 3 | 4 | describe('MusicEducationService', () => { 5 | let service: MusicEducationService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [MusicEducationService], 10 | }).compile(); 11 | 12 | service = module.get(MusicEducationService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/social/challenge/challenge.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ChallengeController } from '../controllers/challenge.controller'; 3 | 4 | describe('ChallengeController', () => { 5 | let controller: ChallengeController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [ChallengeController], 10 | }).compile(); 11 | 12 | controller = module.get(ChallengeController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/notification/notification.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { NotificationController } from './notification.controller'; 3 | 4 | describe('NotificationController', () => { 5 | let controller: NotificationController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [NotificationController], 10 | }).compile(); 11 | 12 | controller = module.get(NotificationController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /backend/src/game-session/game-session.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { GameSessionController } from './game-session.controller'; 3 | import { GameSessionService } from './providers/game-session.service'; 4 | import { ConfigModule } from '@nestjs/config'; 5 | import jwtConfig from 'src/auth/authConfig/jwt.config'; 6 | import { JwtModule } from '@nestjs/jwt'; 7 | 8 | @Module({ 9 | imports: [ 10 | ConfigModule.forFeature(jwtConfig), 11 | JwtModule.registerAsync(jwtConfig.asProvider()), 12 | ], 13 | controllers: [GameSessionController], 14 | providers: [GameSessionService], 15 | }) 16 | export class GameSessionModule {} 17 | -------------------------------------------------------------------------------- /backend/src/game-mode/game-mode.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Post, Body, Request} from '@nestjs/common'; 2 | import { GameModeService } from './game-mode.service'; 3 | import { GameModeDto } from './dto/create-game-mode.dto'; 4 | 5 | @Controller('game-mode') 6 | export class GameModeController { 7 | constructor(private readonly gameModeService: GameModeService) {} 8 | 9 | @Post() 10 | async createGameMode(@Body() data: GameModeDto, @Request() req) { 11 | return this.gameModeService.createGameMode(data, req.user); 12 | } 13 | 14 | @Get() 15 | async getAllGameModes() { 16 | return this.gameModeService.getAllGameModes(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /frontend/src/components/atoms/score-badge.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils'; 2 | 3 | interface ScoreBadgeProps { 4 | score: number 5 | maxScore?: number 6 | className?: string 7 | } 8 | 9 | export function ScoreBadge({ score, maxScore, className }: ScoreBadgeProps) { 10 | return ( 11 |
12 | {score} 13 | {maxScore && ( 14 | <> 15 | | 16 | {maxScore} 17 | 18 | )} 19 |
20 | ); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /backend/src/achievement/dto/create-achievement.dto.ts: -------------------------------------------------------------------------------- 1 | // src/achievement/dto/create-achievement.dto.ts 2 | import { IsString, IsEnum, IsNumber, IsObject, IsNotEmpty } from 'class-validator'; 3 | import { AchievementCategory } from '../entities/achievement.entity'; 4 | 5 | export class CreateAchievementDto { 6 | @IsString() 7 | @IsNotEmpty() 8 | title: string; 9 | 10 | @IsString() 11 | @IsNotEmpty() 12 | description: string; 13 | 14 | @IsString() 15 | icon: string; 16 | 17 | @IsEnum(AchievementCategory) 18 | category: AchievementCategory; 19 | 20 | @IsNumber() 21 | pointsValue: number; 22 | 23 | @IsObject() 24 | criteria: Record; 25 | } -------------------------------------------------------------------------------- /backend/src/analytics/dto/player-engagement.dto.ts: -------------------------------------------------------------------------------- 1 | import { ApiProperty } from "@nestjs/swagger" 2 | import { IsNumber, IsDate, IsArray } from "class-validator" 3 | 4 | export class PlayerEngagementDto { 5 | @ApiProperty() 6 | @IsNumber() 7 | totalSessions: number 8 | 9 | @ApiProperty() 10 | @IsNumber() 11 | activeUsers: number 12 | 13 | @ApiProperty() 14 | @IsNumber() 15 | averageSessionDuration: number 16 | 17 | @ApiProperty() 18 | @IsNumber() 19 | retentionRate: number 20 | 21 | @ApiProperty({ type: [Number] }) 22 | @IsArray() 23 | peakActivityHours: number[] 24 | 25 | @ApiProperty() 26 | @IsDate() 27 | timestamp: Date 28 | } 29 | 30 | -------------------------------------------------------------------------------- /backend/src/auth/providers/bcrypt-provider.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import * as bcrypt from 'bcrypt' 3 | 4 | @Injectable() 5 | export class BcryptProvider { 6 | // hash paassword 7 | public async hashPassword(impPassword: string | Buffer): Promise { 8 | const saltRounds = 10 9 | const salt = await bcrypt.genSalt(saltRounds) 10 | return await bcrypt.hash(impPassword, salt) 11 | } 12 | 13 | // conpare passwords 14 | public async comparePasswords(passwordData: string, encryptedPassword: string): Promise { 15 | return await bcrypt.compare(passwordData, encryptedPassword) 16 | } 17 | } -------------------------------------------------------------------------------- /backend/src/db-migration/entities/migration-lock.entity.ts: -------------------------------------------------------------------------------- 1 | // src/db-migration/entities/migration-lock.entity.ts 2 | import { Entity, Column, PrimaryColumn, UpdateDateColumn } from 'typeorm'; 3 | 4 | @Entity('migration_lock') 5 | export class MigrationLock { 6 | @PrimaryColumn() 7 | id: string; 8 | 9 | @Column() 10 | lockedBy: string; 11 | 12 | @Column() 13 | lockedAt: Date; 14 | 15 | @Column({ nullable: true }) 16 | expiresAt?: Date; 17 | 18 | @Column({ default: false }) 19 | isExecuting: boolean; 20 | 21 | @Column({ nullable: true }) 22 | currentMigrationId?: string; 23 | 24 | @UpdateDateColumn() 25 | updatedAt: Date; 26 | } 27 | -------------------------------------------------------------------------------- /backend/src/wager/provider/wager.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | // Service responsible for handling wager operations. 4 | @Injectable() 5 | export class WagerService { 6 | // Place a wager. 7 | placeWager() { 8 | // Implement place wager logic 9 | } 10 | // Get wager history. 11 | // This method will retrieve the history of wagers placed by the user. 12 | getWagerHistory() { 13 | // Implement get wager history logic 14 | } 15 | 16 | // Claim winnings. 17 | // This method will handle the logic to claim the winnings from a wager. 18 | claimWinnings() { 19 | // Implement claim winnings logic 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /frontend/src/store/modal-store.ts: -------------------------------------------------------------------------------- 1 | import { create } from 'zustand'; 2 | 3 | type ModalType = 4 | | 'game' 5 | | 'settings' 6 | | 'profile' 7 | | 'leaderboard' 8 | | 'wager' 9 | | 'wager-summary' 10 | | 'won' 11 | | 'lost' 12 | | null; 13 | 14 | interface ModalState { 15 | isOpen: boolean; 16 | modalType: ModalType; 17 | openModal: (type: ModalType) => void; 18 | closeModal: () => void; 19 | } 20 | 21 | export const useModalStore = create((set) => ({ 22 | isOpen: false, 23 | modalType: null, 24 | openModal: (type) => set({ isOpen: true, modalType: type }), 25 | closeModal: () => set({ isOpen: false, modalType: null }), 26 | })); 27 | -------------------------------------------------------------------------------- /backend/src/game-mode/entities/game-mode.entity.ts: -------------------------------------------------------------------------------- 1 | import { User } from 'src/user/user.entity'; 2 | import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm'; 3 | 4 | @Entity() 5 | export class GameMode { 6 | @PrimaryGeneratedColumn() 7 | id: string; 8 | 9 | @Column() 10 | name: string; 11 | 12 | @Column('json') 13 | rules: { 14 | timeLimit: number; 15 | pointSystem: Record; 16 | powerUpsAllowed: string[]; 17 | minimumPlayers: number; 18 | specialConditions: string[]; 19 | }; 20 | 21 | @Column() 22 | isPublic: boolean; 23 | 24 | @ManyToOne(() => User, (user) => user.gameModes) 25 | creator: User; 26 | } -------------------------------------------------------------------------------- /backend/src/game/strategies/scoring/endless-scoring.strategy.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { ScoringStrategy } from '../strategies/scoring/scoring-strategy.interface'; 3 | 4 | @Injectable() 5 | export class EndlessScoringStrategy implements ScoringStrategy { 6 | calculateScore(gameData: any, playerId: string): number { 7 | // Implementation based on endless mode rules 8 | // Points based on endurance and progression difficulty 9 | const baseScore = gameData.playerStats[playerId].points; 10 | const levelMultiplier = 1 + (gameData.playerStats[playerId].level * 0.1); 11 | return Math.floor(baseScore * levelMultiplier); 12 | } 13 | } -------------------------------------------------------------------------------- /backend/src/game/strategies/scoring/time-attack-scoring.strategy.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { ScoringStrategy } from './scoring-strategy.interface'; 3 | 4 | @Injectable() 5 | export class TimeAttackScoringStrategy implements ScoringStrategy { 6 | calculateScore(gameData: any, playerId: string): number { 7 | // Implementation based on time attack mode rules 8 | // Points based on speed of completion and accuracy 9 | const baseScore = gameData.playerStats[playerId].points; 10 | const timeBonus = Math.max(0, gameData.timeLimit - gameData.playerStats[playerId].timeTaken); 11 | return baseScore + (timeBonus * 10); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /backend/src/social/notification/notification.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { NotificationController } from '../controllers/notification.controller'; 3 | 4 | describe('NotificationController', () => { 5 | let controller: NotificationController; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | controllers: [NotificationController], 10 | }).compile(); 11 | 12 | controller = module.get(NotificationController); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(controller).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | .pnpm-debug.log* 32 | 33 | # env files (can opt-in for committing if needed) 34 | .env* 35 | 36 | # vercel 37 | .vercel 38 | 39 | # typescript 40 | *.tsbuildinfo 41 | next-env.d.ts 42 | -------------------------------------------------------------------------------- /backend/src/music-education/quiz/providers/quiz.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { InjectRepository } from '@nestjs/typeorm'; 3 | import { Repository } from 'typeorm'; 4 | import { Quiz } from '../entities/quiz.entity'; 5 | 6 | @Injectable() 7 | export class QuizService { 8 | constructor( 9 | @InjectRepository(Quiz) 10 | private readonly quizRepo: Repository, 11 | ) {} 12 | 13 | findAll() { 14 | return this.quizRepo.find(); 15 | } 16 | 17 | findOne(id: number) { 18 | return this.quizRepo.findOne({ where: { id } }); 19 | } 20 | 21 | create(quiz: Partial) { 22 | return this.quizRepo.save(quiz); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /backend/src/songs/songs.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { SongsController } from './songs.controller'; 3 | import { SongsService } from './songs.service'; 4 | 5 | describe('SongsController', () => { 6 | let controller: SongsController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [SongsController], 11 | providers: [SongsService], 12 | }).compile(); 13 | 14 | controller = module.get(SongsController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /backend/src/songs/songs.module.ts: -------------------------------------------------------------------------------- 1 | // src/songs/songs.module.ts 2 | import { Module } from '@nestjs/common'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { SongsService } from './songs.service'; 5 | import { SongsController } from './songs.controller'; 6 | import { Song } from './entities/song.entity'; 7 | import { RedisService } from 'src/redis/redis.service'; 8 | import { Difficulty } from 'src/difficulty/entities/difficulty.entity'; 9 | 10 | @Module({ 11 | imports: [TypeOrmModule.forFeature([Song, Difficulty]), RedisService], 12 | controllers: [SongsController], 13 | providers: [SongsService], 14 | exports: [SongsService], 15 | }) 16 | export class SongsModule {} -------------------------------------------------------------------------------- /backend/src/game/game-modes/battle-royale-scoring.strategy.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { ScoringStrategy } from '../strategies/scoring/scoring-strategy.interface'; 3 | 4 | @Injectable() 5 | export class BattleRoyaleScoringStrategy implements ScoringStrategy { 6 | calculateScore(gameData: any, playerId: string): number { 7 | // Implementation based on battle royale mode rules 8 | // Points based on survival time and eliminations 9 | const survivalPoints = gameData.playerStats[playerId].survivalTime * 2; 10 | const eliminationPoints = gameData.playerStats[playerId].eliminations * 100; 11 | return survivalPoints + eliminationPoints; 12 | } 13 | } -------------------------------------------------------------------------------- /backend/src/music-education/quiz/quiz.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Post, Body, Param } from '@nestjs/common'; 2 | import { QuizService } from './providers/quiz.service'; 3 | import { Quiz } from './entities/quiz.entity'; 4 | 5 | @Controller('quizzes') 6 | export class QuizController { 7 | constructor(private readonly quizService: QuizService) {} 8 | 9 | @Get() 10 | findAll() { 11 | return this.quizService.findAll(); 12 | } 13 | 14 | @Get(':id') 15 | findOne(@Param('id') id: number) { 16 | return this.quizService.findOne(id); 17 | } 18 | 19 | @Post() 20 | create(@Body() quiz: Partial) { 21 | return this.quizService.create(quiz); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.github/workflows/cairo.yml: -------------------------------------------------------------------------------- 1 | name: LyricsFlip Contracts 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - main 8 | pull_request: 9 | permissions: read-all 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: asdf-vm/actions/install@v3 16 | - run: scarb fmt --check 17 | working-directory: onchain 18 | - run: scarb build 19 | working-directory: onchain 20 | 21 | test: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v4 25 | - uses: asdf-vm/actions/install@v3 26 | - run: snforge test 27 | working-directory: onchain -------------------------------------------------------------------------------- /backend/src/game-results/entities/game-result.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, Index } from 'typeorm'; 2 | 3 | @Entity('game_results') 4 | export class GameResult { 5 | @PrimaryGeneratedColumn('uuid') 6 | id: string; 7 | 8 | @Column() 9 | @Index() 10 | userId: string; 11 | 12 | @Column() 13 | gameId: string; 14 | 15 | @Column('json') 16 | gameData: any; 17 | 18 | @Column('int') 19 | score: number; 20 | 21 | @Column('int') 22 | timeSpent: number; 23 | 24 | @Column('json', { nullable: true }) 25 | achievements: any[]; 26 | 27 | @CreateDateColumn() 28 | @Index() 29 | createdAt: Date; 30 | } -------------------------------------------------------------------------------- /backend/src/song-genre/entities/genre-challenge.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, CreateDateColumn } from 'typeorm'; 2 | import { Genre } from './genre.entity'; 3 | 4 | @Entity() 5 | export class GenreChallenge { 6 | @PrimaryGeneratedColumn('uuid') 7 | id: string; 8 | 9 | @Column() 10 | title: string; 11 | 12 | @ManyToOne(() => Genre) 13 | genre: Genre; 14 | 15 | @Column('text') 16 | description: string; 17 | 18 | @Column('json') 19 | requirements: Record; 20 | 21 | @Column('int') 22 | experienceReward: number; 23 | 24 | @Column() 25 | expiresAt: Date; 26 | 27 | @CreateDateColumn() 28 | createdAt: Date; 29 | } 30 | -------------------------------------------------------------------------------- /backend/src/analytics/constants/analytics.constants.ts: -------------------------------------------------------------------------------- 1 | export const ANALYTICS_CACHE_TTL = 300 // 5 minutes 2 | 3 | export const METRIC_TYPES = { 4 | PLAYER_ENGAGEMENT: "player_engagement", 5 | SONG_CATEGORY: "song_category", 6 | TOKEN_ECONOMY: "token_economy", 7 | USER_PROGRESSION: "user_progression", 8 | } as const 9 | 10 | export const AGGREGATION_PERIODS = { 11 | HOURLY: "hourly", 12 | DAILY: "daily", 13 | WEEKLY: "weekly", 14 | MONTHLY: "monthly", 15 | } as const 16 | 17 | export const DEFAULT_DATE_RANGE = { 18 | startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000), // 30 days ago 19 | endDate: new Date(), 20 | } 21 | 22 | export const ANALYTICS_QUEUE = "analytics_queue" 23 | 24 | -------------------------------------------------------------------------------- /backend/src/progression/entities/player-level.entity.ts: -------------------------------------------------------------------------------- 1 | // src/progression/entities/player-level.entity.ts 2 | import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, CreateDateColumn } from 'typeorm'; 3 | import { PlayerStats } from './player-stats.entity'; 4 | 5 | @Entity() 6 | export class PlayerLevel { 7 | @PrimaryGeneratedColumn('uuid') 8 | id: string; 9 | 10 | @ManyToOne(() => PlayerStats, stats => stats.levelHistory) 11 | playerStats: PlayerStats; 12 | 13 | @Column({ type: 'int' }) 14 | level: number; 15 | 16 | @Column({ type: 'int' }) 17 | xpGained: number; 18 | 19 | @Column({ type: 'int' }) 20 | totalXp: number; 21 | 22 | @CreateDateColumn() 23 | achievedAt: Date; 24 | } -------------------------------------------------------------------------------- /backend/src/scoring/scoring.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ScoringController } from './scoring.controller'; 3 | import { ScoringService } from './scoring.service'; 4 | 5 | describe('ScoringController', () => { 6 | let controller: ScoringController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [ScoringController], 11 | providers: [ScoringService], 12 | }).compile(); 13 | 14 | controller = module.get(ScoringController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /backend/src/game-insights/game-insights.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TypeOrmModule } from '@nestjs/typeorm'; 3 | import { GameInsightsService } from './provider/game-insights/game-insights.service'; 4 | import { GameInsightsController } from './game-insights.controller'; 5 | import { GameSession } from './GameSession.entity'; 6 | import { UserBehavior } from './UserBehavior'; 7 | import { PlayerPerformance } from './PlayerPerformance'; 8 | 9 | @Module({ 10 | imports: [TypeOrmModule.forFeature([GameSession, PlayerPerformance, UserBehavior])], 11 | controllers: [GameInsightsController], 12 | providers: [GameInsightsService], 13 | }) 14 | export class GameInsightsModule {} 15 | -------------------------------------------------------------------------------- /backend/src/music-education/artists/providers/artist.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { InjectRepository } from '@nestjs/typeorm'; 3 | import { Repository } from 'typeorm'; 4 | import { Artist } from '../entities/artist.entity'; 5 | 6 | @Injectable() 7 | export class ArtistService { 8 | constructor( 9 | @InjectRepository(Artist) 10 | private readonly artistRepo: Repository, 11 | ) {} 12 | 13 | findAll() { 14 | return this.artistRepo.find(); 15 | } 16 | 17 | findOne(id: number) { 18 | return this.artistRepo.findOne({ where: { id } }); 19 | } 20 | 21 | create(artist: Partial) { 22 | return this.artistRepo.save(artist); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /backend/src/game-results/game-results.module.ts: -------------------------------------------------------------------------------- 1 | 2 | import { Module } from '@nestjs/common'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { EventEmitterModule } from '@nestjs/event-emitter'; 5 | import { GameResultsController } from './game-results.controller'; 6 | import { GameResultsService } from './game-results.service'; 7 | import { GameResult } from './entities/game-result.entity'; 8 | 9 | @Module({ 10 | imports: [ 11 | TypeOrmModule.forFeature([GameResult]), 12 | EventEmitterModule.forRoot(), 13 | ], 14 | controllers: [GameResultsController], 15 | providers: [GameResultsService], 16 | exports: [GameResultsService], 17 | }) 18 | export class GameResultsModule {} 19 | -------------------------------------------------------------------------------- /backend/src/music-education/artists/artist.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Post, Body, Param } from '@nestjs/common'; 2 | import { ArtistService } from './providers/artist.service'; 3 | import { Artist } from './entities/artist.entity'; 4 | 5 | @Controller('artists') 6 | export class ArtistController { 7 | constructor(private readonly artistService: ArtistService) {} 8 | 9 | @Get() 10 | findAll() { 11 | return this.artistService.findAll(); 12 | } 13 | 14 | @Get(':id') 15 | findOne(@Param('id') id: number) { 16 | return this.artistService.findOne(id); 17 | } 18 | 19 | @Post() 20 | create(@Body() artist: Partial) { 21 | return this.artistService.create(artist); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /backend/src/sync/dto/sync-response.dto.ts: -------------------------------------------------------------------------------- 1 | // src/sync/dto/sync-response.dto.ts 2 | import { IsBoolean, IsNotEmpty, IsNumber, IsObject, IsOptional, IsString, IsDate } from 'class-validator'; 3 | 4 | export class SyncResponseDto { 5 | @IsBoolean() 6 | success: boolean; 7 | 8 | @IsNumber() 9 | version: number; 10 | 11 | @IsObject() 12 | @IsOptional() 13 | data?: T; 14 | 15 | @IsBoolean() 16 | hasConflicts: boolean; 17 | 18 | @IsObject() 19 | @IsOptional() 20 | conflictDetails?: any; 21 | 22 | @IsDate() 23 | syncedAt: Date; 24 | 25 | @IsString() 26 | @IsOptional() 27 | strategyUsed?: string; 28 | 29 | @IsObject() 30 | @IsOptional() 31 | delta?: Partial; 32 | } 33 | -------------------------------------------------------------------------------- /backend/src/game-mode/game-mode.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { GameModeController } from './game-mode.controller'; 3 | import { GameModeService } from './game-mode.service'; 4 | 5 | describe('GameModeController', () => { 6 | let controller: GameModeController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [GameModeController], 11 | providers: [GameModeService], 12 | }).compile(); 13 | 14 | controller = module.get(GameModeController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /backend/src/song-genre/entities/genre.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, OneToMany, CreateDateColumn, UpdateDateColumn } from 'typeorm'; 2 | import { Song } from './song.entity'; 3 | 4 | @Entity() 5 | export class Genre { 6 | @PrimaryGeneratedColumn('uuid') 7 | id: string; 8 | 9 | @Column({ unique: true }) 10 | name: string; 11 | 12 | @Column('text') 13 | description: string; 14 | 15 | @Column() 16 | icon: string; 17 | 18 | @Column('float', { default: 1.0 }) 19 | difficultyMultiplier: number; 20 | 21 | @OneToMany(() => Song, song => song.genre) 22 | songs: Song[]; 23 | 24 | @CreateDateColumn() 25 | createdAt: Date; 26 | 27 | @UpdateDateColumn() 28 | updatedAt: Date; 29 | } -------------------------------------------------------------------------------- /backend/src/questions/questions.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { QuestionsController } from './questions.controller'; 3 | import { QuestionsService } from './questions.service'; 4 | 5 | describe('QuestionsController', () => { 6 | let controller: QuestionsController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [QuestionsController], 11 | providers: [QuestionsService], 12 | }).compile(); 13 | 14 | controller = module.get(QuestionsController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /backend/src/app.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | describe('AppController', () => { 6 | let appController: AppController; 7 | 8 | beforeEach(async () => { 9 | const app: TestingModule = await Test.createTestingModule({ 10 | controllers: [AppController], 11 | providers: [AppService], 12 | }).compile(); 13 | 14 | appController = app.get(AppController); 15 | }); 16 | 17 | describe('root', () => { 18 | it('should return "Hello World!"', () => { 19 | expect(appController.getHello()).toBe('Hello World!'); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /backend/src/questions/exceptions/question.exception.ts: -------------------------------------------------------------------------------- 1 | import { BadRequestException,NotFoundException } from "@nestjs/common"; 2 | // src/questions/exceptions/question.exceptions.ts 3 | export class DuplicateLyricException extends BadRequestException { 4 | constructor() { 5 | super('Lyric snippet already exists in the database'); 6 | } 7 | } 8 | 9 | export class InvalidOptionsException extends BadRequestException { 10 | constructor() { 11 | super('Invalid options provided for the question'); 12 | } 13 | } 14 | 15 | export class QuestionNotFoundException extends NotFoundException { 16 | constructor(id: string) { 17 | super(`Question with ID ${id} not found`) 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./src/*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /backend/src/achievement/entities/user-achievement.entity.ts: -------------------------------------------------------------------------------- 1 | // src/achievement/entities/user-achievement.entity.ts 2 | import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, CreateDateColumn } from 'typeorm'; 3 | import { Achievement } from './achievement.entity'; 4 | import { User } from '../../user/entities/user.entity'; 5 | 6 | @Entity() 7 | export class UserAchievement { 8 | @PrimaryGeneratedColumn('uuid') 9 | id: string; 10 | 11 | @ManyToOne(() => User) 12 | user: User; 13 | 14 | @ManyToOne(() => Achievement) 15 | achievement: Achievement; 16 | 17 | @Column('float') 18 | progress: number; 19 | 20 | @Column({ default: false }) 21 | isCompleted: boolean; 22 | 23 | @CreateDateColumn() 24 | unlockedAt: Date; 25 | } -------------------------------------------------------------------------------- /backend/src/song-genre/controllers/song.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { SongGenreController } from './song.controller'; 3 | import { SongGenreService } from '../services/song.service'; 4 | 5 | describe('SongGenreController', () => { 6 | let controller: SongGenreController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [SongGenreController], 11 | providers: [SongGenreService], 12 | }).compile(); 13 | 14 | controller = module.get(SongGenreController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /backend/src/power-ups/power-up-validation.middleware.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, type NestMiddleware } from '@nestjs/common'; 2 | import { Request, Response, NextFunction } from 'express'; 3 | import { PowerUpService } from './power-up.service'; 4 | 5 | @Injectable() 6 | export class PowerUpValidationMiddleware implements NestMiddleware { 7 | constructor(private readonly powerUpService: PowerUpService) {} 8 | 9 | async use(req: Request, res: Response, next: NextFunction) { 10 | const user = req['user']; 11 | const activePowerUps = await this.powerUpService.getActivePowerUps(user); 12 | 13 | // Add active power-ups to the request object for use in controllers 14 | req['activePowerUps'] = activePowerUps; 15 | 16 | next(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /backend/test/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { INestApplication } from '@nestjs/common'; 3 | import * as request from 'supertest'; 4 | import { AppModule } from './../src/app.module'; 5 | 6 | describe('AppController (e2e)', () => { 7 | let app: INestApplication; 8 | 9 | beforeEach(async () => { 10 | const moduleFixture: TestingModule = await Test.createTestingModule({ 11 | imports: [AppModule], 12 | }).compile(); 13 | 14 | app = moduleFixture.createNestApplication(); 15 | await app.init(); 16 | }); 17 | 18 | it('/ (GET)', () => { 19 | return request(app.getHttpServer()) 20 | .get('/') 21 | .expect(200) 22 | .expect('Hello World!'); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /frontend/public/dropdown.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /backend/src/power-ups/power-up.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TypeOrmModule } from '@nestjs/typeorm'; 3 | import { PowerUpService } from './power-up.service'; 4 | import { PowerUpController } from './power-up.controller'; 5 | import { PowerUp } from './entities/power-up.entity'; 6 | import { PowerUpPurchase } from './entities/power-up-purchase.entity'; 7 | import { PowerUpValidationMiddleware } from './power-up-validation.middleware'; 8 | 9 | @Module({ 10 | imports: [TypeOrmModule.forFeature([PowerUp, PowerUpPurchase])], 11 | providers: [PowerUpService, PowerUpValidationMiddleware], 12 | controllers: [PowerUpController], 13 | exports: [PowerUpService, PowerUpValidationMiddleware], 14 | }) 15 | export class PowerUpModule {} 16 | -------------------------------------------------------------------------------- /backend/src/scoring/scoring.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TypeOrmModule } from '@nestjs/typeorm'; 3 | import { EventEmitterModule } from '@nestjs/event-emitter'; 4 | import { ScoringService } from './scoring.service'; 5 | import { ScoringController } from './scoring.controller'; 6 | import { Scoring } from './entities/scoring.entity'; 7 | import { Player } from 'src/player/player.entity'; 8 | 9 | @Module({ 10 | imports: [ 11 | TypeOrmModule.forFeature([Player, Scoring]), // Include Scoring entity 12 | EventEmitterModule.forRoot(), 13 | ], 14 | controllers: [ScoringController], // Add ScoringController 15 | providers: [ScoringService], 16 | exports: [ScoringService], 17 | }) 18 | export class ScoringModule {} 19 | -------------------------------------------------------------------------------- /backend/src/analytics/entities/player-engagement.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, Index } from "typeorm" 2 | 3 | @Entity("player_engagement_metrics") 4 | export class PlayerEngagementMetric { 5 | @PrimaryGeneratedColumn("uuid") 6 | id: string 7 | 8 | @Column() 9 | @Index() 10 | userId: string 11 | 12 | @Column() 13 | sessionCount: number 14 | 15 | @Column("float") 16 | sessionDuration: number 17 | 18 | @Column("json") 19 | activityData: Record 20 | 21 | @CreateDateColumn() 22 | @Index() 23 | timestamp: Date 24 | 25 | @UpdateDateColumn() 26 | updatedAt: Date 27 | 28 | @Column("json", { nullable: true }) 29 | metadata: Record 30 | } 31 | 32 | -------------------------------------------------------------------------------- /backend/src/db-migration/interfaces/validator.interface.ts: -------------------------------------------------------------------------------- 1 | // src/db-migration/interfaces/validator.interface.ts 2 | export interface DataValidator { 3 | /** 4 | * Name of the validator 5 | */ 6 | name: string; 7 | 8 | /** 9 | * Validates data against a schema or set of rules 10 | */ 11 | validate(data: any, schema: any): Promise; 12 | } 13 | 14 | export interface ValidationResult { 15 | /** 16 | * Whether validation passed 17 | */ 18 | valid: boolean; 19 | 20 | /** 21 | * Error messages if validation failed 22 | */ 23 | errors?: string[]; 24 | 25 | /** 26 | * Warnings that don't cause validation to fail 27 | */ 28 | warnings?: string[]; 29 | } -------------------------------------------------------------------------------- /backend/src/room-movement/entities/room.entity.ts: -------------------------------------------------------------------------------- 1 | 2 | import { Entity, Column, PrimaryGeneratedColumn, OneToMany, CreateDateColumn, UpdateDateColumn } from 'typeorm'; 3 | import { PlayerRoom } from './player-room.entity'; 4 | 5 | @Entity('rooms') 6 | export class Room { 7 | @PrimaryGeneratedColumn('uuid') 8 | id: string; 9 | 10 | @Column() 11 | name: string; 12 | 13 | @Column() 14 | description: string; 15 | 16 | @Column({ default: 10 }) 17 | capacity: number; 18 | 19 | @Column({ default: true }) 20 | isActive: boolean; 21 | 22 | @OneToMany(() => PlayerRoom, playerRoom => playerRoom.room) 23 | playerRooms: PlayerRoom[]; 24 | 25 | @CreateDateColumn() 26 | createdAt: Date; 27 | 28 | @UpdateDateColumn() 29 | updatedAt: Date; 30 | } 31 | -------------------------------------------------------------------------------- /backend/src/music-education/user-progress/user-progress.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Post, Patch, Param, Body } from '@nestjs/common'; 2 | import { UserProgressService } from './providers/user-progress.service'; 3 | 4 | @Controller('user-progress') 5 | export class UserProgressController { 6 | constructor(private readonly userProgressService: UserProgressService) {} 7 | 8 | @Get() 9 | findAll() { 10 | return this.userProgressService.findAll(); 11 | } 12 | 13 | @Get('user/:userId') 14 | findByUser(@Param('userId') user: string) { 15 | return this.userProgressService.findByUser(user); 16 | } 17 | 18 | @Patch(':id') 19 | markComplete(@Param('id') id: number) { 20 | return this.userProgressService.markComplete(id); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /backend/src/song-genre/entities/user-genre-preference.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, CreateDateColumn, UpdateDateColumn } from 'typeorm'; 2 | import { Genre } from './genre.entity'; 3 | 4 | @Entity() 5 | export class UserGenrePreference { 6 | @PrimaryGeneratedColumn('uuid') 7 | id: string; 8 | 9 | @Column() 10 | userId: string; 11 | 12 | @ManyToOne(() => Genre) 13 | genre: Genre; 14 | 15 | @Column('float', { default: 0 }) 16 | preferenceScore: number; 17 | 18 | @Column('int', { default: 0 }) 19 | playCount: number; 20 | 21 | @Column('float', { default: 0 }) 22 | averagePerformance: number; 23 | 24 | @CreateDateColumn() 25 | createdAt: Date; 26 | 27 | @UpdateDateColumn() 28 | updatedAt: Date; 29 | } -------------------------------------------------------------------------------- /backend/src/music-education/genre-history/providers/genre-history.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { InjectRepository } from '@nestjs/typeorm'; 3 | import { Repository } from 'typeorm'; 4 | import { GenreHistory } from '../entities/genre-history.entity'; 5 | 6 | @Injectable() 7 | export class GenreHistoryService { 8 | constructor( 9 | @InjectRepository(GenreHistory) 10 | private readonly genreRepo: Repository, 11 | ) {} 12 | 13 | findAll() { 14 | return this.genreRepo.find(); 15 | } 16 | 17 | findOne(id: number) { 18 | return this.genreRepo.findOne({ where: { id } }); 19 | } 20 | 21 | create(genreHistory: Partial) { 22 | return this.genreRepo.save(genreHistory); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /backend/src/game-results/game-results.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { GameResultsController } from './game-results.controller'; 3 | import { GameResultsService } from './game-results.service'; 4 | 5 | describe('GameResultsController', () => { 6 | let controller: GameResultsController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [GameResultsController], 11 | providers: [GameResultsService], 12 | }).compile(); 13 | 14 | controller = module.get(GameResultsController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /backend/src/music-education/music-lessons/providers/music-theory-lesson.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { InjectRepository } from '@nestjs/typeorm'; 3 | import { Repository } from 'typeorm'; 4 | import { MusicLesson } from '../entities/music-theory-lesson.entity'; 5 | 6 | @Injectable() 7 | export class MusicLessonsService { 8 | constructor( 9 | @InjectRepository(MusicLesson) 10 | private readonly lessonRepo: Repository, 11 | ) {} 12 | //hey 13 | findAll() { 14 | return this.lessonRepo.find(); 15 | } 16 | 17 | findOne(id: number) { 18 | return this.lessonRepo.findOne({ where: { id } }); 19 | } 20 | 21 | create(lesson: Partial) { 22 | return this.lessonRepo.save(lesson); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /frontend/src/hooks/useGameService.ts: -------------------------------------------------------------------------------- 1 | import { BigNumberish } from 'starknet'; 2 | import { useDojo } from '@/lib/dojo/hooks/useDojo'; 3 | import { useModalStore } from '@/store/modal-store'; 4 | import { useGameStore } from '@/store/game'; 5 | 6 | export const useGameService = () => { 7 | const { systemCalls } = useDojo(); 8 | const { closeModal } = useModalStore(); 9 | const { setRoundId } = useGameStore(); 10 | 11 | const createRound = async (genre: BigNumberish) => { 12 | if (!systemCalls) { 13 | throw new Error('System not initialized'); 14 | } 15 | 16 | const roundId = await systemCalls.createRound(genre); 17 | setRoundId(roundId); 18 | closeModal(); 19 | return roundId; 20 | }; 21 | 22 | return { 23 | createRound 24 | }; 25 | }; -------------------------------------------------------------------------------- /frontend/src/store/GameStores.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | import { create } from 'zustand'; 4 | import { immer } from 'zustand/middleware/immer'; 5 | import { devtools, persist } from 'zustand/middleware'; 6 | import { createGameSlice } from './slices/GameSlicess'; 7 | import { createUserSlice } from './slices/UserSlices'; 8 | import { Store } from './Types'; 9 | 10 | export const useStore = create()( 11 | devtools( 12 | persist( 13 | immer((...a) => ({ 14 | ...createGameSlice(...a), 15 | ...createUserSlice(...a), 16 | })), 17 | { 18 | name: 'game-store', 19 | partialize: (state) => ({ 20 | user: { 21 | preferences: state.user.preferences, 22 | }, 23 | }), 24 | }, 25 | ), 26 | ), 27 | ); -------------------------------------------------------------------------------- /backend/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | project: 'tsconfig.json', 5 | tsconfigRootDir: __dirname, 6 | sourceType: 'module', 7 | }, 8 | plugins: ['@typescript-eslint/eslint-plugin'], 9 | extends: [ 10 | 'plugin:@typescript-eslint/recommended', 11 | 'plugin:prettier/recommended', 12 | ], 13 | root: true, 14 | env: { 15 | node: true, 16 | jest: true, 17 | }, 18 | ignorePatterns: ['.eslintrc.js'], 19 | rules: { 20 | '@typescript-eslint/interface-name-prefix': 'off', 21 | '@typescript-eslint/explicit-function-return-type': 'off', 22 | '@typescript-eslint/explicit-module-boundary-types': 'off', 23 | '@typescript-eslint/no-explicit-any': 'off', 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /backend/src/state-recovery/state-recovery.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { StateRecoveryController } from './state-recovery.controller'; 3 | import { StateRecoveryService } from './state-recovery.service'; 4 | 5 | describe('StateRecoveryController', () => { 6 | let controller: StateRecoveryController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [StateRecoveryController], 11 | providers: [StateRecoveryService], 12 | }).compile(); 13 | 14 | controller = module.get(StateRecoveryController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /backend/src/analytics/entities/token.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, Index } from "typeorm" 2 | 3 | @Entity("token_metrics") 4 | export class TokenMetric { 5 | @PrimaryGeneratedColumn("uuid") 6 | id: string 7 | 8 | @Column("float") 9 | totalSupply: number 10 | 11 | @Column("float") 12 | circulation: number 13 | 14 | @Column() 15 | transactions: number 16 | 17 | @Column("float") 18 | averageHolding: number 19 | 20 | @Column("json") 21 | distributionData: Record 22 | 23 | @CreateDateColumn() 24 | @Index() 25 | timestamp: Date 26 | 27 | @UpdateDateColumn() 28 | updatedAt: Date 29 | 30 | @Column("json", { nullable: true }) 31 | metadata: Record 32 | } 33 | 34 | -------------------------------------------------------------------------------- /backend/src/redis/redis.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { Redis } from 'ioredis'; 3 | 4 | @Injectable() 5 | export class RedisService { 6 | private client: Redis; 7 | 8 | constructor() { 9 | this.client = new Redis({ 10 | host: '127.0.0.1', 11 | port: 6379, 12 | }); 13 | } 14 | 15 | async get(key: string): Promise { 16 | return this.client.get(key); 17 | } 18 | 19 | async set(key: string, value: string, ttl?: number): Promise { 20 | if (ttl) { 21 | await this.client.set(key, value, 'EX', ttl); 22 | } else { 23 | await this.client.set(key, value); 24 | } 25 | } 26 | 27 | async del(key: string): Promise { 28 | await this.client.del(key); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /frontend/src/__tests__/alias.test.ts: -------------------------------------------------------------------------------- 1 | // src/__tests__/alias.test.ts 2 | import { render } from '@testing-library/react'; 3 | import GameComponent from "@/components/GameComponent"; 4 | import React from 'react'; 5 | 6 | // Mock the Dojo hooks 7 | jest.mock('@/lib/dojo/hooks/useDojo', () => ({ 8 | useDojo: () => ({ 9 | account: null, 10 | systemCalls: {}, 11 | execute: jest.fn(), 12 | world: {}, 13 | }) 14 | })); 15 | 16 | describe('GameComponent', () => { 17 | test("GameComponent should be imported correctly", () => { 18 | expect(GameComponent).toBeDefined(); 19 | }); 20 | 21 | test("GameComponent should render without crashing", () => { 22 | const { container } = render(React.createElement(GameComponent)); 23 | expect(container).toBeTruthy(); 24 | }); 25 | }); -------------------------------------------------------------------------------- /backend/src/difficulty/difficulty.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from "@nestjs/common"; 2 | import { InjectRepository } from "@nestjs/typeorm"; 3 | import { Difficulty } from "./entities/difficulty.entity"; 4 | import { Repository } from "typeorm"; 5 | 6 | @Injectable() 7 | export class DifficultyService { 8 | constructor( 9 | @InjectRepository(Difficulty) 10 | private readonly difficultyRepository: Repository, 11 | ){} 12 | 13 | async findAll(): Promise { 14 | return this.difficultyRepository.find() 15 | } 16 | 17 | async findByName(id: string): Promise { 18 | const difficulties = this.difficultyRepository.findOne({ 19 | where: { id } 20 | }) 21 | 22 | return difficulties 23 | } 24 | } -------------------------------------------------------------------------------- /frontend/src/app/admin/page.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import { AdminConfig } from "@/components/organisms/AdminConfig"; 4 | import { useDojo } from "@/lib/dojo/hooks/useDojo"; 5 | import { useRouter } from "next/navigation"; 6 | import { useEffect } from "react"; 7 | 8 | export default function AdminPage() { 9 | const { account } = useDojo(); 10 | const router = useRouter(); 11 | 12 | useEffect(() => { 13 | // Redirect if no account or not admin 14 | if (!account) { 15 | router.push('/'); 16 | } 17 | }, [account, router]); 18 | 19 | if (!account) { 20 | return null; 21 | } 22 | 23 | return ( 24 |
25 |

Admin Dashboard

26 | 27 |
28 | ); 29 | } -------------------------------------------------------------------------------- /backend/src/achievement/achievement.module.ts: -------------------------------------------------------------------------------- 1 | // src/achievement/achievement.module.ts 2 | import { Module } from '@nestjs/common'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { AchievementController } from './achievement.controller'; 5 | import { AchievementService } from './achievement.service'; 6 | import { AchievementGateway } from './achievement.gateway'; 7 | import { Achievement } from './entities/achievement.entity'; 8 | import { UserAchievement } from './entities/user-achievement.entity'; 9 | 10 | @Module({ 11 | imports: [ 12 | TypeOrmModule.forFeature([Achievement, UserAchievement]), 13 | ], 14 | controllers: [AchievementController], 15 | providers: [AchievementService, AchievementGateway], 16 | exports: [AchievementService], 17 | }) 18 | export class AchievementModule {} -------------------------------------------------------------------------------- /backend/src/chat-room/chat-room.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { CreateChatRoomDto } from './dto/create-chat-room.dto'; 3 | import { UpdateChatRoomDto } from './dto/update-chat-room.dto'; 4 | 5 | @Injectable() 6 | export class ChatRoomService { 7 | create(createChatRoomDto: CreateChatRoomDto) { 8 | return 'This action adds a new chatRoom'; 9 | } 10 | 11 | findAll() { 12 | return `This action returns all chatRoom`; 13 | } 14 | 15 | findOne(id: number) { 16 | return `This action returns a #${id} chatRoom`; 17 | } 18 | 19 | update(id: number, updateChatRoomDto: UpdateChatRoomDto) { 20 | return `This action updates a #${id} chatRoom`; 21 | } 22 | 23 | remove(id: number) { 24 | return `This action removes a #${id} chatRoom`; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /backend/src/music-education/music-lessons/music.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Post, Body, Param } from '@nestjs/common'; 2 | import { MusicLesson } from './entities/music-theory-lesson.entity'; 3 | import { MusicLessonsService } from './providers/music-theory-lesson.service'; 4 | 5 | @Controller('music-lessons') 6 | export class MusicLessonsController { 7 | constructor(private readonly musicLessonsService: MusicLessonsService) {} 8 | 9 | @Get() 10 | findAll() { 11 | return this.musicLessonsService.findAll(); 12 | } 13 | 14 | @Get(':id') 15 | findOne(@Param('id') id: number) { 16 | return this.musicLessonsService.findOne(id); 17 | } 18 | 19 | @Post() 20 | create(@Body() lesson: Partial) { 21 | return this.musicLessonsService.create(lesson); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /backend/src/analytics/entities/user-progression.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, Index } from "typeorm" 2 | 3 | @Entity("user_progression_metrics") 4 | export class UserProgressionMetric { 5 | @PrimaryGeneratedColumn("uuid") 6 | id: string 7 | 8 | @Column() 9 | @Index() 10 | userId: string 11 | 12 | @Column() 13 | level: number 14 | 15 | @Column("float") 16 | experience: number 17 | 18 | @Column("simple-array") 19 | achievements: string[] 20 | 21 | @Column("json") 22 | progressionData: Record 23 | 24 | @CreateDateColumn() 25 | @Index() 26 | timestamp: Date 27 | 28 | @UpdateDateColumn() 29 | updatedAt: Date 30 | 31 | @Column("json", { nullable: true }) 32 | metadata: Record 33 | } 34 | 35 | -------------------------------------------------------------------------------- /backend/src/music-education/genre-history/genre-history.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Post, Body, Param } from '@nestjs/common'; 2 | import { GenreHistory } from './entities/genre-history.entity'; 3 | import { GenreHistoryService } from './providers/genre-history.service'; 4 | 5 | @Controller('genre-history') 6 | export class GenreHistoryController { 7 | constructor(private readonly genreHistoryService: GenreHistoryService) {} 8 | 9 | @Get() 10 | findAll() { 11 | return this.genreHistoryService.findAll(); 12 | } 13 | 14 | @Get(':id') 15 | findOne(@Param('id') id: number) { 16 | return this.genreHistoryService.findOne(id); 17 | } 18 | 19 | @Post() 20 | create(@Body() genreHistory: Partial) { 21 | return this.genreHistoryService.create(genreHistory); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /backend/src/music-education/user-progress/providers/user-progress.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { InjectRepository } from '@nestjs/typeorm'; 3 | import { Repository } from 'typeorm'; 4 | import { UserProgress } from '../entities/user-progress.entity'; 5 | 6 | @Injectable() 7 | export class UserProgressService { 8 | constructor( 9 | @InjectRepository(UserProgress) 10 | private readonly progressRepo: Repository, 11 | ) {} 12 | 13 | findAll() { 14 | return this.progressRepo.find(); 15 | } 16 | 17 | findByUser(userId: string) { 18 | return this.progressRepo.find({ where: { user: { id: userId } } }); 19 | } 20 | 21 | markComplete(progressId: number) { 22 | return this.progressRepo.update(progressId, { completed: true }); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /backend/src/replay-analysis/entities/pattern.entity.ts: -------------------------------------------------------------------------------- 1 | // src/replay-analysis/entities/pattern.entity.ts 2 | @Entity('patterns') 3 | export class Pattern { 4 | @PrimaryGeneratedColumn('uuid') 5 | id: string; 6 | 7 | @Column() 8 | replayId: string; 9 | 10 | @ManyToOne(() => Replay, replay => replay.patterns) 11 | replay: Replay; 12 | 13 | @Column() 14 | playerId: string; 15 | 16 | @Column() 17 | type: string; 18 | 19 | @Column() 20 | name: string; 21 | 22 | @Column() 23 | description: string; 24 | 25 | @Column() 26 | confidence: string; 27 | 28 | @Column('jsonb') 29 | data: any; 30 | 31 | @Column('float', { nullable: true }) 32 | frequency?: number; 33 | 34 | @Column({ default: false }) 35 | isCommon: boolean; 36 | 37 | @CreateDateColumn() 38 | createdAt: Date; 39 | } -------------------------------------------------------------------------------- /backend/src/tournament/tournament.entity.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Entity, 3 | PrimaryGeneratedColumn, 4 | Column, 5 | ManyToMany, 6 | OneToMany, 7 | } from 'typeorm'; 8 | import { User } from '../user/user.entity'; 9 | import { GameSession } from '../game-session/game-session.entity'; 10 | 11 | @Entity() 12 | export class Tournament { 13 | @PrimaryGeneratedColumn('uuid') 14 | id: string; 15 | 16 | @Column() 17 | name: string; 18 | 19 | @Column('timestamp') 20 | startTime: Date; 21 | 22 | @Column('timestamp') 23 | endTime: Date; 24 | 25 | @Column('json', { nullable: true }) 26 | rules: Record; 27 | 28 | @ManyToMany(() => User, { eager: true }) 29 | participants: User[]; 30 | 31 | @OneToMany(() => GameSession, (gameSession) => gameSession) 32 | matches: GameSession[]; 33 | } 34 | -------------------------------------------------------------------------------- /backend/src/http-yac/app.http: -------------------------------------------------------------------------------- 1 | # APP API 2 | 3 | @baseUrl = http://localhost:3000 4 | 5 | # App Endpoints 6 | 7 | ### unnamed0 8 | GET {{baseUrl}}/ 9 | 10 | # Template CRUD Operations 11 | # These are common operations that might not be implemented in your controller yet 12 | 13 | ### findAll (Template) 14 | GET {{baseUrl}}/ 15 | 16 | ### findOne (Template) 17 | GET {{baseUrl}}//:id 18 | 19 | ### create (Template) 20 | POST {{baseUrl}}/ 21 | Content-Type: application/json 22 | 23 | { 24 | "name": "app name", 25 | "description": "app description" 26 | } 27 | 28 | ### update (Template) 29 | PATCH {{baseUrl}}//:id 30 | Content-Type: application/json 31 | 32 | { 33 | "name": "updated app name", 34 | "description": "updated app description" 35 | } 36 | 37 | ### remove (Template) 38 | DELETE {{baseUrl}}//:id 39 | 40 | -------------------------------------------------------------------------------- /backend/src/music-education/music-education.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { MusicTheoryLessonController } from './music-theory-lesson.controller'; 3 | import { MusicTheoryLessonService } from './music-theory-lesson.service'; 4 | 5 | describe('MusicTheoryLessonController', () => { 6 | let controller: MusicTheoryLessonController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [MusicTheoryLessonController], 11 | providers: [MusicTheoryLessonService], 12 | }).compile(); 13 | 14 | controller = module.get(MusicTheoryLessonController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /backend/src/replay-analysis/replay-analysis.module.ts: -------------------------------------------------------------------------------- 1 | // src/replay-analysis/replay-analysis.module.ts 2 | import { Module } from '@nestjs/common'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { ConfigModule } from '@nestjs/config'; 5 | 6 | @Module({ 7 | imports: [ 8 | ConfigModule, 9 | TypeOrmModule.forFeature([ 10 | Replay, 11 | Pattern, 12 | Anomaly, 13 | Report, 14 | ]), 15 | ], 16 | controllers: [ 17 | ReplayAnalysisController, 18 | ], 19 | providers: [ 20 | ReplayAnalysisService, 21 | ReplayStorageService, 22 | PatternRecognitionService, 23 | AnomalyDetectionService, 24 | ReportingService, 25 | VisualizationService, 26 | ], 27 | exports: [ 28 | ReplayAnalysisService, 29 | ], 30 | }) 31 | export class ReplayAnalysisModule {} -------------------------------------------------------------------------------- /backend/src/voice/entities/room.entity.ts: -------------------------------------------------------------------------------- 1 | // src/voice/entities/room.entity.ts 2 | import { Room } from '../interfaces/room.interface'; 3 | import { Participant } from '../interfaces/participant.interface'; 4 | import { v4 as uuidv4 } from 'uuid'; 5 | 6 | export class RoomEntity implements Room { 7 | id: string; 8 | name: string; 9 | participants: Map; 10 | maxParticipants: number; 11 | createdAt: Date; 12 | 13 | constructor(name: string, maxParticipants: number = 10) { 14 | this.id = uuidv4(); 15 | this.name = name; 16 | this.participants = new Map(); 17 | this.maxParticipants = maxParticipants; 18 | this.createdAt = new Date(); 19 | } 20 | 21 | addParticipant(participant: Participant): boolean { 22 | if (this.participants.size >= this.maxParticipant){}} -------------------------------------------------------------------------------- /backend/src/config/config.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ConfigModule as NestConfigModule } from '@nestjs/config'; 3 | import configuration from './configuration'; 4 | import { validationSchema } from './validation.schema'; 5 | import { ConfigService } from './providers/config.service'; 6 | import { TestConfigController } from './test.controller'; 7 | 8 | @Module({ 9 | imports: [ 10 | NestConfigModule.forRoot({ 11 | envFilePath: `.env.${process.env.NODE_ENV}`, 12 | load: [configuration], 13 | validationSchema, 14 | validationOptions: { 15 | abortEarly: false, 16 | }, 17 | isGlobal: true, 18 | }), 19 | ], 20 | providers: [ConfigService], 21 | exports: [ConfigService], 22 | controllers: [TestConfigController] 23 | }) 24 | export class ConfigModule {} -------------------------------------------------------------------------------- /backend/src/config/providers/game.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { GameService } from './game.service'; 3 | 4 | describe('GameService', () => { 5 | let service: GameService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [GameService], 10 | }).compile(); 11 | 12 | service = module.get(GameService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | 19 | // Add more tests for specific methods in GameService 20 | // Example: 21 | // it('should initialize game state correctly', () => { 22 | // const initialState = service.initializeGame(); 23 | // expect(initialState).toEqual(expectedState); 24 | // }); 25 | }); -------------------------------------------------------------------------------- /backend/src/http-yac/profile.http: -------------------------------------------------------------------------------- 1 | # PROFILE API 2 | 3 | @baseUrl = http://localhost:3000 4 | 5 | # Profile Endpoints 6 | 7 | # Template CRUD Operations 8 | # These are common operations that might not be implemented in your controller yet 9 | 10 | ### findAll (Template) 11 | GET {{baseUrl}}/profile 12 | 13 | ### findOne (Template) 14 | GET {{baseUrl}}/profile/:id 15 | 16 | ### create (Template) 17 | POST {{baseUrl}}/profile 18 | Content-Type: application/json 19 | 20 | { 21 | "name": "profile name", 22 | "description": "profile description" 23 | } 24 | 25 | ### update (Template) 26 | PATCH {{baseUrl}}/profile/:id 27 | Content-Type: application/json 28 | 29 | { 30 | "name": "updated profile name", 31 | "description": "updated profile description" 32 | } 33 | 34 | ### remove (Template) 35 | DELETE {{baseUrl}}/profile/:id 36 | 37 | -------------------------------------------------------------------------------- /backend/src/analytics/dto/aggregated-analytics.dto.ts: -------------------------------------------------------------------------------- 1 | import { ApiProperty } from "@nestjs/swagger" 2 | import { IsDate, IsObject } from "class-validator" 3 | 4 | export class AggregatedAnalyticsDto { 5 | @ApiProperty() 6 | @IsDate() 7 | timestamp: Date 8 | 9 | @ApiProperty() 10 | @IsObject() 11 | playerEngagement: Record 12 | 13 | @ApiProperty() 14 | @IsObject() 15 | songCategories: Record 16 | 17 | @ApiProperty() 18 | @IsObject() 19 | tokenEconomy: Record 20 | 21 | @ApiProperty() 22 | @IsObject() 23 | userProgression: Record 24 | 25 | @ApiProperty() 26 | @IsObject() 27 | summary: { 28 | totalActiveUsers: number 29 | topCategory: string 30 | tokenCirculation: number 31 | averageUserLevel: number 32 | timestamp: Date 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /backend/src/db-migration/entities/backup-metadata.entity.ts: -------------------------------------------------------------------------------- 1 | // src/db-migration/entities/backup-metadata.entity.ts 2 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, Index } from 'typeorm'; 3 | 4 | @Entity('backup_metadata') 5 | export class BackupMetadata { 6 | @PrimaryGeneratedColumn('uuid') 7 | id: string; 8 | 9 | @Column() 10 | @Index() 11 | backupId: string; 12 | 13 | @Column() 14 | filename: string; 15 | 16 | @Column() 17 | location: string; 18 | 19 | @Column('bigint') 20 | size: number; 21 | 22 | @Column({ nullable: true }) 23 | @Index() 24 | migrationId?: string; 25 | 26 | @Column({ default: true }) 27 | available: boolean; 28 | 29 | @Column('json', { nullable: true }) 30 | metadata?: any; 31 | 32 | @CreateDateColumn() 33 | @Index() 34 | createdAt: Date; 35 | } -------------------------------------------------------------------------------- /backend/src/http-yac/activity.http: -------------------------------------------------------------------------------- 1 | # ACTIVITY API 2 | 3 | @baseUrl = http://localhost:3000 4 | 5 | # Activity Endpoints 6 | 7 | # Template CRUD Operations 8 | # These are common operations that might not be implemented in your controller yet 9 | 10 | ### findAll (Template) 11 | GET {{baseUrl}}/activity 12 | 13 | ### findOne (Template) 14 | GET {{baseUrl}}/activity/:id 15 | 16 | ### create (Template) 17 | POST {{baseUrl}}/activity 18 | Content-Type: application/json 19 | 20 | { 21 | "name": "activity name", 22 | "description": "activity description" 23 | } 24 | 25 | ### update (Template) 26 | PATCH {{baseUrl}}/activity/:id 27 | Content-Type: application/json 28 | 29 | { 30 | "name": "updated activity name", 31 | "description": "updated activity description" 32 | } 33 | 34 | ### remove (Template) 35 | DELETE {{baseUrl}}/activity/:id 36 | 37 | -------------------------------------------------------------------------------- /backend/src/analytics/entities/song-category.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, Index } from "typeorm" 2 | 3 | @Entity("song_category_metrics") 4 | export class SongCategoryMetric { 5 | @PrimaryGeneratedColumn("uuid") 6 | id: string 7 | 8 | @Column() 9 | @Index() 10 | categoryId: string 11 | 12 | @Column() 13 | categoryName: string 14 | 15 | @Column() 16 | playCount: number 17 | 18 | @Column() 19 | uniqueUsers: number 20 | 21 | @Column("float") 22 | averagePlayTime: number 23 | 24 | @Column("json") 25 | popularityTrend: Record 26 | 27 | @CreateDateColumn() 28 | @Index() 29 | timestamp: Date 30 | 31 | @UpdateDateColumn() 32 | updatedAt: Date 33 | 34 | @Column("json", { nullable: true }) 35 | metadata: Record 36 | } 37 | 38 | -------------------------------------------------------------------------------- /backend/src/analytics/guards/analytics-roles.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, type CanActivate, type ExecutionContext } from "@nestjs/common" 2 | import type { Reflector } from "@nestjs/core" 3 | import type { AnalyticsRole } from "../enums/analytics-role.enum" 4 | 5 | @Injectable() 6 | export class AnalyticsRolesGuard implements CanActivate { 7 | constructor(private reflector: Reflector) {} 8 | 9 | canActivate(context: ExecutionContext): boolean { 10 | const requiredRoles = this.reflector.get("roles", context.getHandler()) 11 | if (!requiredRoles) { 12 | return true 13 | } 14 | 15 | const request = context.switchToHttp().getRequest() 16 | // Implement your role checking logic here 17 | const userRole = request.headers["x-analytics-role"] 18 | return requiredRoles.includes(userRole) 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /backend/src/coupons/controllers/coupon.controller.ts: -------------------------------------------------------------------------------- 1 | // src/coupons/controllers/coupon.controller.ts 2 | import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Query } from '@nestjs/common'; 3 | import { CouponService } from '../services/coupon.service'; 4 | import { CreateCouponDto } from '../dto/create-coupon.dto'; 5 | import { UpdateCouponDto } from '../dto/update-coupon.dto'; 6 | import { GenerateBulkCouponsDto } from '../dto/generate-bulk-coupons.dto'; 7 | import { AdminGuard } from '../../auth/guards/admin.guard'; 8 | import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; 9 | 10 | @ApiTags('coupons') 11 | @ApiBearerAuth() 12 | @Controller('admin/coupons') 13 | @UseGuards(AdminGuard) 14 | export class CouponAdminController { 15 | constructor(private readonly couponService: CouponService) {} 16 | 17 | @Post() 18 | create(@Body() createC -------------------------------------------------------------------------------- /frontend/jest.config.js: -------------------------------------------------------------------------------- 1 | const nextJest = require('next/jest') 2 | 3 | const createJestConfig = nextJest({ 4 | dir: './', 5 | }) 6 | 7 | const customJestConfig = { 8 | setupFilesAfterEnv: ['/jest.setup.ts'], 9 | testEnvironment: 'jsdom', 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1', 12 | '^@dojoengine/create-burner$': '/src/__mocks__/types.ts', 13 | '^@dojoengine/core$': '/src/__mocks__/dojoCore.ts' 14 | }, 15 | transformIgnorePatterns: [ 16 | '/node_modules/(?!@dojoengine)' 17 | ], 18 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], 19 | testPathIgnorePatterns: ['/node_modules/', '/.next/'], 20 | transform: { 21 | '^.+\\.(ts|tsx)$': ['ts-jest', { 22 | tsconfig: '/tsconfig.json' 23 | }] 24 | } 25 | } 26 | 27 | module.exports = createJestConfig(customJestConfig) -------------------------------------------------------------------------------- /backend/src/http-yac/challenge.http: -------------------------------------------------------------------------------- 1 | # CHALLENGE API 2 | 3 | @baseUrl = http://localhost:3000 4 | 5 | # Challenge Endpoints 6 | 7 | # Template CRUD Operations 8 | # These are common operations that might not be implemented in your controller yet 9 | 10 | ### findAll (Template) 11 | GET {{baseUrl}}/challenge 12 | 13 | ### findOne (Template) 14 | GET {{baseUrl}}/challenge/:id 15 | 16 | ### create (Template) 17 | POST {{baseUrl}}/challenge 18 | Content-Type: application/json 19 | 20 | { 21 | "name": "challenge name", 22 | "description": "challenge description" 23 | } 24 | 25 | ### update (Template) 26 | PATCH {{baseUrl}}/challenge/:id 27 | Content-Type: application/json 28 | 29 | { 30 | "name": "updated challenge name", 31 | "description": "updated challenge description" 32 | } 33 | 34 | ### remove (Template) 35 | DELETE {{baseUrl}}/challenge/:id 36 | 37 | -------------------------------------------------------------------------------- /backend/src/progression/gateways/progression.gateway.ts: -------------------------------------------------------------------------------- 1 | // src/progression/gateways/progression.gateway.ts 2 | import { WebSocketGateway, WebSocketServer } from '@nestjs/websockets'; 3 | import { Server } from 'socket.io'; 4 | import { OnEvent } from '@nestjs/event-emitter'; 5 | 6 | @WebSocketGateway() 7 | export class ProgressionGateway { 8 | @WebSocketServer() 9 | server: Server; 10 | 11 | @OnEvent('progression.xp.added') 12 | handleXpAdded(payload: any) { 13 | this.server.to(payload.userId).emit('xpGained', payload); 14 | } 15 | 16 | @OnEvent('progression.level.up') 17 | handleLevelUp(payload: any) { 18 | this.server.to(payload.userId).emit('levelUp', payload); 19 | } 20 | 21 | @OnEvent('progression.rank.changed') 22 | handleRankChange(payload: any) { 23 | this.server.to(payload.userId).emit('rankChanged', payload); 24 |   } 25 | } -------------------------------------------------------------------------------- /backend/src/modules/share/dto/create-share.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString, IsEnum, IsOptional } from 'class-validator'; 2 | import { ShareType } from '../enums/share-type.enum'; 3 | import { PlatformType } from '../enums/platform-type.enum'; 4 | 5 | export class CreateShareDto { 6 | @IsNotEmpty() 7 | @IsString() 8 | userId: string; 9 | 10 | @IsNotEmpty() 11 | @IsEnum(ShareType) 12 | type: ShareType; 13 | 14 | @IsNotEmpty() 15 | @IsString() 16 | contentId: string; 17 | 18 | @IsNotEmpty() 19 | @IsString() 20 | contentType: string; 21 | 22 | @IsOptional() 23 | @IsString() 24 | title?: string; 25 | 26 | @IsOptional() 27 | @IsString() 28 | description?: string; 29 | 30 | @IsOptional() 31 | @IsString() 32 | thumbnailUrl?: string; 33 | 34 | @IsOptional() 35 | @IsEnum(PlatformType) 36 | platform?: PlatformType; 37 | } 38 | -------------------------------------------------------------------------------- /backend/src/progression/controllers/progression.controller.ts: -------------------------------------------------------------------------------- 1 | // src/progression/controllers/progression.controller.ts 2 | import { Controller, Post, Body, Get, Param, UseGuards } from '@nestjs/common'; 3 | import { ProgressionService } from '../services/progression.service'; 4 | import { XpEventDto } from '../dtos/xp-event.dto'; 5 | import { JwtAuthGuard } from '../../auth/guards/jwt-auth.guard'; 6 | 7 | @Controller('progression') 8 | @UseGuards(JwtAuthGuard) 9 | export class ProgressionController { 10 | constructor(private readonly progressionService: ProgressionService) {} 11 | 12 | @Post('xp') 13 | addXp(@Body() xpEvent: XpEventDto) { 14 | return this.progressionService.addXp(xpEvent); 15 | } 16 | 17 | @Get(':userId') 18 | getPlayerStats(@Param('userId') userId: string) { 19 | return this.progressionService.getOrCreatePlayerStats(userId); 20 |   } 21 | } -------------------------------------------------------------------------------- /backend/src/sync/sync.module.ts: -------------------------------------------------------------------------------- 1 | // src/sync/sync.module.ts 2 | import { Module } from '@nestjs/common'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { SyncController } from './sync.controller'; 5 | import { SyncService } from './sync.service'; 6 | import { SyncRecord } from './entities/sync-record.entity'; 7 | import { SyncHistory } from './entities/sync-history.entity'; 8 | import { LastWriteWinsStrategy } from './strategies/last-write-wins.strategy'; 9 | import { ThreeWayMergeStrategy } from './strategies/three-way-merge.strategy'; 10 | 11 | @Module({ 12 | imports: [ 13 | TypeOrmModule.forFeature([SyncRecord, SyncHistory]), 14 | ], 15 | controllers: [SyncController], 16 | providers: [ 17 | SyncService, 18 | LastWriteWinsStrategy, 19 | ThreeWayMergeStrategy, 20 | ], 21 | exports: [SyncService], 22 | }) 23 | export class SyncModule {} -------------------------------------------------------------------------------- /backend/src/practice/controllers/user-progress.controller.ts: -------------------------------------------------------------------------------- 1 | // src/practice/controllers/user-progress.controller.ts 2 | import { Controller, Get, Param, Query, UseGuards, Request } from '@nestjs/common'; 3 | import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; 4 | import { JwtAuthGuard } from '../../auth/guards/jwt-auth.guard'; 5 | import { UserProgressService } from '../services/user-progress.service'; 6 | import { Genre } from '../enums/genre.enum'; 7 | 8 | @ApiTags('practice-progress') 9 | @ApiBearerAuth() 10 | @Controller('practice/progress') 11 | @UseGuards(JwtAuthGuard) 12 | export class UserProgressController { 13 | constructor(private readonly progressService: UserProgressService) {} 14 | 15 | @Get() 16 | getUserProgress(@Request() req, @Query('genre') genre?: Genre) { 17 | return this.progressService.getUserProgress(req.user.id, genre); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /backend/src/state-recovery/state-recovery.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { CreateStateRecoveryDto } from './dto/create-state-recovery.dto'; 3 | import { UpdateStateRecoveryDto } from './dto/update-state-recovery.dto'; 4 | 5 | @Injectable() 6 | export class StateRecoveryService { 7 | create(createStateRecoveryDto: CreateStateRecoveryDto) { 8 | return 'This action adds a new stateRecovery'; 9 | } 10 | 11 | findAll() { 12 | return `This action returns all stateRecovery`; 13 | } 14 | 15 | findOne(id: number) { 16 | return `This action returns a #${id} stateRecovery`; 17 | } 18 | 19 | update(id: number, updateStateRecoveryDto: UpdateStateRecoveryDto) { 20 | return `This action updates a #${id} stateRecovery`; 21 | } 22 | 23 | remove(id: number) { 24 | return `This action removes a #${id} stateRecovery`; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /backend/src/store/controllers/store.controller.ts: -------------------------------------------------------------------------------- 1 | // src/store/controllers/store.controller.ts 2 | @Controller('store') 3 | @UseGuards(AuthGuard) 4 | export class StoreController { 5 | constructor(private readonly storeService: StoreService) {} 6 | 7 | @Get('items') 8 | async getItems(@Query() filter: any) { 9 | return this.storeService.getItems(filter); 10 | } 11 | 12 | @Post('purchase') 13 | async purchaseItem( 14 | @User() user: User, 15 | @Body() purchaseDto: PurchaseDto 16 | ) { 17 | return this.storeService.purchaseItem(user.id, purchaseDto); 18 | } 19 | 20 | @Get('inventory') 21 | async getInventory(@User() user: User) { 22 | return this.storeService.getInventory(user.id); 23 | } 24 | 25 | @Get('transactions') 26 | async getTransactions(@User() user: User) { 27 | return this.storeService.getTransactionHistory(user.id); 28 | } 29 | } -------------------------------------------------------------------------------- /backend/src/game-session/dto/game-session.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsOptional, 3 | IsString, 4 | IsInt, 5 | IsEnum, 6 | IsISO8601, 7 | IsNumber, 8 | IsNotEmpty, 9 | } from 'class-validator'; 10 | import { Type } from 'class-transformer'; 11 | import { GameStatus } from '../enums/game-status.enum'; 12 | 13 | export class GameSessionDto { 14 | @IsString() 15 | @IsNotEmpty() 16 | playerId: string; 17 | 18 | @IsISO8601() 19 | @IsNotEmpty() 20 | @Type(() => Date) 21 | startTime: Date; 22 | 23 | @IsOptional() 24 | @IsISO8601() 25 | @Type(() => Date) 26 | endTime?: Date; 27 | 28 | @IsEnum(GameStatus) 29 | @IsNotEmpty() 30 | status: GameStatus; 31 | 32 | @IsInt() 33 | @IsNotEmpty() 34 | maxPlayers: number; 35 | 36 | @IsOptional() 37 | @IsNumber() 38 | score?: number; 39 | 40 | @IsOptional() 41 | @IsString() 42 | description?: string; 43 | } 44 | -------------------------------------------------------------------------------- /backend/src/social/entities/profile.entity.ts: -------------------------------------------------------------------------------- 1 | // entities/profile.entity.ts 2 | import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm'; 3 | import { Friend } from './friend.entity'; 4 | import { Activity } from './activity.entity'; 5 | 6 | @Entity() 7 | export class Profile { 8 | @PrimaryGeneratedColumn('uuid') 9 | id: string; 10 | 11 | @Column() 12 | username: string; 13 | 14 | @Column() 15 | displayName: string; 16 | 17 | @Column() 18 | avatar: string; 19 | 20 | @Column('text') 21 | bio: string; 22 | 23 | @Column('json') 24 | stats: UserStats; 25 | 26 | @Column('json') 27 | achievements: Achievement[]; 28 | 29 | @Column() 30 | lastActive: Date; 31 | 32 | @OneToMany(() => Friend, friend => friend.profile) 33 | friends: Friend[]; 34 | 35 | @OneToMany(() => Activity, activity => activity.profile) 36 | activities: Activity[]; 37 | } -------------------------------------------------------------------------------- /backend/src/tournament/scheduling.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { GameSession } from 'src/game-session/game-session.entity'; 3 | import { Player } from '../player/player.entity'; 4 | 5 | @Injectable() 6 | export class SchedulingService { 7 | schedule(tournament: any): GameSession[] { 8 | const participants: Player[] = tournament.participants; 9 | const matches: GameSession[] = []; 10 | 11 | for (let i = 0; i < participants.length; i++) { 12 | for (let j = i + 1; j < participants.length; j++) { 13 | const match = new GameSession(); 14 | match.players = [participants[i], participants[j]]; 15 | match.startTime = this.getMatchTime(); 16 | matches.push(match); 17 | } 18 | } 19 | 20 | return matches; 21 | } 22 | 23 | private getMatchTime(): Date { 24 | return new Date(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /backend/src/http-yac/notification.http: -------------------------------------------------------------------------------- 1 | # NOTIFICATION API 2 | 3 | @baseUrl = http://localhost:3000 4 | 5 | # Notification Endpoints 6 | 7 | # Template CRUD Operations 8 | # These are common operations that might not be implemented in your controller yet 9 | 10 | ### findAll (Template) 11 | GET {{baseUrl}}/notification 12 | 13 | ### findOne (Template) 14 | GET {{baseUrl}}/notification/:id 15 | 16 | ### create (Template) 17 | POST {{baseUrl}}/notification 18 | Content-Type: application/json 19 | 20 | { 21 | "name": "notification name", 22 | "description": "notification description" 23 | } 24 | 25 | ### update (Template) 26 | PATCH {{baseUrl}}/notification/:id 27 | Content-Type: application/json 28 | 29 | { 30 | "name": "updated notification name", 31 | "description": "updated notification description" 32 | } 33 | 34 | ### remove (Template) 35 | DELETE {{baseUrl}}/notification/:id 36 | 37 | -------------------------------------------------------------------------------- /backend/src/http-yac/test.http: -------------------------------------------------------------------------------- 1 | # TEST API 2 | 3 | @baseUrl = http://localhost:3000 4 | 5 | # Test Endpoints 6 | 7 | ### unnamed0 8 | GET {{baseUrl}}/config-test 9 | 10 | # Template CRUD Operations 11 | # These are common operations that might not be implemented in your controller yet 12 | 13 | ### findAll (Template) 14 | GET {{baseUrl}}/config-test 15 | 16 | ### findOne (Template) 17 | GET {{baseUrl}}/config-test/:id 18 | 19 | ### create (Template) 20 | POST {{baseUrl}}/config-test 21 | Content-Type: application/json 22 | 23 | { 24 | "name": "test name", 25 | "description": "test description" 26 | } 27 | 28 | ### update (Template) 29 | PATCH {{baseUrl}}/config-test/:id 30 | Content-Type: application/json 31 | 32 | { 33 | "name": "updated test name", 34 | "description": "updated test description" 35 | } 36 | 37 | ### remove (Template) 38 | DELETE {{baseUrl}}/config-test/:id 39 | 40 | --------------------------------------------------------------------------------