# nomoreft/private-isu architecture

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

- Interactive diagram: https://gitdiagram.com/nomoreft/private-isu
- Repository: https://github.com/nomoreft/private-isu

## Overview

##### Main System Components

a. Web Application Layer
- Multiple language implementations (Ruby, Go, PHP, Node.js)
- Uses Nginx as reverse proxy
- Implements a social media-like application with posts and user management
- Uses templates for view rendering

b. Database Layer
- MySQL for persistent storage
- Memcached for caching

c. Benchmarker Component
- Standalone Go application
- Contains user data for testing
- Implements scoring system
- Includes checker and scenario modules

d. Portal Component (Legacy)
- Ruby on Rails application
- Manages teams, users, and jobs
- Uses Sidekiq for background processing
- Includes scoring dashboard

**[Client Browsers]**
- ↓
**[Load Balancer/Nginx]**
- ↓
**[Web Application Layer]**
- Ruby App (default)
- Go App
- PHP-FPM App
- Node.js App
- ↓
**[Data Layer]**
- MySQL
- Memcached

**[Benchmarker Component] ←→ [Target Application]**
- Scenario Runner
- Score Calculator
- User Data Store

**[Portal Component]**
- Web Interface
- Sidekiq Workers
- Redis

##### Connection Types

- Double lines: Data replication/sync

##### Important Elements to Highlight

a. Infrastructure:
- Separation between competitor instances and benchmarker instances
- AWS deployment options
- Available deployment methods (Docker, Vagrant, bare metal)

b. Application Flow:
- Request handling path
- Data access patterns
- Caching strategy
- Benchmark execution flow

##### Additional Details

Annotations for:
- Port numbers (80, 3000, etc.)
- Language-specific components
- Configuration file locations
- Resource limits and constraints

##### Performance-Critical Paths

- Main request processing path
- Database query routes
- Cache access patterns
- Benchmark measurement points

##### Deployment Options

- AMI deployment
- Docker Compose setup
- Vagrant configuration
- Manual installation

This system design should help the principal software engineer understand both the overall architecture and the specific components that are likely to be performance bottlenecks during the ISUCON competition.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        Browser["Web Browsers"]:::client
    end

    subgraph Proxy["Proxy Layer"]
        Nginx["Nginx Reverse Proxy"]:::proxy
        click Nginx "https://github.com/nomoreFt/private-isu/blob/master/webapp/etc/nginx/conf.d/default.conf"
    end

    subgraph Apps["Web Application Layer"]
        Ruby["Ruby App"]:::app
        Go["Go App"]:::app
        PHP["PHP-FPM App"]:::app
        Node["Node.js App"]:::app
        
        click Ruby "https://github.com/nomoreFt/private-isu/blob/master/webapp/ruby/app.rb"
        click Go "https://github.com/nomoreFt/private-isu/blob/master/webapp/golang/app.go"
        click PHP "https://github.com/nomoreFt/private-isu/blob/master/webapp/php/index.php"
        click Node "https://github.com/nomoreFt/private-isu/blob/master/webapp/node/app.js"

        subgraph Views["View Templates"]
            RubyViews["Ruby Views"]:::view
            GoViews["Go Templates"]:::view
            PHPViews["PHP Views"]:::view
            NodeViews["Node.js Views"]:::view

            click RubyViews "https://github.com/nomoreFt/private-isu/tree/master/webapp/ruby/views/"
            click GoViews "https://github.com/nomoreFt/private-isu/tree/master/webapp/golang/templates/"
            click PHPViews "https://github.com/nomoreFt/private-isu/tree/master/webapp/php/views/"
            click NodeViews "https://github.com/nomoreFt/private-isu/tree/master/webapp/node/views/"
        end
    end

    subgraph Data["Data Layer"]
        MySQL[(MySQL)]:::database
        Memcached[(Memcached)]:::cache
        click MySQL "https://github.com/nomoreFt/private-isu/blob/master/benchmarker/sql/schema.sql"
    end

    subgraph Bench["Benchmarker Component"]
        BenchMain["Main Benchmarker"]:::bench
        Checker["Checker Module"]:::bench
        Scoring["Score Calculator"]:::bench
        UserData["User Data Store"]:::bench
        Scenario["Scenario Runner"]:::bench

        click BenchMain "https://github.com/nomoreFt/private-isu/blob/master/benchmarker/main.go"
        click Checker "https://github.com/nomoreFt/private-isu/tree/master/benchmarker/checker/"
        click Scoring "https://github.com/nomoreFt/private-isu/tree/master/benchmarker/score/"
        click UserData "https://github.com/nomoreFt/private-isu/tree/master/benchmarker/userdata/"
        click Scenario "https://github.com/nomoreFt/private-isu/blob/master/benchmarker/scenario.go"
    end

    subgraph Portal["Portal Component"]
        WebUI["Web Interface"]:::portal
        Sidekiq["Sidekiq Workers"]:::portal
        Redis[(Redis)]:::cache
        Controllers["Controllers"]:::portal
        Models["Models"]:::portal
        PortalViews["Views"]:::portal
        
        click Controllers "https://github.com/nomoreFt/private-isu/tree/master/portal/app/controllers/"
        click Models "https://github.com/nomoreFt/private-isu/tree/master/portal/app/models/"
        click PortalViews "https://github.com/nomoreFt/private-isu/tree/master/portal/app/views/"
        click Sidekiq "https://github.com/nomoreFt/private-isu/blob/master/portal/app/jobs/benchmarker_job.rb"
    end

    subgraph Deploy["Deployment"]
        Docker["Docker"]:::deploy
        Ansible["Ansible"]:::deploy
        Services["System Services"]:::deploy

        click Docker "https://github.com/nomoreFt/private-isu/blob/master/webapp/docker-compose.yml"
        click Ansible "https://github.com/nomoreFt/private-isu/tree/master/provisioning/image/ansible/"
        click Services "https://github.com/nomoreFt/private-isu/tree/master/provisioning/image/files/etc/systemd/system/"
    end

    Browser --> Nginx
    Nginx --> Ruby & Go & PHP & Node
    Ruby & Go & PHP & Node --> MySQL
    Ruby & Go & PHP & Node --> Memcached
    Ruby --> RubyViews
    Go --> GoViews
    PHP --> PHPViews
    Node --> NodeViews
    BenchMain --> Checker
    BenchMain --> Scoring
    BenchMain --> UserData
    BenchMain --> Scenario
    BenchMain -.-> Nginx
    WebUI --> Controllers
    Controllers --> Models
    Controllers --> PortalViews
    Sidekiq --> Redis

    classDef client fill:#4B96FF,stroke:#333,stroke-width:2px
    classDef proxy fill:#95D475,stroke:#333,stroke-width:2px
    classDef app fill:#68B587,stroke:#333,stroke-width:2px
    classDef view fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef database fill:#FFD700,stroke:#333,stroke-width:2px
    classDef cache fill:#FFA500,stroke:#333,stroke-width:2px
    classDef bench fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef portal fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef deploy fill:#A9A9A9,stroke:#333,stroke-width:2px
```
