How anuragfrantic/pocker_tracker_backendmysql works
Project Type and Purpose
• This is a RESTful backend service built with Node.js/Express and MySQL.
• It manages poker game data (users, game sessions, transactions, chips) and provides authenticated API endpoints for CRUD operations and uploads.
File Structure
• Top-level:
• poker.js – entry point (Express app bootstrap)
• config/ – database (config/config.json, config/db.js) & environment
• controllers/ – route handlers implementing business logic
• routes/ – Express routers mapping endpoints to controllers
• middleware/ – Auth (JWT) & file-upload logic
• models/ – Sequelize or raw models defining tables & relations
• uploads/ – persistent storage for CSV uploads
• Patterns:
• MVC-style layering: routes → controllers → models
• Centralized config and env loading
• JWT-based stateless auth middleware
• Deployment:
README for Extra Context
• Technologies: Node.js, Express, MySQL, dotenv, bcryptjs, jsonwebtoken
• DB Schema: users, games, transactions, tables, chips and their relations
• Key API endpoints for users, games, transactions, chips
Main Components & Their Interactions
a. Client / External Consumer
• A frontend or third-party tool sends HTTP requests to your REST API.
b. Express API Server (Node.js)
• Entry Point (poker.js): loads .env, connects DB, mounts middleware, routes.
• Middleware Layer:
• Auth Middleware (verifies JWT)
• upload Middleware (handles CSV multipart requests)
• Routing Layer:
• authroutes.js, userRoutes.js, masterRoutes.js
• Controller Layer:
• Implements the logic per resource (UserController, GameController, etc.)
• Model Layer:
• ORM definitions (models/User.js, models/Games.js, etc.)
• index.js ties models and relations
c. MySQL Database
• Stores tables as defined in models.
• config/db.js manages the connection pool.
d. File Storage
• uploads/ folder holds CSV files; controllers reference these for bulk data import.
e. External Services
• bcryptjs for hashing passwords
• jsonwebtoken for JWT issuance/validation
• dotenv for config management
Architectural Patterns & Principles
• MVC separation for maintainability
• Layered architecture (HTTP → routing → auth/middleware → controllers → models → DB)
• Single responsibility per controller
• Stateless authentication (JWT)
• Config-driven environment management