fountain:基于仓颉语言的企业级Web服务端框架项目

fountain是一个用于服务器应用开发的综合工具库。 - 零配置文件,运行期零反射函数调用 - 环境变量和命令行参数配置 - 约定优于配置 - 深刻利用仓颉语言特性 - 应用项目彻底脱离main函数,只需要开发动态链接库,fboot负责加载、初始化并运行 - 覆盖服务器应用开发的各种场景

Branch113Tags81

LICENSE stars star

  _____                    __         .__
_/ ____\____  __ __  _____/  |______  |__| ____
\   __\/  _ \|  |  \/    \   __\__  \ |  |/    \
 |  | (  <_> )  |  /   |  \  |  / __ \|  |   |  \
 |__|  \____/|____/|___|  /__| (____  /__|___|  /
                        \/          \/        \/

fountain

fountain

Introduction

Stargazers over time

Stargazers over time

Version Number

The version number has three parts, a.b.c. a.b must strictly match the first two parts of the Cangjie SDK version. c is formatted as x0yz, where yz is the number of releases on top of SDK version a.b. x indicates a major feature change: when the SDK changes in a way that forces a version bump, x is incremented by 1.

For example, starting from 2026.11.09, SDK nightly 1.3.0 no longer allows a subtype to implement or inherit an interface already implemented or inherited by its parent type. Judging from the compiler errors, this seems to be caused by local mode. Therefore the version number was changed to 1.3.1019.

Demo Video

🎥 Watch the full demo video

STDX dependency

Configure the environment variable: export CANGJIE_STDX_DYNAMIC_PATH=/path/to/dynamic_stdx

fountain::fboot

The launcher for application projects that depend on fountain. An application project only needs to be compiled into a dynamic library, and fboot calls fountain::f_app to start the application.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/fboot/README_en.md

Installation

cjpm install fountain::fboot-a.b.c --root /path/to/install # replace a.b.c with the actual version number
export PATH=$PATH:/path/to/install/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/install/libs/fboot

Startup

fboot run --dylibPattern=<REGEX_OF_PROJECT_DYLIB_FILENAMES> # see the boot.sh script of the project's fdemo module for details
# dylibPattern can also be defined as an environment variable, eg.
# export dylibPattern=<REGEX_OF_PROJECT_DYLIB_FILENAMES>

Creating a project and adding dependencies

After installing fboot, you can run fboot workspace to initialize the current directory as a Cangjie workspace project; see the fboot documentation for details. Any module the project needs is added to the cjpm.toml in the project root directory. Take f_base as an example:

fboot workspace <workspace_name> # Omit <workspace_name> to create a workspace at the current working path, which must then be empty
# Automatically adds the dependencies fountain::f_base and fountain::f_version with version 1.0.0
# The automatically added dependencies match the fboot version
# Automatically adds the stdx dependencies; define the environment variable CANGNJIE_STDX_DYNAMIC_PATH yourself
cd <workspace_name>
fboot module <module_name> # Create a dynamic library module
fboot help # Display the other features of fboot
[dependencies]
# Make a.b.c the same as `fboot version`
"fountain::f_base" = "a.b.c" 
"fountain::f_version" = "a.b.c"

Module dependencies

The diagram below shows the dependencies between fountain modules (the arrow A → B means A depends on B; green boxes are the foundation modules that depend on nothing, blue boxes are the most depended-upon modules. Only dependencies that are both declared in cjpm.toml and actually imported in the source are drawn; for each module its three most-called dependencies are drawn as solid colored lines and the rest as dashed grey lines. The demo applications fdemo, fcoder and frpcdemo are not included):

fountain module dependencies

The matrix below is the same data in another reading — handy for lookups such as "what does X depend on / who depends on X" (rows are dependents, columns are dependencies, both axes share the same order; a cell takes the dependent's color, its shade follows how many times that module calls the dependency's API — the three most-called dependencies of each row are colored cells, the rest are pale grey):

fountain module dependency matrix

The generators and how to redraw the diagrams: see docs/模块依赖图.

fountain-developer

skills/fountain-developer is a skill for AI coding agents (a standard Agent Skills layout, not tied to any specific tool); it captures the complete workflow of building projects with fountain, covering eleven workstreams from getting started to delivery:

  • Getting started: install fboot, initialize a workspace, create modules with fboot module, and add central-repository module dependencies to a project;
  • Q&A: answer questions about fountain configuration keys and API usage, with sources cited (and an honest "not found" when the repository has no answer);
  • Development: build a server application from a requirements document (MVC / ORM / Bean / AOP / security / scheduled tasks); port projects written in other languages (Python / Java / Go / Node, etc.) to Cangjie; refactor Cangjie projects that do not use fountain into the fountain style; develop the framework itself inside this repository (add features / fix defects / create modules);
  • Evolution: add or adjust module dependencies and configuration as features evolve, keeping the three platform scripts in sync;
  • Delivery: the development workstreams follow one complete pipeline — initialize → configure → strict TDD (Red-Green-Refactor, loading the test-driven-development skill up front) → regression + smoke tests → commit → tag.

The skill always takes its API facts from this repository's code and READMEs: the bundled scripts/fountain_lookup.py locates this repository and provides module lists, keyword search (covering both READMEs and sources) and per-module public declaration listings; when no local checkout exists it clones a documentation copy automatically (for lookup only). Whenever fountain does not cover a required capability, the skill confirms the plan with the developer first (simplify / provide a third-party dependency / reduce scope / implement in-project) instead of faking it. It also links the Cangjie knowledge skills (cangjie-coding / cangjie-doc-lookup) to verify language and std/stdx APIs, and follows fdemo / frpcdemo to generate three-platform launch scripts (boot.sh / boot-macos.sh / boot-win-gitbash.sh) for new projects. Building a server application from a requirements document (workflow F) and creating a module inside this repository (workflow J) additionally follow the OpenSpec spec-driven flow: opsx:propose produces the five change artifacts → the developer reviews design.md / tasks.md → opsx:apply implements task by task under TDD → opsx:verify checks code against spec → opsx:archive files the change (planning writes documents only, never code; the OpenSpec artifacts do not replace TDD / regression / smoke tests / commit / tag).

Usage: copy skills/fountain-developer into your coding agent's skills directory (e.g. CodeBuddy's ~/.codebuddy/skills/, Claude Code's ~/.claude/skills/, or a project-local skills directory); agents without a skill mechanism can simply read skills/fountain-developer/SKILL.md.

Detailed documentation of each module

fountain::f_a2a

Agent-to-Agent (A2A) protocol dynamic library: task model, state machine, server and client; transport and protocol reuse f_jsonrpc (JSON-RPC 2.0 over HTTP, streaming over SSE).

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_a2a/README_en.md

fountain::f_app

Application process management module; this module can load application projects developed with fountain as dynamic libraries. You can also use the same-named APIs of this module through the fountain::fountain.app package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_app/README_en.md

fountain::f_aspect

AOP You can also use the same-named APIs of this module through the fountain::fountain.aspect package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_aspect/README_en.md

fountain::f_base

Some Iterator extensions, enum OS, string extensions to get the raw byte array of a string without unsafe, ArrayList extensions to get the raw array of an ArrayList without unsafe, extend Option, extend Array, extend Range, extend Number, extend String, extend ThreadLocal, HashBuilder, StringGenerator, etc. You can also use the same-named APIs of this module through the fountain::fountain.base package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_base/README_en.md

fountain::f_bean

IOC You can also use the same-named APIs of this module through the fountain::fountain.base package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_bean/README_en.md

fountain::f_cache

Heap cache You can also use the same-named APIs of this module through the fountain::fountain.cache package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_cache/README_en.md

fountain::f_chart

JSON-driven SVG charts: callers describe data and styling in JSON; at runtime f_svg turns it into SVG. One chart per source file, all behind the same Chart interface.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_chart/README_en.md

fountain::f_cmd

Command line tools You can also use the same-named APIs of this module through the fountain::fountain.cmd package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_cmd/README_en.md

fountain::f_codec

Codec

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_codec/README_en.md

fountain::f_collection

Collections not yet supported by the standard library, plus some standard library collection extensions You can also use the same-named APIs of this module through the fountain::fountain.collection package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_collection/README_en.md

fountain::f_concurrent

Load balancing, rate limiting algorithms, concurrent collections not yet supported by the standard library, and standard library concurrent collection extensions You can also use the same-named APIs of this module through the fountain::fountain.concurrent package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_concurrent/README_en.md

fountain::f_config

Configuration module You can also use the same-named APIs of this module through the fountain::fountain.config package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_config/README_en.md

fountain::f_crypto

Cryptography module You can also use the same-named APIs of this module through the fountain::fountain.crypto package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_crypto/README_en.md

fountain::f_data

Data copying module, which can copy public member variables and public member properties with the same name between instances of any classes. The value of a public member variable or property with a given name can be obtained at any time. It provides various data validation annotations that can decorate public member variables or properties as well as function parameters, implementing data validation during copying; they can also validate the actual arguments of controller functions when MVC passes parameters. You can also use the same-named APIs of this module through the fountain::fountain.data package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_data/README_en.md

fountain::f_dbpool

Database connection pool built on f_pool, providing a Datasource connection pool (DatabasePool moved out of f_orm and re-exported by it)

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_dbpool/README_en.md

fountain::f_excel

Excel (xlsx / OOXML) reader and writer: streaming parse, streaming generate, date detection and merged cells.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_excel/README_en.md

fountain::f_exception

Exception module You can also use the same-named APIs of this module through the fountain::fountain.exception package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_exception/README_en.md

fountain::f_http

HTTP; currently it implements the definition of the HTTP data format MediaType and the json and multipart/form-data implementations. You can also use the same-named APIs of this module through the fountain::fountain.http package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_http/README_en.md

fountain::f_httpclient

HTTP client You can also use the same-named APIs of this module through the fountain::fountain.httpclient package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_httpclient/README_en.md

fountain::f_hydra

In-process vector store: collection → record → three-way vectors, persisted through f_store, no database required.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_hydra/README_en.md

fountain::f_io

IO You can also use the same-named APIs of this module through the fountain::fountain.io package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_io/README_en.md

fountain::f_jsonrpc

JSON-RPC 2.0 over HTTP server and client on top of f_mvc: the JSON-RPC message model, a runtime method table and the error model.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_jsonrpc/README_en.md

fountain::f_jwt

JWT You can also use the same-named APIs of this module through the fountain::fountain.jwt package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_jwt/README_en.md

fountain::f_log

Logging You can also use the same-named APIs of this module through the fountain::fountain.log package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_log/README_en.md

fountain::f_macros

Macro utility API You can also use the same-named APIs of this module through the fountain::fountain.macros package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_macros/README_en.md

fountain::f_mcp

MCP (Model Context Protocol) client / server SDK: the message layer is f_jsonrpc; MCP semantics cover version and capabilities, tools, resources, prompts, subscriptions and rate limiting.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_mcp/README_en.md

fountain::f_mockdb

mock database You can also use the same-named APIs of this module through the fountain::fountain.mockdb package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_mockdb/README_en.md

fountain::f_mvc

MVC You can also use the same-named APIs of this module through the fountain::fountain.mvc package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_mvc/README_en.md

fountain::f_net

Event-driven network communication module You can also use the same-named APIs of this module through the fountain::fountain.net package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_net/README_en.md

fountain::f_orm

ORM You can also use the same-named APIs of this module through the fountain::fountain.orm package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_orm/README_en.md

fountain::f_pool

An implementation of pools, providing object pools, array pools and ArrayList pools You can also use the same-named APIs of this module through the fountain::fountain.pool package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_pool/README_en.md

fountain::f_process

Process extension module You can also use the same-named APIs of this module through the fountain::fountain.process package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_process/README_en.md

fountain::f_protocol

An implementation of a network communication protocol

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_protocol/README_en.md

fountain::f_random

Random number extensions, ThreadLocalRandom, reservoir sampling algorithm, random strings You can also use the same-named APIs of this module through the fountain::fountain.random package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_random/README_en.md

fountain::f_regex

Regular expression extensions, regex cache, regex DSL You can also use the same-named APIs of this module through the fountain::fountain.regex package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_regex/README_en.md

fountain::f_rule

Rule engine: fact bases, a Rete network, an agenda, decision tables and decision flows, built on f_egraph and f_jit.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_rule/README_en.md

fountain::f_rx

Reactive programming API You can also use the same-named APIs of this module through the fountain::fountain.rx package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_rx/README_en.md

fountain::f_security

Security module used together with MVC You can also use the same-named APIs of this module through the fountain::fountain.security package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_security/README_en.md

fountain::f_ticktock

CRON timer module You can also use the same-named APIs of this module through the fountain::fountain.ticktock package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_ticktock/README_en.md

fountain::f_time

Time API extensions for the standard library You can also use the same-named APIs of this module through the fountain::fountain.time package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_time/README_en.md

fountain::f_util

crc16/key exchange protocol/naming style conversion/common design patterns/geohash/snowflake/UUID/murmur_hash/path matching/text template/tree structure conversion You can also use the same-named APIs of this module through the fountain::fountain.util package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_util/README_en.md

fountain::f_version

Version information of the application and fountain, and the application BANNER You can also use the same-named APIs of this module through the fountain::fountain.version package.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_version/README_en.md

fountain::f_email

Email client: SMTP / POP3 / IMAP4rev1 + MIME parsing and generation, a unified Email facade (send / list / body / attachments / delete), streaming attachments, TLS and credential redaction.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_email/README_en.md

fountain::f_xml

Generic XML 1.0 parser and generator: streaming events (push / pull), DOM, namespaces, DTD internal entities, security limits.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_xml/README_en.md

fountain::f_svg

SVG 1.1 static documents: value types, typed DOM, parser and writer, lossless preservation of unknown content, security filtering and size limits

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_svg/README_en.md

fountain::f_zip

ZIP container reader/writer: ZIP64 in both directions, streaming writes (24-byte ZIP64 descriptor), large-entry spilling, Zip Slip / symlink / bomb protection.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_zip/README_en.md

fountain::f_egraph

Event-driven flow library

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_egraph/README_en.md

fountain::f_llm

Large model development library based on fountain::f_egraph

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_llm/README_en.md

fountain::f_store

An LSM-TREE key-value store based on fountain::f_collection.ConcurrentSkipListMap and fountain::f_io.SegmentedLog. Every create/read/update/delete operation is guaranteed to be atomic. It also supports iterators for KEY prefix traversal.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_store/README_en.md

fountain::fleet

A data synchronization service based on fountain::f_store, fountain::f_codec, fountain::f_net and fountain::f_protocol. It can be used for service registration, configuration centers, metadata registration, and so on.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/fleet/README_en.md

fountain::f_rpc

RPC implementation with service self-registration and discovery, implementing load balancing, service node weights, heartbeat keep-alive, etc.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_rpc/README_en.md

fountain::f_bloom

Bloom Filter implementation

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_bloom/README_en.md

fountain::f_health

Process health check

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_health/README_en.md

fountain::f_uring

FFI bindings for liburing; all APIs are available on Linux only

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_uring/README_en.md

fountain::f_mq

MQ client and the client/server shared API: record codec, protocol payloads, filters, topic validation, and MQClient.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_mq/README_en.md

fountain::fmq

MQ server executable (fmq server / fmq manager): multi-node queues, consumer-group cursors, timeout redelivery and dead letters, full metadata replication, and backup replicas.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/fmq/README_en.md

fountain::f_dbd

A std.database.sql driver that sends SQL and parameters to the fountain::fdbm middleware and pulls result rows on demand. It does not depend on any physical database driver; the registration name is the dbd_driverName setting (multidbd for the multi-node variant).

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_dbd/README_en.md

fountain::f_dbm

Extension interface library for the database middleware: the contracts of PartitionAlgorithm (sharding) and IdGenerator. A third-party extension depends only on this module, is built into a dynamic library and dropped into fdbm's custom/ directory.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_dbm/README_en.md

fountain::fdbm

Database middleware shipped as an executable module. Applications see one logical database; inside, fdbm provides shard routing, read/write splitting, global-table broadcasting, ID generation and a routing cache. Clients connect through the fountain::f_dbd driver; physical database drivers are loaded from a deployment driver/ directory.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/fdbm/README_en.md

fountain::f_jit

Bytecode compiler and JIT for a Cangjie dialect: source is compiled to architecture-neutral bytecode (.fbc) and executed by an interpreter plus x86_64 / aarch64 native backends, interoperating with host classes, functions and closures through JitFunction.call<T>. The interpreter is the semantic authority; native code is Linux-only and other platforms fall back to the interpreter.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_jit/README_en.md

fountain::f_probe

Extension contract for server monitoring: probe agents (ProbeAgent), alarm message channels (AlarmMessageChannel), thread-safe registries and stable error codes. A third-party extension depends only on this module to build a dynamic library, without RPC, mail or TUI dependencies.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_probe/README_en.md

fountain::f_tui

Unix terminal backend: POSIX termios raw mode, terminal size, key decoding, ANSI differential rendering, and a ratatui_buffer.Buffer → ANSI renderer. It depends only on f_base and the ratatui base packages, never on crossterm / ratatui_backend / ratatui_terminal / ratatui_widgets.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/f_tui/README_en.md

fountain::fprobe

Server-monitoring executable (fprobe agent / fprobe supervisor): the node agent periodically collects host metrics and exposes them over RPC; the supervisor aggregates multiple nodes and provides TUI and resident modes, alarms, terminal charts, periodic reports with inline SVG, an optional LLM advisor and custom/ dynamic-library extensions.

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/fprobe/README_en.md

fountain::fboot

Application project launcher depending on fountain

See details:https://gitcode.com/Cangjie-TPC/fountain/blob/master/fboot/README_en.md

Introduction

fountain是一个用于服务器应用开发的综合工具库。 - 零配置文件,运行期零反射函数调用 - 环境变量和命令行参数配置 - 约定优于配置 - 深刻利用仓颉语言特性 - 应用项目彻底脱离main函数,只需要开发动态链接库,fboot负责加载、初始化并运行 - 覆盖服务器应用开发的各种场景

https://gitcode.com/Cangjie-TPC/fountainCustomize your domain