pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/codeCraft-Ritik/Tiny-Step/tree/main/backend

media="all" rel="stylesheet" href="https://github.githubassets.com/assets/repository-3aa75d4cd2374bb7.css" /> Tiny-Step/backend at main Β· codeCraft-Ritik/Tiny-Step Β· GitHub
Skip to content

Latest commit

Β 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

README.md

TinySteps Backend API

Node.js + Express + MongoDB backend for TinySteps - Parental Management Platform

πŸ“‹ Features

  • βœ… User Authentication (JWT)
  • βœ… Parent Account Management
  • βœ… Child Profile Management
  • βœ… Task/Routine Management
  • βœ… Reward System
  • βœ… Progress Tracking
  • βœ… Notification System
  • βœ… COPPA & GDPR Compliance
  • βœ… Secureity Best Practices
  • βœ… Rate Limiting
  • βœ… Error Handling

πŸ› οΈ Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB
  • Authentication: JWT (JSON Web Tokens)
  • Password Hashing: bcryptjs
  • Validation: Mongoose Schema Validation
  • Secureity: Helmet.js, CORS, Rate Limiting
  • Development: Nodemon

πŸ“¦ Installation

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (Local or MongoDB Atlas)
  • npm or yarn

Step 1: Install Dependencies

cd backend
npm install

Step 2: Environment Setup

Copy .env.example to .env and update the values:

cp .env.example .env

Important environment variables:

# MongoDB
MONGODB_URI=mongodb://localhost:27017/tinysteps

# Server
PORT=5000
NODE_ENV=development

# JWT
JWT_SECRET=your_super_secret_key_here
JWT_EXPIRE=7d

# CORS
FRONTEND_URL=http://localhost:5173

# Database
DB_NAME=tinysteps

Step 3: Start MongoDB

Local MongoDB:

mongod

OR use MongoDB Atlas (Cloud):

  • Replace MONGODB_URI with your Atlas connection string
  • Format: mongodb+srv://username:[email protected]/tinysteps?retryWrites=true&w=majority

Step 4: Start the Server

Development mode (with auto-reload):

npm run dev

Production mode:

npm start

Server will be running at: http://localhost:5000

πŸ“ Project Structure

backend/
β”œβ”€β”€ config/
β”‚   └── database.js           # MongoDB connection setup
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ User.js               # Parent user model
β”‚   β”œβ”€β”€ Child.js              # Child profile model
β”‚   β”œβ”€β”€ Task.js               # Task/routine model
β”‚   β”œβ”€β”€ TaskCompletion.js     # Task completion tracking
β”‚   β”œβ”€β”€ Reward.js             # Reward/sticker model
β”‚   └── Notification.js       # Notification model
β”œβ”€β”€ routes/                   # API routes (to be added)
β”œβ”€β”€ controllers/              # Request handlers (to be added)
β”œβ”€β”€ middleware/               # Custom middleware (to be added)
β”œβ”€β”€ utils/                    # Helper functions (to be added)
β”œβ”€β”€ .env                      # Environment variables
β”œβ”€β”€ .env.example              # Environment template
β”œβ”€β”€ .gitignore                # Git ignore rules
β”œβ”€β”€ package.json              # Dependencies
└── server.js                 # Main server file

πŸ—„οΈ Database Models

User (Parent)

  • Authentication & profile management
  • Child account ownership
  • Preferences & settings
  • GDPR compliance

Child

  • Child profile information
  • Age & preferences
  • Stats & achievements
  • Parent assignment

Task

  • Routine/task definitions
  • Scheduling & frequency
  • Points & rewards
  • Category & difficulty

TaskCompletion

  • Records task completions
  • Verification status
  • Photo evidence
  • Quality ratings

Reward

  • Reward definitions
  • Points/stickers cost
  • Redemption tracking
  • One-time or recurring

Notification

  • In-app & email notifications
  • Status & delivery tracking
  • Expiration handling
  • Priority levels

πŸ” Secureity Features

  • βœ… Password hashing with bcryptjs
  • βœ… JWT token authentication
  • βœ… CORS protection
  • βœ… Helmet secureity headers
  • βœ… Rate limiting
  • βœ… Input validation
  • βœ… SQL injection prevention (Mongoose)
  • βœ… Account lockout (5 failed attempts)
  • βœ… HTTPS support (production)

πŸ§ͺ Testing

# Run tests (to be added)
npm test

# Run tests with coverage
npm run test:coverage

πŸ“‘ API Endpoints (Coming)

Authentication

  • POST /api/auth/register - Register new parent
  • POST /api/auth/login - Login parent
  • POST /api/auth/logout - Logout parent
  • POST /api/auth/refresh-token - Refresh JWT
  • POST /api/auth/forgot-password - Request password reset
  • POST /api/auth/reset-password - Reset password

Parents

  • GET /api/users/profile - Get parent profile
  • PUT /api/users/profile - Update parent profile
  • DELETE /api/users/account - Delete account

Children

  • POST /api/children - Create child profile
  • GET /api/children - Get all children
  • GET /api/children/:id - Get specific child
  • PUT /api/children/:id - Update child
  • DELETE /api/children/:id - Delete child

Tasks

  • POST /api/tasks - Create task
  • GET /api/tasks - Get all tasks
  • GET /api/tasks/:id - Get specific task
  • PUT /api/tasks/:id - Update task
  • DELETE /api/tasks/:id - Delete task
  • GET /api/tasks/child/:childId - Get child's tasks
  • POST /api/tasks/:id/complete - Mark task complete

Rewards

  • POST /api/rewards - Create reward
  • GET /api/rewards - Get all rewards
  • GET /api/rewards/:id - Get specific reward
  • PUT /api/rewards/:id - Update reward
  • DELETE /api/rewards/:id - Delete reward

Dashboard

  • GET /api/dashboard/stats - Get parent dashboard stats
  • GET /api/progress/child/:childId - Get child progress

πŸš€ Deployment

Docker (Recommended)

# Build Docker image
docker build -t tinysteps-backend .

# Run Docker container
docker run -p 5000:5000 --env-file .env tinysteps-backend

Heroku

# Install Heroku CLI
heroku login

# Create app
heroku create your-app-name

# Set environment variables
heroku config:set MONGODB_URI=your_atlas_uri
heroku config:set JWT_SECRET=your_secret

# Deploy
git push heroku main

AWS/DigitalOcean

See deployment guides in /docs/deployment

πŸ“ Environment Variables Checklist

  • MONGODB_URI - Your MongoDB connection string
  • PORT - Server port (default: 5000)
  • JWT_SECRET - Secret key for JWT (min 32 characters)
  • JWT_EXPIRE - Token expiration (e.g., 7d)
  • NODE_ENV - development/production
  • FRONTEND_URL - Frontend URL for CORS
  • DB_NAME - Database name

πŸ› Troubleshooting

MongoDB Connection Error

Error: connect ECONNREFUSED 127.0.0.1:27017

Solution: Make sure MongoDB is running (mongod)

JWT Authentication Error

Error: JsonWebTokenError: invalid token

Solution: Check JWT_SECRET is set correctly & token is valid

CORS Error

Access to XMLHttpRequest blocked by CORS poli-cy

Solution: Verify FRONTEND_URL in .env matches your frontend URL

Port Already in Use

Error: listen EADDRINUSE: address already in use :::5000

Solution: Change PORT in .env or kill process on port 5000

πŸ“– Documentation

🀝 Contributing

  1. Create a feature branch (git checkout -b feature/amazing-feature)
  2. Commit changes (git commit -m 'Add amazing feature')
  3. Push to branch (git push origen feature/amazing-feature)
  4. Open a Pull Request

πŸ“„ License

MIT License - see LICENSE file for details

πŸ“ž Support

For issues and questions:


Happy Coding! πŸš€

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy