Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Environment Variables for DMS
# Copy this file to .env and fill in your actual credentials

# Server Configuration
PORT=3001
NODE_ENV=development

# Database
DB_PATH=./database/dms.db

# JWT Secret (generate a secure random string)
JWT_SECRET=your-super-secure-jwt-secret-here

# Twilio Configuration
TWILIO_ACCOUNT_SID=your-twilio-account-sid
TWILIO_AUTH_TOKEN=your-twilio-auth-token
TWILIO_PHONE_NUMBER=your-twilio-phone-number

# Firebase Configuration
FIREBASE_PROJECT_ID=your-firebase-project-id
FIREBASE_CLIENT_EMAIL=your-firebase-client-email
FIREBASE_PRIVATE_KEY=your-firebase-private-key

# Notification Settings
DEFAULT_REMINDER_MINUTES=30
MAX_TASK_DURATION_DAYS=365
DEFAULT_TASK_DURATION_DAYS=98
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Environment files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Database
database/
*.db
*.sqlite

# Logs
logs/
*.log

# Firebase service account key
firebase-service-account.json

# Build outputs
build/
dist/
.build/

# IDE files
.vscode/
.idea/
*.swp
*.swo

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Temporary files
tmp/
temp/
.tmp/

# Coverage directory used by tools like istanbul
coverage/
.nyc_output/

# Runtime data
pids/
*.pid
*.seed
*.pid.lock
43 changes: 43 additions & 0 deletions FIREBASE_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Firebase Admin SDK Setup Guide

To complete the Firebase Push notification setup, you need to generate a Firebase Admin SDK service account key:

## Steps to get Firebase Admin SDK credentials:

