# re-publisher

Owner's service · external integrations await configuration

FastAPI, PostgreSQL, a Telegram collector and a publication processing pipeline. The server runs the original app without a demo wrapper. Collection needs Telegram and model configuration. Those are not connected yet, so there is no collected content.

Source version: `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`

Code history: since 16 June 2026. Demo preparation: 7 September 2026.

[Project notes](https://portfolio.komaroff-dev.ru/en/projects/publisher/) · [Online documentation](https://portfolio.komaroff-dev.ru/en/projects/publisher/docs/)

[Demo](https://publisher.komaroff-dev.ru/) — owner access required.

[Source repository](https://github.com/komaroffsergei/re-publisher)

## Task

Content goes through extraction, classification and draft preparation. The source and intermediate results are stored separately, so a failed step can be inspected and rerun.

Editing content for topic-based channels.

## Work done

- Normalization, data extraction, classification and editing templates.
- Processing history and results for individual steps.
- Image build, migrations and deployment of the original interface. External integrations still need configuration.

## Stack

| Technology | Role |
| --- | --- |
| FastAPI / Jinja | Original editorial interface |
| PostgreSQL / SQLAlchemy / Alembic | Production data schema and migrations |
| Telethon | MTProto collector; awaiting a session |
| scikit-learn / LLM | Classification and rewriting after model configuration |

## Architecture and decisions

- The original application's app.web.main:app is running, rather than app.portfolio.
- PostgreSQL with the original migrations; separate persistent sessions, media, models, cache, artifacts and reports directories.
- The collector and full-cycle pipeline are separate services in the connected profile. They are activated after configuring the Telegram session, model and selected integrations.
- The administrative interface is protected by HTTPS Basic Auth; secrets are kept outside the repository.

### Components and integration boundaries

![Components and integration boundaries](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/diagrams/components.svg)

[Mermaid source](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/diagrams/components.mmd)

### Production pipeline after configuration

![Production pipeline after configuration](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/diagrams/scenario.svg)

[Mermaid source](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/diagrams/scenario.mmd)

### Deployment

![Deployment](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/diagrams/deployment.svg)

[Mermaid source](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/diagrams/deployment.mmd)

## Code map

| Feature | Screen / API | Module | Data / verification |
| --- | --- | --- | --- |
| Collection | Telegram MTProto | app/main.py; app/collector.py | TG session → telegram_posts; connection awaiting configuration |
| Application interface | /processed, /drafts, /pipeline | app/web/main.py; app/web/templates | 11 main GET sections checked |
| Classification | Pipeline / models | app/content/model_registry.py; pipeline_manager.py | model_versions; active joblib is not yet available |
| Editorial processing | Rewriting / prompts | app/content/pipeline_rewriter.py; prompt_versions.py | PublicationDraft / RewriteAttempt; external models unverified |
| Operations | /health; Docker Compose | Dockerfile.runtime; app/config.py; alembic | PostgreSQL, migrations, password access |

Before changing a feature, trace its interface, API, state and storage dependencies. Check inputs, errors, retries and related workflows. Update the map and affected diagrams alongside the code, rerun the related checks and attach evidence for the source version.

## Workflows and API

1. Sign in to the owner's interface and open Materials, Drafts, Labeling, Models and Pipeline.
2. Open Rewrite Progress, Prompts and Search: these are the original pages backed by PostgreSQL.
3. After configuring Telegram: app.main login/login-qr → inspect-folder → limited sync → inspect materials.
4. After registering a model and configuring the LLM: processing → classification → draft → review → approved publication to the selected channel.

## Verification

- The original Docker image was built in GitHub CI. PostgreSQL migrations were applied.
- All 11 main navigation pages return HTTP 200 after sign-in, with no JavaScript errors.
- Unauthenticated requests return 401. /health confirms web and database availability.
- Telegram collection, model execution and publishing are unverified because configuration is missing; these stages are not described as complete.

[CI: Full build of the original application](https://github.com/komaroffsergei/re-publisher/actions/runs/34082300355) — `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`, 2026-09-07; this demo's version.

## Results and measurements

- Five sequential HTTPS GET requests from the VPS to itself: 81.5–228.6 ms, all HTTP 200. This is not a load test or an assessment of the external network.
- No Telegram collection, LLM processing or Codex task ran during the measurements.

These checks apply to the listed version. Business metrics and model quality on an independent dataset were not measured.

![Container memory: three snapshots without external processing](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/metrics/resources.svg)

[Container memory: three snapshots without external processing: source data](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/metrics/resources.json)

## Limitations

- Telegram API ID/hash and an authorized MTProto session have not yet been provided. Collection of real messages has not started.
- The active tfidf_logreg.joblib model and selected LLM settings are missing. There is no basis for claiming verified classification or rewriting quality.
- The interface currently shows an empty production-schema database. The previous demo's synthetic corpus has not been mixed into the original tables.
- External publishing has not been tested: it requires a destination channel and BOT_TOKEN or MAX settings. AUTO_PUBLISH remains false until the destination is configured.

## Running and operating

The Dockerfile.runtime image is built outside the VPS. Web starts with uvicorn app.web.main:app --host 0.0.0.0 --port 8080.

Runtime settings: /srv/portfolio/publisher/.env; additional integrations: /srv/portfolio/publisher/integrations.env. Secret values are not published.

After configuring the collector, create a session with app.main login-qr or login. Do not import old WTG data: WTG has been deleted and is not a recovery source.

Register the model with the standard app.content.model_registry register-initial-model command using the owner's supplied package. Initial sync is limited to 20 messages per chat.

Do not enable AUTO_PUBLISH without a configured destination channel. Keep administrative screens private when working with real data.

## Screenshot index

1. [Materials: original interface, no data yet](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/01-original-ui.png) — 2026-09-07T04:30:17.224873+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

2. [Yandex genres: original section, no runs yet](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/03--yandex-genres.png) — 2026-09-07T04:30:17.863469+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

3. [Codex training: awaiting configuration](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/04--codex-training.png) — 2026-09-07T04:30:18.249278+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

4. [Topic audit: not yet run](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/05--topic-audit.png) — 2026-09-07T04:30:18.375701+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

5. [Drafts: the working database is empty](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/06--drafts.png) — 2026-09-07T04:30:18.739880+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

6. [Labeling: original table](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/07--labels.png) — 2026-09-07T04:30:18.939178+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

7. [Models: model registration required](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/08--models.png) — 2026-09-07T04:30:19.122813+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

8. [Pipeline: awaiting source data](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/09--pipeline.png) — 2026-09-07T04:30:19.518248+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

9. [Rewrite progress: processing has not started](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/10--rewrite-progress.png) — 2026-09-07T04:30:19.768650+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

10. [Prompts: original editorial section](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/11--pipeline-prompts.png) — 2026-09-07T04:30:20.009240+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

11. [Search in the working database](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/full/12--search.png) — 2026-09-07T04:30:20.240461+00:00, source `be01bfe3995fdd2fa481038cf74fc5f6ef8c8689`.

Screenshots, diagrams and the original evidence package retain their source language. Captions and this document are translated into English.

[Original evidence package](https://portfolio.komaroff-dev.ru/evidence/publisher/revision-be01bfe3/materials.zip)
