Skip to content

Leorev01/ProductivityApp2.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

82 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š Productivity App

A modern productivity application with separated frontend and backend architecture. Track your habits, boost your productivity, and compete with friends through gamification features.

Next.js TypeScript Tailwind CSS React Node.js Express JWT bcrypt

๐Ÿ—๏ธ Architecture

This project consists of two separate applications:

  • Frontend: Next.js 15 application with React, TypeScript, and Tailwind CSS
  • Backend: Node.js API server with Express.js for authentication, habit management, and gamification
  • Data Storage: JSON files in backend with API integration (transitioning to database)
  • Authentication: JWT-based user authentication with bcrypt password hashing

โœจ Features

Current Features โœ…

  • ๐Ÿ“ฑ Responsive Design - Seamless experience across desktop, tablet, and mobile devices
  • ๐ŸŽฏ Habit Management UI - View habits from backend API
  • โœ๏ธ Habit CRUD UI - Add, edit, and delete habit interfaces with backend integration
  • ๐Ÿ“Š Dashboard Overview - Basic dashboard layout with placeholder widgets
  • ๐Ÿ”„ Real-time Navigation - Dynamic navigation with active route highlighting
  • ๐ŸŽจ Modern UI/UX - Clean interface built with Headless UI components
  • โšก Modal Interactions - Delete confirmation and edit modals
  • ๐Ÿ” User Authentication - Registration, login with JWT tokens and password hashing
  • ๐Ÿ“ง Email Service Backend - Express server for email functionality
  • ๐Ÿท๏ธ Habit Completion Tracking - In-memory tracking that resets on page refresh
  • ๐ŸŽฎ Gamification Foundation - User scoring system for habit completion tracking

Planned Features ๐Ÿšง

  • ๐Ÿ† Competitive Leaderboards - Compare productivity scores with friends and global users
  • ๐Ÿ”ฅ Streak Tracking - Long-term habit completion streaks with visual indicators
  • ๐Ÿ“ˆ Productivity Scoring - Points-based system for habit completion and consistency
  • ๐Ÿ‘ฅ Friend System - Add friends and compete in productivity challenges
  • ๐ŸŽ–๏ธ Achievement Badges - Unlock badges for milestones and consistent habits
  • ๐Ÿ“Š Analytics Dashboard - Habit statistics, progress charts, and productivity insights
  • ๐ŸŽฏ Challenges & Goals - Create and join productivity challenges with friends
  • ๐Ÿ“ฑ Push Notifications - Habit reminders and friend activity updates
  • ๐Ÿ’พ Database Integration - Replace JSON files with PostgreSQL/MongoDB
  • ๐Ÿ“ค Data Export/Import - Backup and restore functionality
  • ๐Ÿ“ฑ Mobile App - React Native companion with full gamification

๐ŸŽฎ Gamification System

Scoring Mechanics

  • Daily Completion: +10 points per habit completed
  • Streak Bonuses: +5 extra points for each day in streak (max +50/day)
  • Perfect Days: +25 bonus points for completing all habits
  • Weekly Challenges: +100 points for weekly goal completion
  • Monthly Milestones: +500 points for consistency achievements

Social Features

  • Friend Leaderboards: See how you rank against your friends
  • Global Rankings: Compete with users worldwide
  • Achievement Sharing: Share badges and milestones on social media
  • Group Challenges: Team up with friends for group productivity goals
  • Progress Comparison: Visual charts comparing your progress with friends

Engagement Features

  • Daily Streaks: Visual streak counters with fire emojis ๐Ÿ”ฅ
  • Level System: Progress through productivity levels (Beginner โ†’ Expert โ†’ Master)
  • Seasonal Events: Special challenges during holidays and events
  • Productivity Insights: Weekly reports showing improvement areas

๐Ÿš€ Tech Stack

Frontend Technologies

Backend Technologies

  • Node.js - JavaScript runtime
  • Express.js 5 - Web application framework
  • JWT - JSON Web Tokens for authentication
  • bcrypt - Password hashing and security
  • CORS - Cross-origin resource sharing
  • dotenv - Environment variable management
  • Nodemon - Development auto-restart

Development Tools

  • ESLint - Code linting and formatting
  • PostCSS - CSS processing and optimization

Data Storage

  • Backend JSON Storage - User and habit data stored in backend/data/
  • Frontend API Integration - Frontend communicates with backend API
  • JWT Authentication - Secure user sessions with token-based auth
  • Password Security - bcrypt hashing for user passwords
  • Future Database - Planned migration to PostgreSQL/MongoDB

๐Ÿ“ Project Structure

productivity-app/
โ”œโ”€โ”€ frontend/                     # Next.js Frontend Application
โ”‚   โ”œโ”€โ”€ app/                     # Next.js App Router
โ”‚   โ”‚   โ”œโ”€โ”€ (auth)/              # Authenticated routes
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ dashboard/       # Dashboard pages
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ habits/      # Habit management
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ add/     # Add habit page
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ edit/    # Edit habit pages
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ calendar/    # Calendar page
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ leaderboard/ # Friend rankings (planned)
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ layout.tsx   # Dashboard layout
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ page.tsx     # Dashboard home
โ”‚   โ”‚   โ”œโ”€โ”€ login/               # Login page
โ”‚   โ”‚   โ”œโ”€โ”€ signup/              # Signup page
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx           # Root layout
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx             # Landing page
โ”‚   โ”‚   โ””โ”€โ”€ globals.css          # Global styles
โ”‚   โ”œโ”€โ”€ components/              # Shared React components
โ”‚   โ”‚   โ”œโ”€โ”€ Habits/              # Habit-related components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Habit.tsx        # Individual habit card
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ HabitsPage.tsx   # Habits page container
โ”‚   โ”‚   โ”œโ”€โ”€ Gamification/        # Gamification components (planned)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Leaderboard.tsx  # Friend rankings
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ScoreDisplay.tsx # User score widget
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ StreakCounter.tsx# Streak visualization
โ”‚   โ”‚   โ”œโ”€โ”€ Navbar.tsx           # Navigation component
โ”‚   โ”‚   โ””โ”€โ”€ Home/                # Landing page components
โ”‚   โ”œโ”€โ”€ types/                   # TypeScript definitions
โ”‚   โ”‚   โ”œโ”€โ”€ habit.ts             # Habit type definitions
โ”‚   โ”‚   โ”œโ”€โ”€ user.ts              # User and auth types
โ”‚   โ”‚   โ””โ”€โ”€ types.ts             # General type definitions
โ”‚   โ”œโ”€โ”€ utils/                   # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ habits.json          # Static habit data (legacy)
โ”‚   โ”‚   โ”œโ”€โ”€ habitFunctions.ts    # Habit manipulation functions
โ”‚   โ”‚   โ”œโ”€โ”€ users.json           # Static user data (legacy)
โ”‚   โ”‚   โ”œโ”€โ”€ userFunctions.ts     # User utility functions
โ”‚   โ”‚   โ””โ”€โ”€ auth.ts              # Authentication helpers
โ”‚   โ”œโ”€โ”€ public/                  # Static assets
โ”‚   โ””โ”€โ”€ package.json             # Frontend dependencies
โ”œโ”€โ”€ backend/                      # Node.js Backend API
โ”‚   โ”œโ”€โ”€ controllers/             # Business logic controllers
โ”‚   โ”‚   โ”œโ”€โ”€ authController.ts    # User registration and login
โ”‚   โ”‚   โ”œโ”€โ”€ userController.ts    # User profile management
โ”‚   โ”‚   โ”œโ”€โ”€ emailController.ts   # Email handling logic
โ”‚   โ”‚   โ””โ”€โ”€ habitController.ts   # Habit CRUD operations
โ”‚   โ”œโ”€โ”€ routes/                  # API route definitions
โ”‚   โ”‚   โ”œโ”€โ”€ auth.ts              # Authentication endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ users.ts             # User management endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ email.ts             # Email endpoints
โ”‚   โ”‚   โ””โ”€โ”€ habits.ts            # Habit endpoints
โ”‚   โ”œโ”€โ”€ models/                  # Data models and types
โ”‚   โ”‚   โ”œโ”€โ”€ User.ts              # User interface definitions
โ”‚   โ”‚   โ””โ”€โ”€ Habit.ts             # Habit interface definitions
โ”‚   โ”œโ”€โ”€ data/                    # JSON data storage
โ”‚   โ”‚   โ”œโ”€โ”€ users.json           # User data with scores and streaks
โ”‚   โ”‚   โ””โ”€โ”€ habits.json          # Habit data persistence
โ”‚   โ”œโ”€โ”€ index.ts                 # Main Express server
โ”‚   โ””โ”€โ”€ package.json             # Backend dependencies
โ”œโ”€โ”€ issue.md                     # Development task tracking
โ”œโ”€โ”€ .gitignore                   # Git ignore rules
โ””โ”€โ”€ README.md                    # This documentation

