$ show ninjaframework/ninja
Ninja is a full-stack web framework for Java, built on Guice dependency injection, FreeMarker templating, and Jackson for JSON/XML serialization. It provides a complete MVC architecture with routing, controllers, filters, sessions, flash scope, i18n, validation, caching, file uploads, WebSockets, email sending, database migrations (via Flyway), and metrics collection. The framework is modular, with separate packages for core, servlet integration, standalone server (Jetty), database, metrics, email, WebSockets, and testing utilities. In production, Ninja applications are deployed either as standalone servers (embedded Jetty) or in servlet containers (Tomcat, Wildfly). The framework handles request routing through a central Routes.java file or annotation-based routing (JaxyRoutes), invokes controller methods with automatic parameter injection and validation, renders templates (FreeMarker) or JSON/XML responses, and manages client-side sessions with signed/encrypted cookies. It includes built-in support for CSRF protection, basic authentication, and secure filters. Key entry points include the Bootstrap class (application startup), NinjaDefault (core request handling), RouterImpl (route matching), ControllerMethodInvoker (parameter injection), and TemplateEngineManager (template rendering). External dependencies include Guice, FreeMarker, Jackson, EhCache/Memcached, Flyway, Apache Commons, and Codahale Metrics. The framework demonstrates strong engineering practices with clean abstractions (filter chain, argument extractors, template engine interface, cache provider), extensive test coverage, and a modular design that allows selective use of features. However, some areas show technical drift with deprecated APIs, aging library versions, and duplicated test code across modules.
The LLM identified 6 files worth highlighting for reuse:
A custom cron expression parser that supports standard cron syntax with ranges, step values, and lists. It calculates the next delay for scheduling. This is a self-contained utility that could be extracted into any Java project needing cron parsing.
Builds detailed error pages for development mode, including source code snippets, stack traces, and request/response context. It uses a template engine to render HTML with embedded CSS/JS. This component is isolated and could be reused in any web framework for better error reporting.
Implements a layered configuration system that merges default properties, mode-specific overrides, external configuration files, system properties, and programmatic overrides. It supports property interpolation and type conversion. This is a robust configuration management component that could be extracted for any Java application.
Provides HTTP caching support with ETag and Last-Modified header generation and validation. It implements conditional request handling and cache control. This component is self-contained and could be extracted for any web framework needing HTTP caching.
Provides cryptographic utilities for HMAC signing and AES encryption, used for secure cookie handling. Includes key derivation and base64 encoding. These utilities are self-contained and could be extracted for any web application needing secure client-side sessions.
A utility class for class loading, instantiation, and reflection operations. It provides methods to load classes by name, create instances, and check type compatibility. This is a standalone utility that could be reused in any Java project.