Gingee: Core Concepts

Welcome to Gingee! This guide will introduce you to the fundamental concepts and the core philosophy behind the platform. Understanding these ideas will help you build powerful, secure, and scalable applications quickly.

The Philosophy: Instant Time to Joy

Gingee is designed around a single guiding principle: drastically reduce the time from an idea to a running, production-ready application.

Traditional backend development involves dozens of small, time-consuming decisions and setup tasks: choosing a framework, setting up a server, configuring a database pool, managing CORS, structuring your project, and more. Gingee handles all of this for you. It's a "batteries-included" platform that lets you focus on your unique business logic from day one.

1. The Gingee Project Structure

A Gingee server has a simple, predictable folder structure. The key directories are:

2. The Flexible Routing Engine

Gingee features a powerful and flexible routing engine that automatically maps incoming URL requests to your server scripts or static files. It supports two distinct modes to fit your application's needs. The two modes can also be used together.

NOTE:

Mode 1: File-Based Routing (Zero-Config Default)

For simplicity and rapid development, this is the default behavior. You don't need to configure anything—just create files.

Mode 2: Manifest-Based Routing (Powerful & Explicit)

For building RESTful APIs with clean, dynamic URLs, you can activate a more powerful routing mode by creating a routes.json file in your app's box folder.

IMPORTANT: The /box/ folder is never included in the url paths. Eg. a URL / /api/my-script is automatically resolved by Gingee to / /box/api/my-script . If the script exists, it is executed as a server script, if not Gingee will attempt to check for a folder of the same name in the path / /api/my-script . If such a folder does not exist then a 404 is issued. If /box/ appears in the URL a blanket 403 Access Denied is issued.

3. The Sandbox (gbox) & Secure Execution

Security is not an afterthought in Gingee; it is the default. Every server script you write is executed inside a secure sandbox called the "gbox".

4. The gingee() Middleware & the $g Global

This is the heart of the Gingee development experience. Every server script is wrapped in a call to the gingee() middleware, which prepares the environment and provides a powerful, simplified API.

module.exports = async function() {
    await gingee(async ($g) => {
        // Your code goes here
        $g.response.send("Hello, World!");
    });
};

The $g object is your secure gateway to everything you need for a request, including the parsed request ($g.request), a response builder ($g.response), the logger ($g.log), and your app's configuration ($g.app).

5. The Module Ecosystem

Gingee provides a rich standard library of "app modules" to handle common tasks securely and efficiently. These are required by name (e.g., require('db')) from any server script.

IMPORTANT: All Gingee modules are required by name (eg. 'fs'). Some of these names intentionally are similar to NodeJS built-in modules for developer familiarity only. Gingee by default locks out access for all NodeJS built-in modules and third party modules with the exception of 'querystring', 'url' and 'mime-types'. A whitelist of built-in and third party modules can be configured in gingee.json but it is not recommended to do so to preserve the sandboxed nature of Gingee apps.

6. Configuration (gingee.json, app.json, etc.)

Configuration in Gingee is declarative and split across several manifest files, each with a clear purpose. This separation keeps server-level concerns apart from application-specific ones.

For a full breakdown, see the Server Config and App Structure reference guides.

7. The Command Line Interface (CLI)

The gingee-cli is an essential, all-in-one tool for the entire application lifecycle. It is used for both local development and production server management. Its key capabilities include:

For detailed usage of all commands, see the CLI Command Reference MD / HTML.

8. A GenAI-Native Platform

Gingee is unique in its origin and development philosophy. It was co-authored by a human architect and a Generative AI partner, embracing a workflow we call "Dialog-Driven Development." High-level goals are discussed and refined in a collaborative dialogue, and the AI generates the implementation, which is then tested and validated.

You are encouraged to adopt this same powerful workflow. The key is to provide the AI with a "knowledge bundle" of the platform's architecture.

How to Start an AI-Assisted App Development Session:

  1. Get the Context: Locate the ai-context.md file in the project's docs/ai-context directory.
  2. Prime the AI: Begin a new session with a capable AI (like Google Gemini) by providing the entire contents of the context file with a simple instruction: "You are an expert developer for a platform called Gingee. Analyze the following documentation and API reference and be prepared to help me build an application."
  3. Give it a Task: Once the AI has processed the context, you can give it high-level, goal-oriented tasks, and it will generate high-quality, idiomatic Gingee code.