# sagnikdatta2k6/rock-paper-scissors-ai-ollama architecture

> Architecture diagram of the GitHub repository sagnikdatta2k6/rock-paper-scissors-ai-ollama, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sagnikdatta2k6/rock-paper-scissors-ai-ollama
- Repository: https://github.com/sagnikdatta2k6/rock-paper-scissors-ai-ollama

## Overview

##### Project type and purpose
- This is a local Python-based “full-stack” toy application (more precisely, a self-contained frontend + backend + AI service) that lets a user play Rock-Paper-Scissors against an adaptive AI.
- The frontend is a Streamlit web app (rps_app.py) with an optional CLI client (main.py). The backend logic lives in game_logic.py. AI predictions come from a locally-hosted LLaMA 3 model served via Ollama.

##### File structure
- Top-level files:
– rps_app.py → Streamlit UI
– main.py → Command-line UI
– game_logic.py → Core game logic & AI integration
– requirements.txt, .gitignore, LICENSE, README.md
- No separate “backend” folder: the Python process hosts both UI and logic.
- External dependency: the Ollama daemon running the LLaMA 3 model (not in repo, but critical).

##### README for additional insights
- Confirms a purely local deployment: Streamlit + Python + Ollama + LLaMA 3.
- Describes how game_logic.py:
- Tracks move history in memory
- Builds a text prompt (“player has played rock X times…”)
- Sends it to the LLaMA 3 server via Ollama CLI (or API)
- Receives the AI’s chosen move, decides winner, updates scores.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interfaces"
        Browser["User (Browser)"]:::user
        Terminal["User (Terminal)"]:::user
    end

    subgraph "Python Runtime & Dependencies"
        Streamlit["Streamlit App\nrps_app.py"]:::ui
        CLI["CLI App\nmain.py"]:::ui
        Logic["Game Logic Module\ngame_logic.py"]:::logic
    end

    External["Ollama Server\nLLaMA 3"]:::external

    subgraph "Project Files"
        README["README.md"]:::docs
        LICENSE["LICENSE"]:::docs
        Gitignore[".gitignore"]:::docs
    end

    Browser -->|"HTTP Request"| Streamlit
    Terminal -->|"CLI Invocation"| CLI
    Streamlit -->|"Call Game Logic"| Logic
    CLI -->|"Call Game Logic"| Logic
    Logic -->|"AI Prompt via Ollama CLI/API"| External
    External -->|"AI Response"| Logic
    Logic -->|"Return Result"| Streamlit
    Logic -->|"Return Result"| CLI

    click Streamlit "https://github.com/sagnikdatta2k6/rock-paper-scissors-ai-ollama/blob/main/rps_app.py"
    click CLI "https://github.com/sagnikdatta2k6/rock-paper-scissors-ai-ollama/blob/main/main.py"
    click Logic "https://github.com/sagnikdatta2k6/rock-paper-scissors-ai-ollama/blob/main/game_logic.py"
    click README "https://github.com/sagnikdatta2k6/rock-paper-scissors-ai-ollama/blob/main/README.md"
    click LICENSE "https://github.com/sagnikdatta2k6/rock-paper-scissors-ai-ollama/tree/main/LICENSE"
    click Gitignore "https://github.com/sagnikdatta2k6/rock-paper-scissors-ai-ollama/blob/main/.gitignore"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef docs fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef user fill:#B0E0E6,stroke:#333,stroke-width:1px
```
