Skip to content

Creates a console app through c# that allows users to create habits, mark them as completed and send daily email reminders based on the users selected time

Notifications You must be signed in to change notification settings

Leorev01/Habits_Builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“… Habit Tracker App

A comprehensive C# console application to help you build and maintain daily habits. Track streaks, view progress history, receive daily email reminders, and sync your habits with Google Calendar for seamless integration across all your devices.


โœจ Features

  • โœ… Add and delete daily habits
  • ๐Ÿ“ˆ View current streaks and habit history
  • โœ… Mark habits as completed
  • โฐ Schedule daily email reminders
  • ๐Ÿ“… Google Calendar integration - Sync habits as all-day events
  • ๐Ÿ’พ Data persistence using local file storage
  • ๐ŸŽจ Dark Mode support (See: THEME_SERVICE.md)
  • ๐ŸŒ Multi-language support with runtime language switching

๐Ÿš€ Getting Started

๐Ÿ”ง Requirements


๐Ÿ“ฅ Installation

  1. Clone this repository
git clone https://github.com/Leorev01/Habits_Builder.git
cd habit-tracker-app
  1. Restore dependencies
dotnet restore
  1. Build the application
dotnet build

โš™๏ธ Configuration

๐Ÿ“ง Email Setup (Optional)

  1. Create a .env file in the project root:
GOOGLE_APP_EMAIL=[email protected]
GOOGLE_APP_PASSWORD=your-app-password
  1. Enable App Passwords in your Gmail account:
    • Go to Google Account Settings
    • Security โ†’ 2-Step Verification โ†’ App passwords
    • Generate a new app password for "Habit Tracker"

๐Ÿ“… Google Calendar Setup (Optional)

Quick Setup with Mock File

  1. Create a mock credentials.json file in your project root:
{
  "installed": {
    "client_id": "YOUR_CLIENT_ID_HERE.apps.googleusercontent.com",
    "project_id": "your-project-id",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "YOUR_CLIENT_SECRET_HERE",
    "redirect_uris": ["http://localhost"]
  }
}
  1. Replace with your actual credentials (see detailed setup below)

Detailed Google Cloud Console Setup

  1. Go to Google Cloud Console

  2. Create a new project

    • Click "New Project"
    • Name it "Habit Tracker"
    • Click "Create"
  3. Enable Google Calendar API

    • Go to APIs & Services โ†’ Library
    • Search for "Google Calendar API"
    • Click "Enable"
  4. Create OAuth 2.0 credentials

    • Go to APIs & Services โ†’ Credentials
    • Click "Create Credentials" โ†’ "OAuth client ID"
    • Configure OAuth consent screen (External user type)
    • Fill required fields:
      • App name: "Habit Tracker"
      • User support email: your email
      • Add your email to test users
    • Choose "Desktop application" as application type
    • Name it "Habit Tracker Desktop"
    • Click "Create"
  5. Download and replace credentials

    • Click the download button (โฌ‡๏ธ) next to your OAuth client
    • Replace the mock credentials.json file with the downloaded file
    • OR copy the values from the downloaded file to your mock file:
      • client_id: Replace YOUR_CLIENT_ID_HERE
      • client_secret: Replace YOUR_CLIENT_SECRET_HERE
      • project_id: Replace your-project-id
  6. First-time authentication

    • When you first use the calendar sync feature, a browser window will open
    • Sign in to your Google account
    • Grant permission to access your calendar
    • The app will save your authentication tokens for future use

๐Ÿƒโ€โ™‚๏ธ Running the Application

dotnet run

๐Ÿ“– Usage

Main Menu Options

  1. Add Habit - Create a new daily habit
  2. View Habits - See all habits with current streaks
  3. Mark Complete - Mark a habit as completed for today
  4. View History - See completion history for a specific habit
  5. Delete Habit - Remove a habit permanently
  6. Set Email Reminders - Schedule daily email notifications
  7. Change Language - Switch between supported languages
  8. Toggle Theme - Switch between light and dark mode
  9. Sync to Google Calendar - Create calendar events for your habits
  10. Exit - Save data and quit

๐Ÿ“… Calendar Integration

  • Sync Today: Press Enter when prompted for date
  • Sync Specific Date: Enter date in format yyyy-mm-dd (e.g., 2025-01-07)
  • All-Day Events: Habits appear as all-day events in your Google Calendar
  • Smart Reminders: Automatic popup and email reminders
  • Duplicate Prevention: Won't create duplicate events for the same habit/date
  • Color Coding: Habit events appear in green for easy identification

๐Ÿ”’ Security Notes

  • Your credentials.json file contains sensitive information
  • Never share this file publicly
  • The file is automatically excluded from version control via .gitignore
  • Authentication tokens are stored locally in token.json

๐Ÿ—‚๏ธ Project Structure

HabitTrackerApp/
โ”œโ”€โ”€ Classes/
โ”‚   โ”œโ”€โ”€ Habit.cs                    # Core habit model
โ”‚   โ”œโ”€โ”€ Storage.cs                  # Data persistence
โ”‚   โ”œโ”€โ”€ ReminderService.cs          # Email reminders
โ”‚   โ””โ”€โ”€ Services/
โ”‚       โ”œโ”€โ”€ GoogleCalendarService.cs # Calendar integration
โ”‚       โ”œโ”€โ”€ LocalizationService.cs  # Multi-language support
โ”‚       โ”œโ”€โ”€ LanguageService.cs      # Language management
โ”‚       โ””โ”€โ”€ ThemeService.cs         # Theme switching
โ”œโ”€โ”€ Resources/                      # JSON Localization files
โ”‚   โ”œโ”€โ”€ en.json                    # English (default)
โ”‚   โ”œโ”€โ”€ it.json                    # Italian
โ”‚   โ”œโ”€โ”€ uk.json                    # Ukranian
โ”‚   โ”œโ”€โ”€ fr.json                    # French
|   โ””โ”€โ”€ ru.json                    # Russian
โ”œโ”€โ”€ credentials.json               # Google API credentials (not in repo)
โ”œโ”€โ”€ .env                          # Email configuration (not in repo)
โ”œโ”€โ”€ habits.json                   # Habit data storage
โ”œโ”€โ”€ token.json                    # Google auth tokens (auto-generated)
โ””โ”€โ”€ Program.cs                    # Main application entry point

๐ŸŒ Localization

This project supports multiple languages with dynamic runtime switching:

  • ๐Ÿ‡บ๐Ÿ‡ธ English (default)
  • ๐Ÿ‡ฎ๐Ÿ‡น Italian
  • ๐Ÿ‡ซ๐Ÿ‡ท French
  • ๐Ÿ‡บ๐Ÿ‡ฆ Ukrainian
  • ๐Ÿ‡ท๐Ÿ‡บ Russian

๐Ÿ“ To add a new language, see Adding a new language guide.


๐ŸŽจ Themes

  • Light Mode: โ˜€๏ธ Default bright theme
  • Dark Mode: ๐ŸŒ™ Easy on the eyes for low-light usage
  • Dynamic Switching: Toggle themes at runtime
  • Persistent Settings: Your theme preference is saved

See THEME_SERVICE.md for more details.


๐Ÿ“ Contributing

Please read our contribution guidelines to learn how to propose changes and report issues.


๐Ÿ› Troubleshooting

Common Issues

Calendar sync fails with "Invalid time zone"

  • Ensure you're using the latest version of the app
  • Check your internet connection

Email reminders not working

  • Verify your .env file has correct Gmail credentials
  • Ensure App Passwords are enabled in Gmail

"OAuth client was not found" error

  • Download fresh credentials.json from Google Cloud Console
  • Ensure Google Calendar API is enabled in your project
  • Make sure you replaced the mock values with your actual credentials

"Access denied" error

  • Add your email as a test user in OAuth consent screen
  • Or publish your app (not recommended for personal use)

Mock credentials.json not working

  • Replace YOUR_CLIENT_ID_HERE and YOUR_CLIENT_SECRET_HERE with actual values
  • Ensure the project ID matches your Google Cloud project

Support

If you encounter issues:

  1. Check the troubleshooting section above
  2. Review the Issues page
  3. Create a new issue with detailed error information

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Google Calendar API for seamless calendar integration
  • .NET Community for excellent documentation and support
  • Contributors who helped improve this application

Happy habit building! ๐ŸŽฏ

About

Creates a console app through c# that allows users to create habits, mark them as completed and send daily email reminders based on the users selected time

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages