# ymj1123/team-14-take-6- architecture

> Architecture diagram of the GitHub repository ymj1123/team-14-take-6-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ymj1123/team-14-take-6-
- Repository: https://github.com/ymj1123/team-14-take-6-

## Overview

##### Project type and purpose
- This is a full-stack real-time multiplayer card game web application.
- Backend: a Django project (with Django REST and Django Channels) providing HTTP/REST APIs for user and room management, plus WebSocket endpoints for real-time gameplay, chat, and state synchronization.
- Persistence: SQLite (for development) via Django ORM; migrations live under backend/game/migrations and backend/users/migrations.

##### File structure
Top-level:
- backend/
- frontend/
- requirements.txt, package.json
Backend substructure:
- take6/ (Django settings, ASGI/WSGI, URL & routing setup)
- game/ (Django app: models, serializers, views, consumers, routing, game_room logic, admin, tests, templates)
- users/ (Django app: user models, views, URLs, CSRF overrides)
- game_logic/ (pure Python core game engine: card.py, core.py, unit tests)
- static/, templates/ (legacy or fallback HTML)
Frontend substructure:
- src/ (React components, pages, assets, API docs)
- public/ (static images & audio)
- styles/ (CSS modules for each component)
- main.jsx, App.jsx, vite.config.js