๐Ÿƒโ€โ™‚๏ธ Getting Started

Prerequisites

  • Node.js 18+ installed on your machine
  • npm or yarn package manager

Installation

  1. Clone the repository
git clone https://github.com/Leorev01/ProductivityApp2.0
cd productivity-app
  1. Install dependencies for both frontend and backend

Frontend:

cd frontend
npm install

Backend:

cd ../backend
npm install
  1. Set up environment variables

Backend (.env file):

# Create backend/.env
PORT=4000
JWT_SECRET=your-super-secret-jwt-key-here
NODE_ENV=development
  1. Run the applications

Start the backend server (Terminal 1):

cd backend
node index.ts
# Backend will run on http://localhost:4000

Start the frontend development server (Terminal 2):

cd frontend
npm run dev
# Frontend will run on http://localhost:3000
  1. Open your browser

๐ŸŽฎ Available Scripts

Frontend Scripts (frontend/)

npm run dev             # Development server (port 3000)
npm run build           # Production build
npm run start           # Production server
npm run lint            # Code linting

Backend Scripts (backend/)

node index.ts           # Start server (port 4000)
# Note: No dev script configured yet

๐Ÿ”Œ API Documentation

Authentication Endpoints

Method Endpoint Description Status
POST /api/auth/register Register new user โœ… Implemented
POST /api/auth/login User login with JWT โœ… Implemented

User Endpoints

Method Endpoint Description Status
GET /api/users/profile Get user profile โœ… Implemented
PUT /api/users/profile Update user profile ๐Ÿšง In Progress
GET /api/users/leaderboard Get friend rankings ๐Ÿšง Planned

Habit Endpoints

Method Endpoint Description Status
GET /api/habits Get all habits โœ… Implemented
POST /api/habits Create new habit ๐Ÿšง In Progress
PUT /api/habits/:id Update existing habit ๐Ÿšง In Progress
DELETE /api/habits/:id Delete habit ๐Ÿšง In Progress

Email Endpoints

Method Endpoint Description Status
POST /api/email/send-email Send email with habit data โœ… Implemented

Sample API Requests

Register user:

curl -X POST http://localhost:4000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepassword123"
  }'

Login user:

curl -X POST http://localhost:4000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepassword123"
  }'

Get habits (authenticated):

curl -X GET http://localhost:4000/api/habits \
  -H "Authorization: Bearer your-jwt-token-here"

Response Examples:

// Registration/Login Success
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": 1,
    "email": "[email protected]"
  }
}

// Habits Response
{
  "habits": [
    {
      "id": 1,
      "userId": 1,
      "title": "Morning Exercise",
      "description": "30 minutes of cardio",
      "createdAt": "2025-01-01"
    }
  ]
}

๐Ÿ—๏ธ Architecture Highlights

Frontend-Backend Integration

  • Complete Separation: Frontend and backend are independent applications
  • JWT Authentication: Secure token-based authentication system
  • API Communication: Frontend calls backend REST API endpoints
  • Real-time Updates: Planned WebSocket integration for live leaderboards

Security Features

  • Password Hashing: bcrypt with salt rounds for secure password storage
  • JWT Tokens: Secure session management with expiration
  • Input Validation: Server-side validation for all user inputs
  • CORS Protection: Configured for secure cross-origin requests

Gamification Architecture

  • User Scoring System: Points tracked per user with daily/weekly calculations
  • Streak Tracking: Consecutive day counters for habit completion
  • Social Features: Friend relationships and competitive leaderboards
  • Achievement System: Badge unlocking based on user milestones

Data Flow

Frontend (React) โ†” Backend API (Express) โ†” JSON Storage โ†’ Future Database
                    โ†“
               JWT Authentication
                    โ†“
              Gamification Engine

๐ŸŽฏ Gamification Features in Detail

Scoring System

interface UserScore {
  userId: number;
  totalPoints: number;
  dailyPoints: number;
  weeklyPoints: number;
  currentStreak: number;
  longestStreak: number;
  level: number;
  badges: Badge[];
}

