How izecrypt/fashionton-backend works
Purpose and Deployment Shape
FashionTON Wardrobe is a Telegram Mini App for managing clothing, assembling outfits, entering social style challenges, and receiving size recommendations. The active deployment appears to be a static JavaScript frontend plus Vercel serverless APIs, configured through vercel.json. A separate Express backend deployment option exists under backend/server.js, with Railway/Render deployment descriptors.
Frontend Application Shell
The client is vanilla HTML/CSS/JavaScript rather than a framework application. src/index.html is the source shell; public/index.html and public/ appear to be the deployable built/copy artifact. Application startup, state, and API integration are separated across:
• src/js/app.js
• src/js/store.js
• src/js/api-client.js
The browser client loads screens and shared UI behavior, then calls same-origin /api/* endpoints. Telegram embedding and TON wallet integration are product concerns described by the README, though no TON-specific source file is present in this tree.
User-Facing Feature Screens
Feature modules divide the primary user journeys:
• Wardrobe browsing and garment organization: src/screens/wardrobe.js, src/components/image-upload.js
• Outfit composition/try-on-facing experience: src/screens/outfits.js, src/components/item-modal.js
• Challenge viewing and participation: src/screens/challenges.js
These screens consume centralized client state and the API client rather than directly owning persistence. Shared visual system assets are in src/styles/main.css and src/styles/glass.css.
Serverless API Boundary
The current api/ directory is a flattened Vercel-function surface, with common infrastructure modules:
• Authentication/request identity: api/_auth.js
• Database access: api/_db.js
• Cloudinary media integration: api/_cloudinary.js
Primary handlers are api/wardrobe.js, api/challenges.js, api/user.js, api/leaderboard.js, and api/size-calculator.js. These functions form the trust boundary: browser requests should be authenticated, data-scoped to the Telegram user, and then persisted or sent to external services.
Wardrobe and Media Flow
Users select/upload clothing through the UI component, submit wardrobe mutations to api/wardrobe.js, and retrieve the resulting wardrobe for screen rendering. Server-side media handling is intended to use Cloudinary via api/_cloudinary.js; database records are managed behind api/_db.js. The older, more granular implementation retains an explicit upload-signature endpoint at api-backup/upload/signature.js, which suggests direct client-to-Cloudinary upload support may have existed before API consolidation.
Challenge and Gamification Flow
Challenge activity is currently consolidated into api/challenges.js; its backup counterpart shows the intended stages: challenge lookup, entry submission, voting, and winner selection:
• api-backup/challenges/index.js
• api-backup/challenges/entry.js
• api-backup/challenges/vote.js
Leaderboard data is exposed separately through api/leaderboard.js. A scheduled daily challenge/winner process is represented only in the backup structure at api-backup/cron/challenge.js; production scheduling must be explicitly restored/configured if automatic challenge lifecycle processing is required.
Data, Identity, and External Services
Material infrastructure is Vercel serverless hosting, a database abstracted by api/_db.js, and Cloudinary for garment/challenge images. Telegram supplies the Mini App runtime and likely user identity, validated by api/_auth.js. TON Connect and TON payments are product-level integrations described in the README, but no current API payment handler or blockchain implementation is present in api/; treat payment verification/reward distribution as a missing or external subsystem.
Parallel/Legacy Implementations
api-backup/ contains a fuller route-oriented API and should be treated as a reference or migration source, not assumed live. backend/ is an alternate Node/Express hosting path with its own package manifest and deployment setup. Maintaining both Vercel functions and Express routes risks behavioral drift; select one authoritative backend surface before expanding features.
Main entry points: app.js App startup · _db.js Database access · _auth.js Request authentication · api-client.js API client
Components 20
Mini App Client
- Client shell
src/index.html - App startup
src/js/app.js - Client store
src/js/store.js - API client
src/js/api-client.js - Wardrobe and upload
src/screens/wardrobe.js - Outfit experience
src/screens/outfits.js - Challenges
src/screens/challenges.js
Vercel API
- Vercel deployment
vercel.json - Request authentication · Validates and scopes requests to Telegram users.
api/_auth.js - Wardrobe API
api/wardrobe.js - Challenges API · Consolidates challenge activity.
api/challenges.js - User API
api/user.js - Leaderboard API
api/leaderboard.js - Size calculator API
api/size-calculator.js - Database access
api/_db.js - Cloudinary adapter
api/_cloudinary.js
External Services
- Telegram Mini App · Supplies the embedded runtime and user identity.
- Cloudinary
Alternate / Legacy
Reference implementations not assumed live.
- Route-oriented API backup · Contains granular challenge and upload routes.
api-backup/challenges/index.js - Express backend option · Separate backend path that can drift from Vercel functions.
backend/server.js
Connections 23
- Telegram Mini App → Client shell: embeds
- Client shell → App startup: starts
- App startup → Client store: manages
- App startup → Wardrobe and upload: loads
- App startup → Outfit experience: loads
- App startup → Challenges: loads
- Wardrobe and upload → API client: uses
- Outfit experience → API client: uses
- Challenges → API client: uses
- API client → Vercel deployment: /api requests
- Vercel deployment → Request authentication: invokes
- Request authentication → Wardrobe API: authorizes
- Request authentication → Challenges API: authorizes
- Request authentication → User API: authorizes
- Wardrobe API → Database access: stores garments
- Wardrobe API → Cloudinary adapter: handles media
- Challenges API → Database access: stores entries and votes
- User API → Database access: reads and writes users
- Leaderboard API → Database access: reads rankings
- Size calculator API → Database access: uses user data
- Cloudinary adapter → Cloudinary: uploads media
- Route-oriented API backup → Challenges API: migration reference
- Express backend option → Vercel deployment: alternative to