# msc24x/hunter architecture

> Architecture diagram of the GitHub repository msc24x/hunter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/msc24x/hunter
- Repository: https://github.com/msc24x/hunter

## Overview

##### Main System Components

a) Frontend Layer (Angular Application):
- Main modules: Common, Compete, and Editor
- Services: AuthService, CompetitionsDataService, ScoresDataService
- Code editor component as a central feature

b) Backend Layer (Node.js/TypeScript):
- API Routes (/api/*)
- Authentication system
- Database interaction layer
- Judge service integration

c) Database Layer:
- Prisma ORM
- Main entities: Users, Competitions, Questions, Results

d) Judge System (Showdown):
- Code execution engine
- Language detection
- Test case evaluation
- Compilation service

##### Component Relationships

- Frontend → Backend: REST API calls with authentication
- Backend → Database: Prisma ORM interactions
- Backend → Judge System: Code execution flow
- Judge System → Backend: Results reporting

##### Specific Design Elements

Use these visual elements:

##### Key Workflows to Highlight

a) Competition Creation Flow:
**Editor Module → API → Database**

b) Code Submission Flow:
**Code Editor → API → Judge System → Results → Scoreboard**

c) Authentication Flow:
**Login Component → Auth Service → GitHub OAuth → Database**

##### Detailed Component Breakdown

Frontend (Angular):
- Common Module
- Components (AppBar, CodeEditor, Scoreboard)
- Pages (Home, Compete, Profile)
- Compete Module
- Competition Components
- Code Submission Interface
- Editor Module
- Competition Management
- Question Editor

Backend (Node.js):
- API Routes
- Auth
- Competition
- Questions
- Results
- Services
- JudgeService
- ScoreboardService
- DatabaseProvider

##### Technical Stack Indicators

Technology badges for:
- Angular
- Node.js
- Prisma
- PostgreSQL
- Docker
- GitHub OAuth

Remember to emphasize the security aspects of the judge system and the isolation of code execution environments, as these are critical for a competition platform.

This system design should clearly communicate how Hunter handles everything from user authentication to code execution and result tracking in a secure and scalable manner.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        CommonModule["Common Module"]
        CompeteModule["Compete Module"]
        EditorModule["Editor Module"]
        
        subgraph Services
            AuthService["Auth Service"]
            CompDataService["Competitions Data Service"]
            ScoresService["Scores Data Service"]
        end
        
        subgraph Components
            CodeEditor["Code Editor Component"]
            AppBar["App Bar"]
            Scoreboard["Scoreboard"]
        end
    end
    
    subgraph Backend
        APIRoutes["API Routes"]
        AuthSystem["Auth System"]
        
        subgraph BackendServices
            JudgeService["Judge Service"]
            ScoreboardService["Scoreboard Service"]
            DBProvider["Database Provider"]
        end
    end
    
    subgraph Database
        PrismaORM["Prisma ORM"]
        
        subgraph Models
            Users["Users"]
            Competitions["Competitions"]
            Questions["Questions"]
            Results["Results"]
        end
    end
    
    subgraph JudgeSystem
        CodeExecution["Code Execution Engine"]
        LangDetection["Language Detection"]
        TestEval["Test Case Evaluation"]
        CompileService["Compilation Service"]
    end
    
    %% Frontend Relationships
    CommonModule --> Components
    CompeteModule --> CodeEditor
    EditorModule --> CompDataService
    Services --> APIRoutes
    
    %% Backend Relationships
    APIRoutes --> BackendServices
    AuthSystem --> DBProvider
    JudgeService --> CodeExecution
    ScoreboardService --> Results
    DBProvider --> PrismaORM
    
    %% Database Relationships
    PrismaORM --> Models
    
    %% Judge System Relationships
    CodeExecution --> TestEval
    LangDetection --> CompileService
    TestEval --> Results
    
    %% Click Events
    click CommonModule "https://github.com/msc24x/hunter/tree/main/src/app/common"
    click CompeteModule "https://github.com/msc24x/hunter/tree/main/src/app/compete"
    click EditorModule "https://github.com/msc24x/hunter/tree/main/src/app/editor"
    click AuthService "https://github.com/msc24x/hunter/blob/main/src/app/services/auth/auth.service.ts"
    click CompDataService "https://github.com/msc24x/hunter/blob/main/src/app/services/competitions-data/competitions-data.service.ts"
    click ScoresService "https://github.com/msc24x/hunter/blob/main/src/app/services/data/scores-data.service.ts"
    click CodeEditor "https://github.com/msc24x/hunter/tree/main/src/app/common/components/code-editor"
    click APIRoutes "https://github.com/msc24x/hunter/tree/main/backend/src/api/routes"
    click AuthSystem "https://github.com/msc24x/hunter/blob/main/backend/src/api/auth.ts"
    click DBProvider "https://github.com/msc24x/hunter/blob/main/backend/src/services/databaseProvider.ts"
    click JudgeService "https://github.com/msc24x/hunter/blob/main/backend/src/services/judgeService.ts"
    click ScoreboardService "https://github.com/msc24x/hunter/blob/main/backend/src/services/scoreboardService.ts"
    click PrismaORM "https://github.com/msc24x/hunter/blob/main/backend/prisma/schema.prisma"
    click Users "https://github.com/msc24x/hunter/blob/main/backend/src/database/models/User.ts"
    click Competitions "https://github.com/msc24x/hunter/blob/main/backend/src/database/models/Competitions.ts"
    click Questions "https://github.com/msc24x/hunter/blob/main/backend/src/database/models/Questions.ts"
    click Results "https://github.com/msc24x/hunter/blob/main/backend/src/database/models/Results.ts"
    
    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef judge fill:#e74c3c,stroke:#c0392b,color:white
    
    class CommonModule,CompeteModule,EditorModule,AuthService,CompDataService,ScoresService,CodeEditor,AppBar,Scoreboard frontend
    class APIRoutes,AuthSystem,JudgeService,ScoreboardService,DBProvider backend
    class PrismaORM,Users,Competitions,Questions,Results database
    class CodeExecution,LangDetection,TestEval,CompileService judge
```
