How umutkarakas34/fruittelegrambot works
Project type and purpose
• Full-stack, play-to-earn web game with Telegram Bot integration.
• Frontend: React SPA (fruit-slicing game UI, pages, components).
• Backend: Node.js/Express API + Telegram Bot process + game logic + user/auth controllers.
• Persistent storage for users, games, tasks, referrals, daily check-ins, tokens, etc.
File structure for major components
• Frontend
– “frontend/fruit-slicing-game/src” contains React UI (App.js, pages, components, styles).
– “src/api/api.js” wraps HTTP calls to backend.
– Public assets in “public/” (HTML entry, images, audio).
• Backend
– “backend/app.js”: main Express app.
– “backend/bot.js”: Telegram Bot listener.
– “controllers/”: HTTP controllers for admin/user flows.
– “routes/”: routes wired to controllers.
– “middleware/”: authentication for users/admins.
– “models/”: MongoDB/Mongoose models (user, game, tasks, referrals, etc.).
– “utility/db.js”: DB connection.
– “upload.js”: file-upload handling.
– “.env” + “web.config” for deployment settings.
README for extra context
• Game logic and play-to-earn token conversion live in backend.
• Telegram Bot endpoints tie into same business layer.
• Frontend is standalone; backend still under active development.
Main components
• User Interfaces
– Web Browser (plays React game)
– Telegram Client (plays via Bot)
• Frontend SPA (React)
• Backend API (Express)
• Telegram Bot Process (bot.js)
• Database (MongoDB/other)
• External Services
– Telegram Bot API
– (Optional) Cloud storage/CDN for static files
– (Optional) Token/Crypto service if real tokens are minted
Relationships and data flows
• Browser → React SPA → HTTP(S) → Express API → DB
• Telegram Client → Telegram API → bot.js → Express controllers → DB
• Express may push notifications back via Telegram API for in-game events.
• Frontend polls or uses WebSockets (if implemented) to fetch game state.
Architectural patterns & design principles
• Three-tier architecture: Presentation (React), Application (Express + Bot), Data (MongoDB).
• MVC within backend: routes → controllers → models.
• Separation of concerns: auth middleware, file upload module, utility module.
• Environment-based config via .env.
Technology stack to annotate
• Frontend: React, Create-React-App, CSS modules.
• Backend: Node.js, Express, Mongoose (MongoDB ODM).
• Telegram Bot API (tdlib or node-telegram-bot-api).
• Authentication: JWT or session tokens (middleware).
• Deployment: IIS/Azure (“web.config”), PM2 (“ecosystem.config.js” in frontend), static host/CDN.
• All components clearly labeled.
• Brief notes on protocols, ports, or configs (e.g., port 3000 for Express).
• Critical paths: game play → scoring → token conversion → payout.