Demo Project
The demonstration project shows how to configure the platform, connect tenant hooks, and start the main applications. It can be used as a project structure example or as the basis for your own deployment.
Project Structure
The demo project is a repository in which application code, static assets, and third-party component configuration examples are organized in separate directories:
famir-demo/
├── assets/ # static application resources
├── third-party/ # third-party component configuration examples
├── logs/ # log files
├── src/ # TypeScript application code
├── build-assets.js # generated source files for static assets
├── package.json
└── tsconfig.jsonThe src directory contains the TypeScript code and application entry points. The assets directory contains static files. The third-party directory contains external infrastructure configuration examples.
Static assets
Assets are static files required by applications at runtime, including YAML presets, HTML pages, text files, and icons.
Before compilation, build-assets.js reads the contents of assets/console, assets/reverse, and assets/actions, then generates TypeScript modules:
assets/console → src/console/assets.ts
assets/reverse → src/reverse/assets.ts
assets/actions → src/actions/assets.tsThe script runs during the prebuild phase. Its output is included in the application build, so applications access assets through an embedded registry rather than reading files directly from the assets directory at runtime.
To add or modify an asset, edit the source file in assets/<app> and rebuild the project.
Third-party component configuration
The third-party directory contains configuration examples for components used with Famir:
third-party/
├── caddy/ # Caddy configuration examples
├── gost/ # gost proxy manager configuration
└── hosts-local # example hosts file for local YAML presetsFiles under third-party are not embedded in applications as static assets. They are configuration examples for external components that can be adapted to a specific environment.
hosts-local demonstrates how to map local mirror domains to the test environment. If needed, entries from this example can be added to the system /etc/hosts file.
Applications
The project contains three Famir applications. Each application has a directory under src, a composition module, and a loader that connects infrastructure dependencies and manages startup.
console-app
console-app provides the platform administration interface. In the demo project, it can run as a CLI application or as a network application.
The main.ts module registers controllers and services for system functions and Famir entities such as campaign, proxy, target, redirector, lure, session, and message. Loaders connect required dependencies, including configuration, logging, and the database.
YAML presets are located in assets/console. During the build, their contents are included in the console-app assets. This allows the application to load presets without reading the original YAML files at runtime.
src/console/
├── loaders/
│ ├── cli.ts # CLI variant startup
│ └── net.ts # network variant startup
├── assets.ts # generated from assets/console
├── main.ts # controller and service registration
└── preload.ts # process initialization
assets/console/
├── *.yaml # YAML presets
└── banner-greet.txt # text resourcereverse-app
reverse-app accepts and processes HTTP traffic forwarded by the external edge server. Its loader connects the HTTP server and client, database, task queue, and other required infrastructure components.
The main.ts module composes the reverse-processing controllers and registers tenant hooks. Hooks are located in src/reverse/tenants and connected to the reverse application through a tenant switch. A hook can apply to the corresponding tenant and target.
HTML pages and other static resources for the reverse application are stored in assets/reverse. In the demo project, resources can be grouped by website or purpose. During the build, they are included in generated src/reverse/assets.ts.
src/reverse/
├── loaders/
│ └── std.ts # reverse-app startup
├── tenants/
│ ├── index.ts # tenant hook exports
│ └── *.ts # individual tenant hooks
├── assets.ts # generated from assets/reverse
├── main.ts # controller and tenant switch composition
└── preload.ts # process initialization
assets/reverse/
├── <tenant>/ # resources for an individual website or tenant
└── *.html, *.txt, *.ico # shared static filesYAML presets configure campaigns and targets, while hooks implement additional programmable behavior. Static HTML and other files are separate reverse-app assets and do not replace hook code.
actions-app
actions-app performs background task processing. In the demo project, it runs workers that consume jobs from BullMQ queues, including analysis and webhook workers.
The loader registers database, object storage, producer and consumer components, and workers before starting the application. The assets/actions directory stores static files for this application.
src/actions/
├── loaders/
│ └── std.ts # actions-app startup
├── assets.ts # generated from assets/actions
├── main.ts # controller and service registration
└── preload.ts # process initialization
assets/actions/
└── ... # static resourcesBuild and run
Preparation
Install dependencies:
npm installCreate a local environment file:
cp .env.example .envConfigure .env for your infrastructure, including Redis and object storage connection settings. Then build the project:
npm run buildThe build command first generates TypeScript modules containing static assets and then compiles TypeScript into the dist/ directory.
Running with npm run
Each application can be started separately:
# Reverse proxy application
npm run start:reverse-std
# Console Cli application
npm run start:console-cli
# Console Net application
npm run start:console-net
# Background workers and task processing
npm run start:actions-stdThe console-app Cli variant is intended for interactive administration commands. The Net variant runs console as a TCP server. reverse-app handles incoming traffic, while actions-app executes background tasks.
Running with PM2
Create a PM2 configuration from the example:
cp pm2.config.cjs.example pm2.config.cjsThe example configures three applications:
console—Netvariant ofconsole-app;reverse—reverse-app;actions—actions-app.
Start the applications:
pm2 start pm2.config.cjsCheck process status and view logs with:
pm2 status
pm2 logsStandard PM2 commands can be used to manage processes:
pm2 restart all
pm2 stop allThe PM2 configuration uses .env and separate preload modules for each application.
Building the Docker image
Build the Docker image from the repository root:
docker build -t famir-demo:latest .The Dockerfile installs the required system dependencies, builds the project, and creates a production image containing the applications and runtime dependencies.
Running with Docker Compose
After building the image, start the services:
docker compose up -dThe Compose configuration starts the Famir applications and supporting infrastructure, including Redis, object storage, and the edge server. Before startup, review the Compose file and adjust environment variables, domains, ports, and component configuration paths for your environment.
Check service status and inspect output with:
docker compose ps
docker compose logs -fStop the services with:
docker compose downLogs
By default, the demo project writes logs to the logs/ directory, organized by application:
logs/
├── console/
├── reverse/
└── actions/The log directory can be changed with the LOGGER_BASE_PATH environment variable.
When running with Docker, logs are stored inside the containers. Configure a Docker volume or bind mount for the log directory if logs need to survive container removal or recreation.