(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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------