Skip to content

MariumShahid13/Node-javascript-sample-project

Repository files navigation

BE-App

A Node.js backend application with modular architecture, supporting user authentication, game logic, transactions, notifications, and more.

Project Structure

.
├── controllers/      # Business logic for routes
├── middleware/       # Express middleware for authentication, validation, and custom responses
├── models/           # Mongoose models for MongoDB collections
├── routes/           # Express route definitions
├── utils/            # Utility functions and helpers

Folders & Key Files

controllers/

  • admin.js: Admin-related business logic and operations.
  • affiliate.js: Affiliate system logic.
  • auth.js: Authentication logic (login, registration, password reset, etc.).
  • firebaseToken.js: Logic for managing Firebase device tokens.
  • game.js: Core game logic and operations.
  • notification.js: Notification sending and management.
  • round.js: Game round management.
  • transaction.js: Transaction processing and business logic.

middleware/

  • auth.js: Authentication and validation middleware (JWT verification, registration/login param checks, admin token checks, etc.).
  • customResponse.js: Custom response class for standardized API responses.
  • game.js: Middleware related to game logic.
  • transaction.js: Middleware for transaction validation.

models/

  • user.js: Main user schema (phone, username, password, balances, referrals, OTP, restrictions, etc.).
  • admin.js, AdminXAFLog.js: Admin and admin log schemas.
  • transaction.js, pendingTransaction.js, XAFTransfer.js: Transaction and transfer schemas.
  • game.js, round.js, userBet.js: Game, round, and betting schemas.
  • firebaseToken.js, UnregisteredUserFirebaseToken.js: Firebase device token storage.
  • balanceLog.js, ReferralRewardLog.js: Logging and reward tracking.
  • globalSetting.js: Global settings schema.

routes/

  • index.js: Main entry point, basic health check route.
  • user.js, admin.js, game.js, transaction.js, affiliate.js, firebaseToken.js, pawapaycalls.js: Route files for user management, admin, game logic, transactions, affiliate system, Firebase token management, and payment gateway callbacks.

utils/

  • common.js: Utility functions for password hashing, JWT, SMS, push notifications, and more.
  • errorCodes.js: Centralized error code definitions for consistent API responses.
  • firebase.js, firebase-adminsdk.json: Firebase admin SDK setup.
  • game.js: Game-related utility functions.
  • notificationTemplates.js: Templates for notifications.

Getting Started

  1. Install dependencies:

    npm install
  2. Set up environment variables:

    • Create a .env file with your MongoDB URI, JWT secret, Twilio credentials, and other required secrets.
  3. Run the server:

    npm start
  4. API Endpoints:

    • See the routes/ folder for available endpoints (user, admin, game, transaction, etc.).

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


License

MIT (or specify your license)

About

Modular Node.js backend for secure gaming and transactions with JWT auth, real-time alerts, and admin tools.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published