Context
ATOM started as an AI assistant for entrepreneurs and grew into a large multi-module platform: around the RAG chat sit a social network, a messenger, a marketplace with escrow deals, a wallet and billing, marketing tools, and a mini-CRM. Everything is available both on the web and in native mobile apps. Under the hood — a Spring Boot monolith of 700+ Java classes (hundreds of services, repositories, and controllers) and a Next.js frontend packaged into iOS/Android via Capacitor.
AI core: RAG chat
The heart of the platform is Retrieval-Augmented Generation: answers are built on a managed knowledge base, not the model's "memory."
- Ingestion pipeline: text cleaning (jsoup) → chunking (sliding window ~512 tokens, ~100 overlap, tokenization via jtokkit) → embedding (
text-embedding-3-small) → upsert into Qdrant (max_knowledge). Sources: files (PDF/DOCX/XLSX/PPTX and more via Apache Tika), raw text, YouTube/Kinescope links with transcription. - Retrieval: query rewriting, multi-hop retrieval for complex questions, context assembly that pulls in neighboring chunks (±1), a Caffeine semantic cache, and quality monitoring (
rag-health). - Chat: sessions and history in MongoDB (
chat_sessions,chat_messages), SSE response streaming, auto-generated session titles, a "Reasoning" mode with a separate thinking stream, and user memory (business facts for personalization). - Models: an
LlmProviderabstraction over OpenAI (gpt-4o / gpt-4-turbo / gpt-3.5-turbo); Yandex GPT (Alice) is stubbed via the interface.
Content generation
- Files from answers — export an assistant reply to CSV / DOCX / PDF / XLSX (Apache POI, PDFBox).
- Images — prompt-based generation with reference images and pre-charged quota.
- Video — clip generation (duration, resolution, aspect ratio) and analysis of an uploaded video (hooks, retention, CTAs) with recommendations.
- Voice — voice-message transcription via OpenAI Whisper; a TTS layer is stubbed via interfaces.
- Attachments — file uploads to messages with automatic text extraction via Apache Tika.
Social network and messenger
A full social layer on top of the assistant:
- Profiles and networking: a profile with niches, avatar, and bio; a people directory
/social/peoplewith search and filters by city/niches/roles. - News feed
/social/newswith infinite scroll, bookmarks, and moderation. - Messenger
/social/messenger: direct and group chats, real-time over SSE (new messages, read receipts, typing indicator, online presence vialastSeenAt), unread counters (atomic$inc). Content: text, images, voice, GIFs (via Tenor), stickers (user packs + official packs), and gift links for subscriptions sent right into the chat. Notifications: visual, sound, Web Push (VAPID), and a Telegram fallback when offline. Sending is gated behind a subscription paywall. - Materials library — user content (templates, guides, checklists) with attachments and categories.
Marketplace and secure deals
- Listings
/social/marketplaceof two kinds (service / request) with categories, prices, photos, search, and filters; full CRUD on the seller's side. - Escrow deals: orders (
marketplace_orders) with an item snapshot, statuses PENDING → PAID → CONFIRMED → COMPLETED, hybrid payment (wallet + card), held funds, and a platform fee routed through a system wallet. - Disputes: disputes with admin resolution (full refund / release / partial split) and an admin review panel.
- Chat anti-fraud: an engine that scans deal messages for phishing and attempts to take payment off-platform.
Marketplace listings and the deal scaffold are implemented; the wallet, escrow, payouts, and anti-fraud are being rolled out in phases (parallel development on feature branches).
Wallet, billing, and partner program
- Wallet: balance, withdrawable balance, and holds based on a ledger model (
wallet_ledger) with idempotency and audit. - Payments: YooKassa integration — top-ups, webhooks, card tokenization, hybrid payment (balance + card).
- Subscriptions and plans: plans (Free / Pro / Premium) with chat/image/video limits and access to messenger/marketplace; one-time quota packages; a 3-day free trial on signup; a free token tier with pay-as-you-go overage; a
QuotaServicethat pre-charges quota for every AI operation. - Promo: single-use gift access codes.
- Partner program
/partner: referral links, stats, earnings and payouts, promo materials, and signup attribution.
Marketing and Growth Lab
- Campaigns
/marketing: managing ads on VK Ads and Yandex, ad groups and ads, OAuth connection of ad accounts. - AI ad generation — headlines and copy from a product description.
- Analytics: impressions/clicks/conversions/ROI (recharts), "channel → subscription/purchase" attribution, AI optimization recommendations, and an autopilot stub.
- Growth Lab: content idea generation, scriptwriting (goal × tone × format), video analysis, and experiment cycles (A/B).
Mini-CRM and amoCRM integration
- Mini-CRM: leads, custom funnel stages, an immutable stage-transition history (
agent_stage_history), per-client notes, lead-to-user conversion, and funnel metrics. - amoCRM (API v4): two-way sync of stages and contacts, OAuth with token refresh, retries with exponential backoff (Spring Retry), and a sync-event audit log.
Admin and infrastructure
- Admin: document upload and monitoring, chunk management (rechunk / merge / reindex into Qdrant), a playground for direct LLM queries with retrieval/prompt inspection, a chat-message inspector, evals (answer-quality labeling), management of models/niches/plans/packages/pricing, content moderation, and analytics (MAU, MRR, churn, cohorts).
- Authentication: Spring Security OAuth2 (Google, Yandex) + sessions in MongoDB (30 days); a mobile JWT flow.
- Performance and observability: Caffeine caching, deliberate Mongo indexes, Spring Boot Actuator (health/metrics), and retrieval-event logging.
Stack and architecture
- Backend: Java 17, Spring Boot 3.4.2, Spring AI 1.0.0 + OpenAI (gpt-4o, embeddings
text-embedding-3-small, Whisper, DALL·E), MongoDB + Qdrant, Spring Security OAuth2, Spring Session, Telegram Bot API (pengrad), YooKassa, Apache Tika/POI/PDFBox, Tenor, Web Push (VAPID). - Frontend: Next.js 16 (App Router), React 19, TypeScript, Tailwind v4, SSE streaming,
react-markdown+remark-gfm, recharts. - Mobile: Capacitor 7 — the same screens as native iOS and Android apps (
ru.getatom.app): splash, safe-area handling, OAuth via the native browser, pull-to-refresh, and a static export for the mobile build. - Deployment: same-origin on
https://getatom.ru— backend and frontend behind one domain.
Role and outcome
We owned the entire platform — backend, frontend, and mobile packaging. We designed the RAG engine and ingestion pipeline, the chat with SSE streaming and reasoning mode, image/video/file generation, the social layer with a real-time messenger, the marketplace with escrow deals, the wallet and billing with YooKassa, the marketing tools, Growth Lab, the mini-CRM with amoCRM sync, and the knowledge-base admin. The result is a single product for entrepreneurs: a controllable AI assistant, a working community, and growth tools — available both on the web and on the phone.