Skip to content

Project Structure ​

Teldock is a monorepo with three top-level parts: a Node.js API (backend/), a React single-page app (frontend/), and a VitePress documentation site (docs-site/). This page explains how the source is organized and how the automated checks are wired.

Directory tree ​

text
Teldock/
├── backend/                         Node.js API (Express 5)
│   ├── server.js                    Process entry point
│   ├── src/
│   │   ├── app.js                   Express setup, middleware, route mounting
│   │   ├── config/
│   │   │   ├── database.js          Sequelize/MySQL connection
│   │   │   └── secrets.js           Secret resolver and boot-time validation
│   │   ├── routes/                  Endpoint definitions + middleware binding
│   │   │   ├── index.js             Mounts /auth, /files, /health
│   │   │   ├── auth.routes.js
│   │   │   ├── file.routes.js       Streaming multipart upload, file CRUD
│   │   │   ├── folder.routes.js
│   │   │   ├── user.routes.js       Telegram connect/config/status/unlink
│   │   │   ├── bot.routes.js        Multi-bot pool
│   │   │   ├── share.routes.js
│   │   │   ├── tag.routes.js
│   │   │   ├── smart-folder.routes.js
│   │   │   ├── preview.routes.js
│   │   │   ├── stats.routes.js
│   │   │   └── webdav.routes.js     Rclone-compatible WebDAV
│   │   ├── controllers/             HTTP request/response handling
│   │   ├── services/                Business logic
│   │   │   ├── telegram-storage.service.js   Chunking, streaming, Telegram I/O
│   │   │   ├── bot-pool.service.js           Round-robin bot selection
│   │   │   ├── file-upload.service.js
│   │   │   ├── file-stream.service.js
│   │   │   ├── file-query.service.js
│   │   │   ├── file-management.service.js
│   │   │   ├── version-history.service.js
│   │   │   ├── jwt.service.js
│   │   │   ├── realtime-sync.service.js      Socket.IO real-time sync
│   │   │   ├── file-service-error.js
│   │   │   └── preview/
│   │   │       ├── image.service.js
│   │   │       └── video.service.js
│   │   ├── models/                  Sequelize models + associations
│   │   │   ├── index.js
│   │   │   ├── User.js
│   │   │   ├── BotToken.js
│   │   │   ├── File.js
│   │   │   ├── FilePart.js
│   │   │   ├── FileVersion.js
│   │   │   ├── FileTag.js
│   │   │   ├── Folder.js
│   │   │   ├── SharedLink.js
│   │   │   ├── SmartFolder.js
│   │   │   ├── Tag.js
│   │   │   └── TelegramConfig.js
│   │   ├── middleware/              Auth, validation, file access, upload
│   │   ├── validation/              Zod schemas (auth, file, telegram)
│   │   └── utils/                   Shared helpers (currently empty)
│   ├── scripts/                     Migration and diagnostic scripts
│   └── tests/                       node:test unit and integration tests
├── frontend/                        React 18 + Vite SPA
│   ├── index.html
│   ├── vite.config.js
│   ├── tailwind.config.js
│   ├── postcss.config.js
│   └── src/
│       ├── main.jsx                 App bootstrap + auth initialization
│       ├── App.jsx                  Router configuration
│       ├── index.css
│       ├── pages/                   Route-level views
│       │   ├── Landing.jsx
│       │   ├── Login.jsx
│       │   ├── Register.jsx
│       │   ├── Dashboard.jsx
│       │   ├── MobileDashboard.jsx
│       │   ├── Settings.jsx
│       │   ├── Shares.jsx
│       │   └── Stats.jsx
│       ├── components/              Reusable UI
│       │   ├── Layout.jsx
│       │   ├── FileViewer.jsx
│       │   ├── TagPicker.jsx
│       │   ├── TransferCenter.jsx
│       │   └── VersionHistory.jsx
│       ├── services/
│       │   └── api.js               Axios client + interceptors
│       └── store/
│           ├── auth-store.js        Zustand auth state
│           ├── theme-store.js       Dark/light theme state
│           └── transfer-context.jsx Upload/download transfer state
├── docs-site/                       VitePress documentation (this site)
├── .github/workflows/
│   ├── ci.yml                       Lint, test, and frontend build
│   └── deploy-docs.yml              Build and deploy the docs site
└── README.md

Backend layers ​

The backend follows a strict layered architecture:

text
routes → controllers → services → models
LayerDirectoryResponsibility
Routessrc/routesDeclare URL paths, attach authentication and validation middleware.
Controllerssrc/controllersHandle the HTTP request/response cycle and translate service errors into status codes.
Servicessrc/servicesHold business logic: chunking, streaming, bot selection, previews, version history.
Modelssrc/modelsDefine tables, associations, and persistence helpers via Sequelize.
Middlewaresrc/middlewareCross-cutting concerns: JWT verification, Zod validation, file-access signatures, upload parsing.
Validationsrc/validationZod schemas that describe valid request bodies.
Configsrc/configDatabase connection and centralized secret resolution.

Frontend folders ​

FolderRole
src/pagesRoute-level screens rendered by the React Router configuration in App.jsx.
src/componentsReusable UI pieces such as the layout shell, file viewer, tag picker, and transfer center.
src/servicesThe Axios API client and its request/response interceptors.
src/storeZustand stores for auth, theme, and transfer state.

Backend npm scripts ​

Run these from the backend directory.

ScriptCommandPurpose
startnode server.jsStart the API in the current environment.
devnodemon server.jsStart with auto-reload for development.
migratenode scripts/migrate.jsCreate/update all database tables.
migrate:chunkednode scripts/migrate-chunked-storage.jsAdd chunked/encrypted columns.
migrate:drop-quotanode scripts/migrate-drop-quota.jsRemove the legacy fixed quota.
migrate:widen-share-tokennode scripts/migrate-widen-share-token.jsWiden the share token column.
migrate:version-snapshotsnode scripts/migrate-version-snapshots.jsAdd version part snapshots.
migrate:tags-favoritesnode scripts/migrate-tags-favorites.jsAdd tags, favorites, smart folders.
testnode --test tests/*.test.jsRun the unit/integration test suite.
test-authnode tests/test-auth.jsRun the legacy auth test script.
test-dbnode scripts/test-database.jsVerify database connectivity and schema.
linteslint "src/**/*.js" "tests/**/*.js" "scripts/**/*.js" "*.js"Static analysis.
formatprettier --write ...Format source, tests, and scripts.

Frontend npm scripts ​

Run these from the frontend directory.

ScriptCommandPurpose
devvite --host 0.0.0.0 --port 3000Start the dev server on port 3000.
buildvite buildProduce the production bundle in dist/.
previewvite previewServe the built bundle locally.

Continuous integration ​

.github/workflows/ci.yml runs on every push to main, on every pull request, and on manual dispatch. It has two independent jobs:

JobSteps
backendCheck out, set up Node.js 22, npm ci --ignore-scripts, npm run lint, npm test.
frontendCheck out, set up Node.js 22, npm ci --ignore-scripts, npm run build.

TIP

CI runs on every push to main and on every pull request. Keep npm run lint and npm test green in backend, and npm run build green in frontend, before opening a PR.

The documentation site is built and deployed by a separate workflow, .github/workflows/deploy-docs.yml. It triggers only when files under docs-site/ change (or when run manually), runs npm run docs:build in docs-site, and publishes the result to GitHub Pages.

Released under the MIT License.