Achievement Badges

  • ๐Ÿ”ฅ Streak Master: 30-day habit streak
  • โญ Perfect Week: Complete all habits for 7 days
  • ๐Ÿš€ Quick Starter: Complete habits for first 7 days
  • ๐Ÿ’ช Consistency Champion: 90% habit completion over 30 days
  • ๐Ÿ† Leaderboard Leader: Top 10 in weekly rankings

Competitive Features

  • Daily Challenges: Complete specific habit combinations
  • Weekly Competitions: Compete with friends on weekly scores
  • Seasonal Events: Special challenges during holidays
  • Team Challenges: Group competitions with shared goals

๐Ÿš€ Deployment

Environment Variables

Frontend:

NEXT_PUBLIC_API_URL=https://your-backend-url.com/api

Backend:

PORT=4000
NODE_ENV=production
JWT_SECRET=your-production-jwt-secret
DATABASE_URL=your-database-connection-string

Production Deployment

  • Frontend: Vercel (recommended for Next.js)
  • Backend: Railway, Heroku, or DigitalOcean
  • Database: PostgreSQL (recommended for production)
  • File Storage: AWS S3 for user-uploaded content

๐Ÿ”ฎ Future Enhancements

Core Features

  • PostgreSQL Integration - Replace JSON files with proper database
  • Real-time WebSockets - Live leaderboard updates and friend activity
  • Advanced Analytics - Detailed productivity insights and trends
  • Mobile Push Notifications - Habit reminders and social updates

Gamification Expansion

  • Guild System - Create and join productivity communities
  • Seasonal Championships - Monthly and yearly competitions
  • Custom Challenges - User-created challenge templates
  • Reward Store - Spend points on virtual rewards and real-world prizes
  • Social Feed - Activity streams showing friend achievements
  • Mentorship Program - Connect experienced users with beginners

Advanced Features

  • AI Habit Recommendations - Machine learning for personalized suggestions
  • Integration APIs - Connect with fitness trackers and other apps
  • Habit Templates - Pre-built habit sets for common goals
  • Progress Photos - Visual progress tracking with image uploads
  • Calendar Integration - Sync with Google Calendar and other services
  • Data Analytics - Advanced reporting and trend analysis

๐Ÿ› ๏ธ Development

Development Workflow

  1. Start backend server with cd backend && node index.ts (port 4000)
  2. Start frontend server with cd frontend && npm run dev (port 3000)
  3. Frontend automatically reloads on file changes
  4. Backend requires manual restart on changes (TypeScript compilation)
  5. Authentication fully functional with registration and login

Current Implementation Status

โœ… Completed:

  • User registration and login with JWT
  • Password hashing with bcrypt
  • Basic habit management UI
  • Backend API structure
  • Frontend-backend communication

๐Ÿšง In Progress:

  • Complete habit CRUD operations
  • User profile management
  • Frontend authentication integration

๐Ÿ“‹ Planned:

  • Friend system and social features
  • Leaderboards and scoring system
  • Achievement badges
  • Database migration

๐Ÿค Contributing

Priority Development Areas

  1. Gamification System - Implement scoring, streaks, and achievements
  2. Friend System - Social features and friend management
  3. Database Migration - Move from JSON to PostgreSQL/MongoDB
  4. Mobile App - React Native companion app
  5. Real-time Features - WebSocket integration for live updates

Development Guidelines

  • Follow TypeScript best practices
  • Implement proper error handling
  • Add comprehensive testing
  • Maintain security best practices
  • Update documentation for new features
  • Consider scalability in architecture decisions

Getting Involved

  1. Backend Development - API endpoints and business logic
  2. Frontend Development - React components and UI/UX
  3. Gamification Design - Scoring systems and achievement mechanics
  4. Mobile Development - React Native app development
  5. DevOps - Deployment and infrastructure setup

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ“ž Support

If you have any questions or run into issues:

  • Open an issue on GitHub
  • Join our Discord community (coming soon)
  • Check out the documentation wiki

Current Status: Active development with authentication system implemented. Gamification features and social competitive elements are the next major milestone. The app is transitioning from JSON storage to a full database solution.

Built with โค๏ธ for the productivity community. Let's make habit building fun and social! ๐Ÿš€

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages