# playframework/play1 architecture

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

- Interactive diagram: https://gitdiagram.com/playframework/play1
- Repository: https://github.com/playframework/play1

## Overview

##### Project type and purpose
- This repository is the Play Framework version 1 — an open-source, full-stack web application framework for Java (and Groovy), delivered as both a CLI tool (the “play” script) and a Java library.
- It provides an MVC web server, hot-reloading compiler, template engine, ORM and database modules, caching, job scheduling, plugin infrastructure, and extension modules (CRUD, console, documentation, testing, etc.).

##### File structure
- Top-level:
– .github: CI, issue/pr templates
– README.md: project overview
– play / play.bat / python/: the CLI launcher and Python “pym” toolset for command dispatch
– framework/: the Java core (build.xml, lib dependencies, src, patches, tests)
– modules/: first‐party extension modules (console, crud, docviewer, secure, testrunner, grizzly, etc.)
– documentation/: static site content, cheatsheets, manuals (HTML/Textile)
– samples-and-tests/: sample applications demonstrating features
– resources/: IDE and application skeleton templates
- framework/src/play/*: core Java packages:
– mvc: Controller, Router, Results
– server: HTTP server (Netty-based) pipeline, SSL, handler
– classloading & compilation: hot‐swap, bytecode enhancement
– templates: Groovy template compiler/loader
– db: JDBC, JPA/Hibernate integration, evolutions
– cache: EhCache, Memcached implementations
– jobs: scheduled tasks
– inject: DI container
– utils, i18n, libs: JSON, YAML, HTTP clients, email, OAuth, WebSockets
– exceptions, data binding, validation

##### README for additional insights
- Play is delivered as an unzippable runtime, exposes a “play” command for scaffolding, running, testing, packaging.
- Emphasizes RESTful, developer productivity, hot code reload, modularity via plugins and modules.

1. CLI layer
– “play” shell script / play.bat
– Python pym backend loading commands (framework/pym/play)
2. Core Java engine
– HTTP Server (framework/src/play/server)
– Request Router & ControllerInvoker (mvc)
– Classloader & Compiler (hot‐reload)
– Template engine (play/templates)
– DI & Plugin Manager (inject & plugins)
– Tasks & Job Scheduler (jobs)
– Data Binding & Validation (data/binding, data/validation)
– Logging, I18N, Utils
3. Data layer
– DB connectors & pools (c3p0, HikariCP)
– ORM: JPA/Hibernate integration, evolutions framework
4. Cache layer
– EhCache, Memcached adapters
5. Extension modules (modules/*)
– Console, CRUD, DocViewer, Secure, TestRunner, Grizzly adapter, etc.
6. Documentation & Samples
– Static docs (documentation/)
– Sample apps (samples-and-tests/)
7. External services
– Databases (MySQL, PostgreSQL, H2)
– Cache servers (Memcached)
– Mail servers (SMTP)
– Third-party REST/OAuth providers
- CLI → launches Java Engine
- Engine boot:
– loads application code & modules via Classloader
– initializes Plugin Manager & DI container
- HTTP Request → Server Pipeline → Router → Controller →
– may invoke Data layer (DAO/JPA) → persists/queries DB
– may invoke Cache layer
– may schedule or invoke Jobs
– may render Template → HTTP Response
- Template compiler hot-reloads on file change
- Plugins and Modules hook into lifecycle events (onStart, onStop)
c. Architectural patterns & principles:
– MVC pattern
– Plugin/Module extensibility (inversion of control)
– Hot-code reloading and bytecode enhancement
– Dependency injection via simple BeanSource/Injector
– Layered architecture: presentation, application, data, integration
– Event‐driven non-blocking IO (Netty)
d. Key technologies/frameworks:
– Java 8+, Groovy templates
– Netty HTTP server
– JPA/Hibernate, Evolutions
– c3p0, HikariCP
– EhCache, Memcached
– Python 3.x (CLI pym scripts)
– Ant/Ivy build and dependency management
– JSON (simplejson), YAML, Mail, OAuth, WebSocket client & server

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI & Tooling
    subgraph "CLI & Tooling"
        PLAY["play script"]:::cli
        PLAYBAT["play.bat"]:::cli
        PYM["Python CLI backend"]:::cli
    end

    %% Core Java Engine
    subgraph "Core Java Engine"
        LOG["Play.java & Logger"]:::core
        CLASSLOAD["Classloader & Compiler"]:::core
        SERVER["HTTP Server (Netty)"]:::core
        ROUTER["Router & Controller Invoker"]:::core
        TEMPLATE["Template Engine"]:::core
        INJECT["DI & Plugin Manager"]:::core
        JOBS["Jobs & Scheduler"]:::core
        BINDING["Data Binding & Validation"]:::core
        I18N["Internationalization"]:::core
        UTILS["Utilities"]:::core
    end

    %% Data Layer
    subgraph "Data Layer"
        DBAPI["DB API & Evolutions"]:::data
        C3P0["c3p0 Support"]:::data
        HIKARI["HikariCP Support"]:::data
        JPA["JPA/Hibernate"]:::data
    end

    %% Cache Layer
    subgraph "Cache Layer"
        CACHEAPI["Cache API & Implementations"]:::data
    end

    %% Extension Modules
    subgraph "Extension Modules"
        CONSOLE["Console (modules/console)"]:::modules
        CRUD["CRUD (modules/crud)"]:::modules
        DOCVIEW["DocViewer (modules/docviewer)"]:::modules
        SECURE["Secure (modules/secure)"]:::modules
        TESTRUN["TestRunner (modules/testrunner)"]:::modules
        GRIZZLY["Grizzly (modules/grizzly)"]:::modules
    end

    %% Docs & Samples
    subgraph "Documentation & Samples"
        DOCS["Documentation (documentation/)"]:::docs
        SAMPLES["Sample Apps (samples-and-tests/)"]:::docs
    end

    %% External Services
    subgraph "External Services"
        EXDB["Databases"]:::external
        EXCACHE["Cache Servers"]:::external
        MAIL["Mail Servers"]:::external
        OAUTH["3rd-party REST/OAuth"]:::external
    end

    %% Relationships
    PLAY -->|launches| LOG
    PLAYBAT -->|launches| LOG
    PYM -->|invokes| LOG

    LOG -->|boots| CLASSLOAD
    CLASSLOAD -->|loads| INJECT
    CLASSLOAD -->|initializes| SERVER

    SERVER -->|HTTP Request| ROUTER
    ROUTER -->|invokes| TEMPLATE
    ROUTER -->|invokes| DBAPI
    ROUTER -->|invokes| CACHEAPI
    ROUTER -->|invokes| JOBS
    ROUTER -->|uses| BINDING
    TEMPLATE -->|renders| SERVER

    CONSOLE -->|hooks into| INJECT
    CRUD -->|hooks into| INJECT
    DOCVIEW -->|hooks into| INJECT
    SECURE -->|hooks into| INJECT
    TESTRUN -->|hooks into| INJECT
    GRIZZLY -->|hooks into| INJECT

    DBAPI -->|persists/queries| EXDB
    CACHEAPI -->|stores/retrieves| EXCACHE
    UTILS -->|sends emails| MAIL
    UTILS -->|calls APIs| OAUTH

    SAMPLES -->|uses| LOG
    DOCS -.->|describes| LOG

    DBAPI --> C3P0
    DBAPI --> HIKARI
    DBAPI --> JPA

    %% Click Events
    click PLAY "https://github.com/playframework/play1/tree/master//play"
    click PLAYBAT "https://github.com/playframework/play1/blob/master//play.bat"
    click PYM "https://github.com/playframework/play1/blob/master/framework/pym/play/application.py"
    click SERVER "https://github.com/playframework/play1/tree/master/framework/src/play/server/"
    click ROUTER "https://github.com/playframework/play1/blob/master/framework/src/play/mvc/Router.java"
    click TEMPLATE "https://github.com/playframework/play1/tree/master/framework/src/play/templates/"
    click CLASSLOAD "https://github.com/playframework/play1/tree/master/framework/src/play/classloading/"
    click INJECT "https://github.com/playframework/play1/tree/master/framework/src/play/inject/"
    click CONSOLE "https://github.com/playframework/play1/tree/master/modules/console/"
    click CRUD "https://github.com/playframework/play1/tree/master/modules/crud/"
    click DOCVIEW "https://github.com/playframework/play1/tree/master/modules/docviewer/"
    click SECURE "https://github.com/playframework/play1/tree/master/modules/secure/"
    click TESTRUN "https://github.com/playframework/play1/tree/master/modules/testrunner/"
    click GRIZZLY "https://github.com/playframework/play1/tree/master/modules/grizzly/"

    %% Styles
    classDef cli fill:#dddddd,stroke:#888888,stroke-width:1px;
    classDef core fill:#cce5ff,stroke:#3399ff,stroke-width:1px;
    classDef data fill:#d4edda,stroke:#28a745,stroke-width:1px;
    classDef modules fill:#ffe5b4,stroke:#ff9900,stroke-width:1px;
    classDef docs fill:#f0f0f0,stroke:#666666,stroke-width:1px,stroke-dasharray: 2 2;
    classDef external fill:#e6ccff,stroke:#9933ff,stroke-width:1px;
```
