A console-based Habit Tracker built with C# and SQLite as part of the C# Academy curriculum. This project introduces database-driven development using ADO.NET to perform full CRUD operations against a real SQLite database.
- About the Project
- Features
- Requirements
- Getting Started
- How to Use
- Project Structure
- New Concepts Learned
- Technologies Used
- License
Habit Logger is a C# console application that tracks daily water intake (glasses of water per day). Every record is stored in a real SQLite database file that persists between sessions. The app demonstrates full CRUD functionality — Create, Read, Update, and Delete — using ADO.NET to communicate directly with the database using raw SQL commands.
- Log daily water intake by date and quantity
- View all logged habit entries
- Update an existing entry
- Delete an existing entry
- SQLite database created automatically on first run
- All errors handled gracefully — app never crashes
- Follows the DRY (Don't Repeat Yourself) principle
| # | Requirement |
|---|---|
| 1 | Log occurrences of a habit tracked by quantity |
| 2 | Users input the date of each occurrence |
| 3 | Data is stored and retrieved from a real SQLite database |
| 4 | Database and table are created automatically on startup |
| 5 | Users can Insert, Delete, Update and View logged habits |
| 6 | All possible errors are handled — app never crashes |
| 7 | Only ADO.NET used — no Entity Framework or Dapper |
| 8 | DRY Principle followed throughout |
- .NET SDK (version 6.0 or later)
- Visual Studio Code with the C# Dev Kit
- Clone the repository:
git clone git@github.com:Timothynyezi/HabitLogger.git- Navigate into the project directory:
cd HabitLogger- Install dependencies:
dotnet restore- Run the application:
dotnet runThe SQLite database file
habitlogger.dbis created automatically on first run — no setup required.
- Launch the app with
dotnet run - From the main menu, choose an option:
- 1 — Log a new water intake entry
- 2 — View all logged entries
- 3 — Update an existing entry
- 4 — Delete an entry
- 0 — Exit
- When logging, enter the date and number of glasses consumed
- When updating or deleting, enter the ID of the record to modify
HabitLogger/
├── Program.cs # Entry point — starts the app and menu loop
├── DatabaseManager.cs # All database operations (CRUD via ADO.NET)
├── UserInterface.cs # All console input and output
├── HabitEntry.cs # Data model representing one habit record
├── HabitLogger.csproj # Project configuration and dependencies
├── habitlogger.db # Auto-generated SQLite database file
└── README.md # Project documentation
| Concept | Description |
|---|---|
| SQLite | A lightweight file-based relational database |
| ADO.NET | Built-in C# library for raw database communication |
SQL CREATE TABLE |
Define a table structure in the database |
SQL INSERT INTO |
Add a new record to a table |
SQL SELECT |
Query and retrieve records from a table |
SQL UPDATE |
Modify an existing record |
SQL DELETE |
Remove a record from the database |
SqliteConnection |
Opens a connection to the SQLite database file |
SqliteCommand |
Executes a SQL statement against the database |
SqliteDataReader |
Reads rows returned from a SELECT query |
| Parameterised queries | Safely pass user input into SQL without SQL injection |
- Language: C#
- Framework: .NET (Console Application)
- Database: SQLite via
Microsoft.Data.Sqlite - Data Access: ADO.NET (raw SQL — no ORM)
- IDE: Visual Studio Code + C# Dev Kit
- Version Control: Git & GitHub
This project is open source and available under the MIT License.
Built as part of the C# Academy — C# Foundation track.