# otniel113/jankenpon-deploy architecture

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

- Interactive diagram: https://gitdiagram.com/otniel113/jankenpon-deploy
- Repository: https://github.com/otniel113/jankenpon-deploy

## Overview

##### Project type and purpose
- This is a Python-based web application (Flask) that serves a pre‐trained CNN model (best_model.h5) to classify user‐uploaded images as rock, paper, or scissors.
- It’s deployed on Heroku (Procfile present), with a lightweight frontend (HTML + uploads) and a backend inference service.

##### File structure
- app.py: Flask application entry point, routes, and inference logic
- best_model.h5: Serialized Keras CNN model used at runtime
- requirements.txt: Python dependencies (Flask, TensorFlow/Keras, etc.)
- Procfile: Declares Gunicorn command for Heroku deployment
- templates/index.html: Jinja2 template for the upload form and result display
- static/uploads: Directory for temporarily storing user uploads

##### Key insights from the README
- Deployed URL: https://jankenpon-deploy.herokuapp.com/
- Inference relies on a CNN trained elsewhere (Jankenpon-CV3 repo).
- Known limitations: less accurate on real-world data, tends toward “paper” predictions.

##### Main components and their relationships
a. Client (Web Browser)
- Presents HTML form (index.html) to user
- Uploads image via HTTP POST
b. Load Balancer / Heroku Router (optional layer)
- Receives incoming requests, forwards to web dyno
c. Web Dyno (Gunicorn + Flask)
- Gunicorn workers launch app.py
- Routes: “/” serves index.html, “/predict” handles uploads
- On upload: saves file to static/uploads, invokes Keras model
d. ML Inference Component
- In-memory loading of best_model.h5 at startup or per request
- Processes image, returns prediction label
e. Storage
- Ephemeral Heroku filesystem for static/uploads
- No persistent database in this project
f. Response Flow
- Flask renders a results page or JSON payload
- Client displays prediction

##### Architectural patterns and technologies
- Two-Tier (Client + Server + ML library)
- MVC-style separation: Templates (View), app.py (Controller), model file (Model)
- RESTful endpoint for predictions
- Heroku deployment using Gunicorn (Procfile)
- TensorFlow/Keras for CNN inference

##### Detailed elements
- Labels: “User Browser,” “Heroku Router,” “Gunicorn,” “Flask app.py,” “CNN model (best_model.h5),” “static/uploads folder”
- Data flows: file upload path, inference call, HTTP response path
- Notes on config: Procfile declares “web: gunicorn app:app”
- External links: Keras, Flask, Heroku

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        Browser["User Browser"]:::user
    end

    %% Platform Layer
    subgraph "Platform Layer"
        Router["Heroku Router"]:::platform
        Storage["Ephemeral Storage\n(static/uploads)"]:::platform
    end

    %% Web Dyno Environment
    subgraph "Web Dyno Environment"
        Gunicorn["Gunicorn"]:::web
        App["Flask app.py"]:::web
        Procfile["Procfile"]:::platform
        ReqTxt["requirements.txt"]:::platform
        Template["templates/index.html"]:::user
    end

    %% ML Tier
    subgraph "ML Tier"
        ModelComponent["CNN Model Loader"]:::ml
        ModelFile["best_model.h5"]:::ml
    end

    %% External Documentation
    Docs["README.md"]:::platform

    %% Connections
    Browser -->|"HTTP POST /upload"| Router
    Router -->|"forwards request"| Gunicorn
    Gunicorn -->|"invokes route"| App
    App -->|"serves index.html"| Template
    App -->|"saves file"| Storage
    App -->|"loads model"| ModelComponent
    ModelComponent -->|"reads file"| ModelFile
    ModelComponent -->|"returns prediction"| App
    App -->|"HTTP Response"| Browser

    %% Config Links
    App --- Procfile
    App --- ReqTxt
    App --- Docs

    %% Click Events
    click App "https://github.com/otniel113/jankenpon-deploy/blob/master/app.py"
    click ModelFile "https://github.com/otniel113/jankenpon-deploy/blob/master/best_model.h5"
    click ReqTxt "https://github.com/otniel113/jankenpon-deploy/blob/master/requirements.txt"
    click Procfile "https://github.com/otniel113/jankenpon-deploy/tree/master/Procfile"
    click Template "https://github.com/otniel113/jankenpon-deploy/blob/master/templates/index.html"
    click Storage "https://github.com/otniel113/jankenpon-deploy/tree/master/static/uploads"
    click Docs "https://github.com/otniel113/jankenpon-deploy/blob/master/README.md"

    %% Styles
    classDef user fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef web fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ml fill:#FFA500,stroke:#000,stroke-width:1px
    classDef platform fill:#D3D3D3,stroke:#000,stroke-width:1px
```