##### README for additional insights
- Frontend runs on port 5173 using `npm run dev`.
- Backend uses ASGI server Daphne on port 8000 to support HTTP + WebSocket.
- Development workflow: Django migrations, pip requirements, conditional CSRF handling, CORS_ALLOW_ORIGINS.
- Key flows: room creation via REST, WebSocket connections per client (consumers.py) and per–room broadcast logic (game_room.py).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        idx["index.html"]:::frontend
        main["main.jsx"]:::frontend
        appComp["App.jsx"]:::frontend
        comps["components/"]:::frontend
        pages["pages/"]:::frontend
        viteCfg["vite.config.js"]:::frontend
        pkgJSON["package.json"]:::frontend
    end

    %% Frontend Dev Server
    devServer["Vite Dev Server (5173)"]:::frontend

    %% Server Layer
    subgraph "Server Layer"
        direction TB
        daphne["Daphne ASGI Server (8000)"]:::backend
        asgiApp["take6.asgi:application"]:::backend

        subgraph "HTTP REST API Layer"
            direction TB
            urls["take6/urls.py"]:::backend
            gameViews["game/views.py"]:::backend
            gameSerial["game/serializers.py"]:::backend
            userViews["users/views.py"]:::backend
            userUrls["users/urls.py"]:::backend
        end

        subgraph "WebSocket Layer"
            direction TB
            wsRoute["take6/routing.py"]:::backend
            gameRoute["game/routing.py"]:::backend
            gameCons["game/consumers.py"]:::backend
        end
    end

    %% Django Apps
    subgraph "Game App" 
        direction TB
        gmInit["__init__.py"]:::backend
        gmModels["models.py"]:::backend
        gmAdmin["admin.py"]:::backend
        gmViews["views.py"]:::backend
        gmSerial["serializers.py"]:::backend
        gmCons["consumers.py"]:::backend
        gmRoom["game_room.py"]:::backend
        gmTests["tests.py"]:::backend
    end

    subgraph "Users App"
        direction TB
        usInit["__init__.py"]:::backend
        usModels["models.py"]:::backend
        usAdmin["admin.py"]:::backend
        usViews["views.py"]:::backend
        usUrls["urls.py"]:::backend
        usCsrf["csrf.py"]:::backend
        usTests["tests.py"]:::backend
    end

    subgraph "Core Game Logic"
        direction TB
        coreCard["card.py"]:::backend
        coreCore["core.py"]:::backend
        coreTests["tests.py"]:::backend
    end

    %% Data Layer
    db["SQLite Database"]:::data
    migrationsGame["game/migrations/"]:::data
    migrationsUsers["users/migrations/"]:::data

    %% Static & Templates
    subgraph "Static Assets (Production)"
        staticFile["static/empty.txt"]:::assets
    end

    subgraph "Templates"
        tplIndex["templates/index.html"]:::assets
        tplRoom["templates/game_room.html"]:::assets
    end

    %% Settings & Entry Points
    settings["settings.py"]:::backend
    wsgi["wsgi.py"]:::backend
    asgiEntry["asgi.py"]:::backend

    %% Connections
    idx --> devServer
    main --> devServer
    appComp --> devServer
    devServer --> idx
    devServer --> main
    devServer --> appComp

    idx -->|"loads SPA"| daphne
    appComp -->|"HTTP/REST"| daphne
    appComp -->|"WebSocket"| daphne

    daphne --> asgiApp
    asgiApp --> urls
    asgiApp --> wsRoute

    urls --> gameViews
    urls --> userViews

    gameViews --> gmModels
    gameViews --> gmSerial
    userViews --> usModels

    wsRoute --> gameRoute
    gameRoute --> gameCons
    gameCons --> gmRoom
    gmRoom --> coreCore
    coreCore --> coreCard

    gmModels --> db
    usModels --> db
    gmRoom --> db

    migrationsGame --> db
    migrationsUsers --> db

    staticFile --> daphne
    tplIndex --> daphne
    tplRoom --> daphne

    settings --> asgiApp
    asgiEntry --> asgiApp
    wsgi --> asgiApp

    %% Click Events
    click idx "https://github.com/ymj1123/team-14-take-6-/blob/main/frontend/index.html"
    click main "https://github.com/ymj1123/team-14-take-6-/blob/main/frontend/src/main.jsx"
    click appComp "https://github.com/ymj1123/team-14-take-6-/blob/main/frontend/src/App.jsx"
    click comps "https://github.com/ymj1123/team-14-take-6-/tree/main/frontend/src/components/"
    click pages "https://github.com/ymj1123/team-14-take-6-/tree/main/frontend/src/pages/"
    click viteCfg "https://github.com/ymj1123/team-14-take-6-/blob/main/frontend/vite.config.js"
    click pkgJSON "https://github.com/ymj1123/team-14-take-6-/blob/main/frontend/package.json"

    click urls "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/take6/urls.py"
    click gameViews "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/views.py"
    click gameSerial "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/serializers.py"
    click userViews "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/users/views.py"
    click userUrls "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/users/urls.py"

    click wsRoute "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/take6/routing.py"
    click gameRoute "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/routing.py"
    click gameCons "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/consumers.py"

    click asgiEntry "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/take6/asgi.py"

    click gmModels "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/models.py"
    click gmAdmin "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/admin.py"
    click gmViews "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/views.py"
    click gmSerial "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/serializers.py"
    click gmCons "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/consumers.py"
    click gmRoom "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/game_room.py"
    click gmTests "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/tests.py"
    click migrationsGame "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game/migrations/0001_initial.py"

    click usModels "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/users/models.py"
    click usAdmin "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/users/admin.py"
    click usViews "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/users/views.py"
    click usUrls "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/users/urls.py"
    click usCsrf "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/users/csrf.py"
    click usTests "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/users/tests.py"
    click migrationsUsers "https://github.com/ymj1123/team-14-take-6-/tree/main/backend/users/migrations/"

    click coreCard "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game_logic/card.py"
    click coreCore "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game_logic/core.py"
    click coreTests "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/game_logic/tests.py"

    click staticFile "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/static/empty.txt"
    click tplIndex "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/templates/index.html"
    click tplRoom "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/templates/game_room.html"

    click settings "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/take6/settings.py"
    click wsgi "https://github.com/ymj1123/team-14-take-6-/blob/main/backend/take6/wsgi.py"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef backend fill:#E6F4EA,stroke:#22863A,color:#22863A;
    classDef data fill:#FFF5B1,stroke:#D29922,color:#D29922;
    classDef assets fill:#F0EFF2,stroke:#8250DF,color:#8250DF;
```