1. Go to the [Firebase Console](https://console.firebase.google.com/)
2. Select your project: `brits-academy`
3. Click the gear icon ⚙️ → "Project settings"
4. Go to the "Service accounts" tab
5. Click "Generate new private key"
6. Download the JSON file

## Extract the required values from the downloaded JSON:

```json
{
"type": "service_account",
"project_id": "brits-academy",
"private_key_id": "...",
"private_key": "-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-xxxxx@brits-academy.iam.gserviceaccount.com",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
...
}
```

## Update the .env file:

```env
FIREBASE_PROJECT_ID=brits-academy
FIREBASE_CLIENT_EMAIL=firebase-adminsdk-xxxxx@brits-academy.iam.gserviceaccount.com
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----"
```

## Current Status:

✅ **Twilio SMS**: Fully configured and working
⚠️ **Firebase Push**: Needs service account private key to complete setup

The client-side Firebase config you provided is used for web apps, but the server needs Admin SDK credentials for sending push notifications.
210 changes: 208 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,208 @@
# DMS
This is a discipline management system for tracking progress and managing tasks to ensure you stick to your plan
# DMS - Discipline Management System

This is a comprehensive discipline management system for tracking progress and managing tasks to ensure you stick to your plan. The system features dual notification support with **Twilio SMS** and **Firebase Push Notifications** to help maintain discipline and track progress.

## 🌟 Features

### Core Functionality
- **Task Management**: Create tasks with custom duration (default 98 days for habit formation)
- **Checklist System**: Add multiple checklist items to track daily progress
- **Flexible Scheduling**: Schedule reminders at specific times throughout the day
- **Progress Tracking**: Visual progress charts and completion statistics
- **Task Status Management**: Active, Completed, Failed, and Paused statuses

### Notification System
- **Twilio SMS**: Send SMS reminders and updates to user's phone
- **Firebase Push**: Send push notifications to web/mobile devices
- **Smart Scheduling**: Automatic reminder system based on user-defined schedules
- **Status Notifications**: Completion celebrations and deadline alerts

### User Experience
- **Modern React Frontend**: Clean, responsive UI built with TypeScript
- **Real-time Updates**: Live progress tracking and status updates
- **Mobile-Friendly**: Responsive design that works on all devices
- **Timezone Support**: Proper timezone handling for international users

## 🏗️ Architecture

### Backend (Node.js/Express)
- **Authentication**: JWT-based user authentication
- **Database**: SQLite with comprehensive schema for tasks, users, and progress
- **Scheduling**: Cron-based task reminder system
- **Notifications**: Integrated Twilio SMS and Firebase Cloud Messaging
- **API**: RESTful API with comprehensive error handling

### Frontend (React/TypeScript)
- **Modern Stack**: React 19, TypeScript, React Router
- **State Management**: Context API for authentication
- **UI Components**: Custom components with Lucide icons
- **Responsive Design**: Mobile-first design approach

### Database Schema
- **Users**: Authentication and profile management
- **Tasks**: Task details with duration and status tracking
- **Checklist Items**: Individual task components with completion tracking
- **Daily Schedules**: Flexible reminder scheduling system
- **Task Progress**: Historical progress tracking
- **Notification Logs**: Audit trail for all notifications

## 🚀 Quick Start

### Prerequisites
- Node.js 18+ and npm
- Twilio account (for SMS notifications)
- Firebase project (for push notifications)

### Installation

1. **Clone and Install**
```bash
git clone <repository-url>
cd DMS
npm run install:all
```

2. **Environment Setup**
```bash
cp .env.example .env
```

Edit `.env` with your credentials:
```env
# Server Configuration
PORT=3001
NODE_ENV=development
JWT_SECRET=your-secure-jwt-secret

# Twilio Configuration
TWILIO_ACCOUNT_SID=your-twilio-account-sid
TWILIO_AUTH_TOKEN=your-twilio-auth-token
TWILIO_PHONE_NUMBER=your-twilio-phone-number

# Firebase Configuration
FIREBASE_PROJECT_ID=your-firebase-project-id
FIREBASE_CLIENT_EMAIL=your-firebase-client-email
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END PRIVATE KEY-----\n"
```

3. **Start Development**
```bash
# Terminal 1 - Start backend server
npm run dev:server

# Terminal 2 - Start frontend development server
npm run dev:client
```

4. **Access the Application**
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001

### Production Deployment

1. **Build the application**
```bash
npm run build
```

2. **Start production server**
```bash
npm start
```

## 📱 Usage Guide

### Getting Started
1. **Register/Login**: Create an account or sign in
2. **Update Profile**: Add phone number for SMS notifications
3. **Create Your First Task**: Set title, description, and duration
4. **Add Checklist Items**: Break down your task into manageable items
5. **Schedule Reminders**: Set times for daily notifications
6. **Track Progress**: Mark items complete and monitor your discipline

### Task Management
- **Duration**: Default 98 days (research-backed habit formation period)
- **Checklist**: Add as many items as needed for daily tracking
- **Schedules**: Multiple reminder times per day with flexible day-of-week selection
- **Status**: Automatic status updates based on completion and deadlines

### Notifications
- **SMS**: Receive text messages with task reminders and progress updates
- **Push**: Web/mobile push notifications for immediate alerts
- **Testing**: Built-in notification testing interface
- **Logging**: Complete audit trail of all notifications sent

## 🛠️ API Endpoints

### Authentication
- `POST /api/auth/register` - User registration
- `POST /api/auth/login` - User login
- `GET /api/auth/profile` - Get user profile
- `PUT /api/auth/profile` - Update user profile

### Tasks
- `GET /api/tasks` - List user tasks
- `POST /api/tasks` - Create new task
- `GET /api/tasks/:id` - Get task details
- `PUT /api/tasks/:id` - Update task
- `DELETE /api/tasks/:id` - Delete task
- `PUT /api/tasks/:id/checklist/:itemId` - Update checklist item
- `GET /api/tasks/:id/progress` - Get task progress

### Notifications
- `GET /api/notifications/status` - Check service availability
- `POST /api/notifications/test/sms` - Test SMS functionality
- `POST /api/notifications/test/push` - Test push notifications

## 🔧 Configuration

### Twilio Setup
1. Sign up for Twilio account
2. Get Account SID and Auth Token from console
3. Purchase phone number for sending SMS
4. Add credentials to `.env` file

### Firebase Setup
1. Create Firebase project
2. Enable Firebase Cloud Messaging
3. Generate service account key
4. Add credentials to `.env` file

### Scheduling
- **Reminder Checks**: Run every minute to check for scheduled notifications
- **Daily Updates**: Midnight task status updates and deadline checks
- **Cleanup**: Weekly cleanup of old logs and completed task data

## 🎯 Discipline System

The DMS follows proven principles of habit formation and discipline building:

1. **98-Day Default**: Based on research showing habit formation takes 2-254 days (average 98)
2. **Daily Tracking**: Break large goals into daily, manageable actions
3. **Consistent Reminders**: Multiple touchpoints throughout the day
4. **Progress Visualization**: Clear progress indicators and completion tracking
5. **Failure Recovery**: Support for pausing and restarting tasks without penalty

## 🤝 Contributing

1. Fork the repository
2. Create feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open Pull Request

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🆘 Support

For issues and questions:
1. Check the notification testing interface at `/notifications/test`
2. Review server logs for configuration issues
3. Ensure all environment variables are properly set
4. Verify Twilio and Firebase credentials are correct

---

**Start your discipline journey today with DMS!** 💪
23 changes: 23 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Loading