Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

chore: standalone repo — sibling freeapi checkout, README, gitignore

Tashfeend18bac30c7fc
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..f8fa42e4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+node_modules/
+build/
+dist-electron/
+.DS_Store
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..e1e21845
--- /dev/null
+++ b/README.md
@@ -0,0 +1,57 @@
+# FreeLLMAPI Desktop
+
+Lean Electron menu-bar app for [freellmapi](https://github.com/tashfeenahmed/freellmapi):
+runs the whole router locally on `127.0.0.1:31415`, with a dark-glass tray
+popover (live 24h request chart, quick stats, copy URL/key) and the full
+dashboard in a native-feeling window.
+
+## Layout requirement
+
+This repo builds against a **sibling checkout** of the main repo:
+
+```
+…/experiments/
+ freeapi/ # the freellmapi repo (server + client sources)
+ freeapi-desktop/ # this repo
+```
+
+A different location can be set with `FREEAPI_REPO=/path/to/freeapi` (dev
+runtime); the esbuild import paths in `src/server-host.ts` and the
+`extraResources` entry in `electron-builder.yml` assume the sibling layout.
+
+The sibling checkout must include the embedder hooks (`CLIENT_DIST` /
+`FREEAPI_ENV_PATH` env overrides in the server, desktop-mode navbar in the
+client) and a built `client/dist`:
+
+```bash
+cd ../freeapi
+npm install
+npm run build -w client
+```
+
+## Develop
+
+```bash
+npm install
+npm run rebuild:native # better-sqlite3 against Electron's ABI (dev loop only)
+npm run dev # bundle + launch
+```
+
+UI iteration helpers (dev only): `FREEAPI_SHOT=1 npx electron .` captures the
+popover + dashboard to /tmp and quits; `FREEAPI_SHOT=hold` pins the popover
+open for real-screen captures.
+
+## Package
+
+```bash
+npm run dist # electron-builder → dist-electron/FreeLLMAPI-…-arm64.dmg
+```
+
+## Notes
+
+- DB + config live in `~/Library/Application Support/FreeLLMAPI/`.
+- The server binds loopback only; default port 31415, scan-up on conflict,
+ resolved port persisted.
+- Do not run plain `npm rebuild` here — it rebuilds better-sqlite3 for the
+ system Node ABI and breaks the Electron dev loop (`npm run rebuild:native`
+ fixes it). Packaging rebuilds natives itself.
diff --git a/electron-builder.yml b/electron-builder.yml
index fb54ffad..b08d5a98 100644
--- a/electron-builder.yml
+++ b/electron-builder.yml
@@ -12,7 +12,7 @@ asarUnpack:
- "**/node_modules/better-sqlite3/**/*.node"
- "**/node_modules/better-sqlite3/build/Release/**"
extraResources:
- - from: ../client/dist
+ - from: ../freeapi/client/dist
to: client-dist
mac:
category: public.app-category.developer-tools
diff --git a/src/main.ts b/src/main.ts
index 4623063f..db9a88b2 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -53,10 +53,12 @@ if (!app.requestSingleInstanceLock()) {
const cfg = loadConfig();
const dbPath = path.join(app.getPath('userData'), 'freeapi.db');
// Packaged: client/dist ships in extraResources (Resources/client-dist).
- // Dev (electron . from desktop/): use the repo's client/dist.
+ // Dev: use the sibling freellmapi checkout's client/dist (FREEAPI_REPO
+ // overrides the default ../freeapi location).
+ const repoRoot = process.env.FREEAPI_REPO ?? path.resolve(__dirname, '../../freeapi');
const clientDist = app.isPackaged
? path.join(process.resourcesPath, 'client-dist')
- : path.resolve(__dirname, '../../client/dist');
+ : path.join(repoRoot, 'client/dist');
try {
const { port } = await startServer({
diff --git a/src/server-host.ts b/src/server-host.ts
index b4a4e5ca..7d288f90 100644
--- a/src/server-host.ts
+++ b/src/server-host.ts
@@ -3,13 +3,17 @@
// internals: the db singleton lives inside this bundle, so anything stateful
// (auth bootstrap, getDb) must be exported from here rather than imported
// from server/src by the main bundle (which would get a second, empty copy).
-import '../../server/src/env.js';
+//
+// The server sources come from the sibling freellmapi checkout
+// (../freeapi — see README). Keep these relative imports in sync with the
+// FREEAPI_REPO default in main.ts and scripts/bundle-server.mjs.
+import '../../freeapi/server/src/env.js';
import crypto from 'node:crypto';
import type { Server } from 'node:http';
-import { createApp } from '../../server/src/app.js';
-import { initDb, getDb, getUnifiedApiKey } from '../../server/src/db/index.js';
-import { startHealthChecker } from '../../server/src/services/health.js';
-import { userCount, createUser, createSession } from '../../server/src/services/auth.js';
+import { createApp } from '../../freeapi/server/src/app.js';
+import { initDb, getDb, getUnifiedApiKey } from '../../freeapi/server/src/db/index.js';
+import { startHealthChecker } from '../../freeapi/server/src/services/health.js';
+import { userCount, createUser, createSession } from '../../freeapi/server/src/services/auth.js';
export { getDb, getUnifiedApiKey };