Skip to content

brycehammond/allowance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

216 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Allowance Tracker

A modern allowance management system built with React + ASP.NET Core 8.0. Helps parents manage children's allowances, track spending, and teach financial responsibility through an intuitive web interface and REST API.

CI Pipeline License: MIT

✨ Features

For Parents

  • πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦ Family Management: Manage multiple children in one family account
  • πŸ’° Transaction Control: Add money (chores, gifts) or deduct spending
  • πŸ“… Automated Allowances: Set weekly allowances that pay automatically
  • πŸ“Š Analytics Dashboard: View spending trends, income vs expenses, and category breakdowns
  • πŸ’Ύ Savings Accounts: Automatic savings transfers with deposits and withdrawals
  • 🎯 Wish Lists: Help children save for goals
  • πŸ” Secure Authentication: ASP.NET Core Identity with role-based access

For Children

  • πŸ’΅ Track Balance: See current balance and transaction history
  • 🎯 Wish List: Save for things they want with progress tracking
  • πŸ’° Savings Account: Build savings with parent oversight
  • πŸ“± Mobile Ready: iOS native app coming soon

Technical Highlights

  • βš›οΈ Modern Frontend: React 19 + TypeScript + Tailwind CSS v4
  • 🎨 Rich Visualizations: Recharts for analytics (line, bar, pie charts)
  • πŸ§ͺ Test-Driven: 213 comprehensive tests with >90% coverage
  • 🐳 Docker Ready: Containerized deployment
  • πŸš€ CI/CD: Automated testing and deployment via GitHub Actions
  • πŸ”’ JWT Authentication: Secure API access
  • πŸ’Ύ Azure SQL Server: Reliable data persistence with EF Core migrations
  • ☁️ Azure Deployment: API on App Service, Frontend on Storage Static Website
  • πŸ“‘ Optional SignalR: Add real-time updates if needed (see ADDING_SIGNALR.md)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         React Frontend (SPA)            β”‚
β”‚  React 19 + TypeScript + Vite          β”‚
β”‚  Tailwind CSS v4 + Recharts            β”‚
β”‚  Axios for API calls                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ HTTP/REST + JWT
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      ASP.NET Core 8.0 Web API           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β”œβ”€β”€ Controllers (REST endpoints)       β”‚
β”‚  β”œβ”€β”€ Services (Business Logic)         β”‚
β”‚  β”‚   β”œβ”€β”€ FamilyService                 β”‚
β”‚  β”‚   β”œβ”€β”€ TransactionService            β”‚
β”‚  β”‚   β”œβ”€β”€ AllowanceService              β”‚
β”‚  β”‚   β”œβ”€β”€ WishListService               β”‚
β”‚  β”‚   β”œβ”€β”€ SavingsAccountService         β”‚
β”‚  β”‚   └── TransactionAnalyticsService   β”‚
β”‚  └── Authentication (JWT + Identity)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ Entity Framework Core 8
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Azure SQL Database                 β”‚
β”‚  β”œβ”€β”€ Users (ApplicationUser)           β”‚
β”‚  β”œβ”€β”€ Families                           β”‚
β”‚  β”œβ”€β”€ Children                           β”‚
β”‚  β”œβ”€β”€ Transactions                       β”‚
β”‚  β”œβ”€β”€ WishListItems                      β”‚
β”‚  └── SavingsTransactions                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β–²
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Azure Function (Timer Trigger)        β”‚
β”‚   Processes Weekly Allowances            β”‚
β”‚   Runs daily at 10:00 AM UTC             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

Local Development

For detailed step-by-step instructions, see LOCAL_DEVELOPMENT.md

Quick version:

# 1. Clone the repository
git clone https://github.com/yourusername/allowance-tracker.git
cd allowance-tracker

# 2. Start SQL Server (using Docker)
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=YourStrong@Passw0rd" \
  -p 1433:1433 --name allowancetracker-sql \
  -d mcr.microsoft.com/azure-sql-edge:latest

# 3. Setup and run the API
cd src/AllowanceTracker
dotnet ef database update
dotnet run
# API runs on https://localhost:7071

# 4. Setup and run the React app (in a new terminal)
cd web
npm install
echo "VITE_API_URL=https://localhost:7071" > .env.development
npm run dev
# Frontend runs on http://localhost:5173

Open your browser to http://localhost:5173

Azure Deployment

Deploy to Azure with GitHub Actions:

  1. Set up Azure resources (SQL, App Service, Function App, Storage)
  2. Configure GitHub Secrets
  3. Push to main branch - automatic deployment!

See GITHUB-ACTIONS-DEPLOYMENT.md for complete instructions.

πŸ§ͺ Running Tests

We follow strict Test-Driven Development (TDD) with 73 comprehensive tests:

# Run all tests
dotnet test

# Run with code coverage
dotnet test --collect:"XPlat Code Coverage"

# Run specific test category
dotnet test --filter "Category=Unit"

# Watch mode (continuous testing)
dotnet watch test

Test Coverage

  • 213 tests passing (API and Services)
  • >90% code coverage on critical business logic
  • Includes: Models, Services, Controllers, Authentication
  • CI/CD runs all tests automatically on every commit

πŸ“– Usage

Create a Family Account

  1. Navigate to /register
  2. Create parent account (first user becomes family admin)
  3. Add children from the dashboard

Add a Child

// Via UI: Dashboard β†’ "Add Child" button

// Or via API:
POST /api/v1/children
{
  "firstName": "Alice",
  "lastName": "Smith",
  "weeklyAllowance": 10.00
}

Record a Transaction

Via React UI:

  1. Go to Dashboard
  2. Click on a child's card to view details
  3. Go to "Transactions" tab
  4. Click "Add Transaction"
  5. Enter amount, type (Credit/Debit), category, and description
  6. Click "Save"

Via API:

curl -X POST https://localhost:7001/api/v1/transactions \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "childId": "guid-here",
    "amount": 25.00,
    "type": "Credit",
    "description": "Mowed the lawn"
  }'

Weekly Allowance

Allowances are processed automatically by an Azure Function with timer trigger:

  • βœ… Runs daily at 10:00 AM UTC
  • βœ… Checks all children with configured weekly allowances
  • βœ… Pays if 7+ days since last payment (or never paid before)
  • βœ… Creates transaction with category "Allowance"
  • βœ… Processes automatic savings transfer (if enabled)
  • βœ… Prevents double-payment within same week
  • βœ… Logs all activity to Application Insights
  • βœ… Nearly free on consumption plan

See WEEKLY_ALLOWANCE.md for complete details and testing instructions.

πŸ” API Authentication

The REST API uses JWT Bearer authentication:

1. Obtain Token

POST /api/auth/login
{
  "email": "parent@example.com",
  "password": "YourPassword123!"
}

# Response:
{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "expiresAt": "2025-10-10T12:00:00Z"
}

2. Use Token in Requests

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
  https://localhost:7001/api/v1/children/{childId}/balance

Tokens expire after 24 hours. Claims included: UserId, Email, Role, FamilyId.

πŸ“ Project Structure

allowance/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ AllowanceTracker/           # ASP.NET Core Web API
β”‚   β”‚   β”œβ”€β”€ Data/                   # EF Core DbContext & Migrations
β”‚   β”‚   β”œβ”€β”€ Models/                 # Domain entities
β”‚   β”‚   β”œβ”€β”€ DTOs/                   # Data transfer objects
β”‚   β”‚   β”œβ”€β”€ Services/               # Business logic
β”‚   β”‚   β”œβ”€β”€ Api/V1/                 # REST API controllers
β”‚   β”‚   └── Program.cs              # App startup & DI
β”‚   β”œβ”€β”€ AllowanceTracker.Functions/ # Azure Functions
β”‚   β”‚   β”œβ”€β”€ WeeklyAllowanceFunction.cs # Timer trigger
β”‚   β”‚   β”œβ”€β”€ Program.cs              # Function startup & DI
β”‚   β”‚   └── host.json               # Function configuration
β”‚   └── AllowanceTracker.Tests/     # xUnit test project
β”‚       β”œβ”€β”€ Models/                 # Model tests
β”‚       β”œβ”€β”€ Services/               # Service tests
β”‚       └── Api/                    # API controller tests
β”œβ”€β”€ web/                            # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/             # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ tabs/               # Tab components
β”‚   β”‚   β”‚   └── forms/              # Form components
β”‚   β”‚   β”œβ”€β”€ pages/                  # Page components
β”‚   β”‚   β”œβ”€β”€ services/               # API service layer
β”‚   β”‚   β”œβ”€β”€ contexts/               # React contexts
β”‚   β”‚   β”œβ”€β”€ types/                  # TypeScript types
β”‚   β”‚   └── App.tsx                 # Main app component
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”œβ”€β”€ ios/                            # iOS Native App (SwiftUI)
β”œβ”€β”€ specs/                          # Detailed specifications
β”œβ”€β”€ .github/workflows/              # GitHub Actions CI/CD workflows
β”œβ”€β”€ GITHUB-ACTIONS-DEPLOYMENT.md    # GitHub Actions deployment guide
β”œβ”€β”€ LOCAL_DEVELOPMENT.md            # Local dev setup guide
β”œβ”€β”€ CLAUDE.md                       # Development guide for AI
└── README.md                       # This file

πŸ› οΈ Technology Stack

Category Technology
Backend Framework ASP.NET Core 8.0 Web API
Frontend Framework React 19 + TypeScript
Build Tool Vite 7
Styling Tailwind CSS v4
Charts Recharts
HTTP Client Axios
Database Azure SQL Server / SQL Server 2022
ORM Entity Framework Core 8
Auth ASP.NET Core Identity + JWT Bearer
Background Jobs Azure Functions (Timer Trigger)
Testing xUnit + FluentAssertions + Moq
CI/CD GitHub Actions
Deployment Azure App Service (API) + Azure Functions + Azure Storage (Frontend)

πŸ”’ Security

  • Password Hashing: ASP.NET Core Identity with PBKDF2
  • JWT Tokens: HMAC-SHA256 signing, 24-hour expiration
  • Role-Based Access: Parent/Child roles enforced at API level
  • Database Transactions: Atomic money operations prevent race conditions
  • Audit Trail: All transactions include CreatedBy and CreatedAt
  • Input Validation: Data annotations + FluentValidation
  • Immutable Transactions: Once created, transactions cannot be modified

πŸ“Š Database Schema

-- Core tables
Users (ApplicationUser extends IdentityUser)
  - Id (Guid, PK)
  - Email, FirstName, LastName
  - Role (Parent/Child enum)
  - FamilyId (FK)

Families
  - Id (Guid, PK)
  - Name
  - CreatedAt

Children
  - Id (Guid, PK)
  - UserId (FK to Users)
  - FamilyId (FK to Families)
  - CurrentBalance (decimal)
  - WeeklyAllowance (decimal)
  - LastAllowanceDate (DateTime?)

Transactions
  - Id (Guid, PK)
  - ChildId (FK to Children)
  - Amount (decimal)
  - Type (Credit/Debit enum)
  - Description (string)
  - BalanceAfter (decimal, snapshot)
  - CreatedById (FK to Users, audit)
  - CreatedAt (DateTime, audit)

🀝 Contributing

We follow strict Test-Driven Development (TDD):

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Write tests first (RED phase)
  4. Implement minimum code to pass tests (GREEN phase)
  5. Refactor while keeping tests green
  6. Commit with descriptive messages:
    git commit -m "Add feature X with TDD
    
    - Wrote 5 tests for feature X
    - Implemented minimum code to pass
    - Refactored for clarity
    
    Tests: 78 passing (+5)
    πŸ€– Generated with Claude Code"
  7. Push to branch: git push origin feature/amazing-feature
  8. Open Pull Request

Code Standards

  • >90% test coverage for new features
  • AAA pattern: Arrange, Act, Assert
  • Async/await consistently
  • Nullable reference types enabled
  • Records for DTOs, classes for entities

πŸ“ Documentation

  • LOCAL_DEVELOPMENT.md - START HERE - Complete local setup guide
  • GITHUB-ACTIONS-DEPLOYMENT.md - Deploy to Azure with GitHub Actions
  • WEEKLY_ALLOWANCE.md - Azure Function for automated allowances
  • ADDING_SIGNALR.md - Add real-time updates (optional)
  • CLAUDE.md - Development guide for AI assistants
  • specs/ - Detailed specifications:
    • 01-overview.md - System overview
    • 02-database-schema.md - EF Core models
    • 03-api-specification.md - REST API docs
    • 04-implementation-phases.md - TDD roadmap
    • 05-testing-strategy.md - Testing approach
    • 06-tdd-best-practices.md - TDD patterns
    • 08-ios-app-specification.md - iOS native app (SwiftUI)
    • 09-design-system.md - Design system and UI patterns

πŸ—ΊοΈ Roadmap

Completed βœ…

  • Phase 1: Foundation with EF Core & Identity
  • Phase 2: Transaction Management with Atomic Operations
  • Phase 3: React Frontend Migration (from Blazor)
  • Phase 4: Weekly Allowance Azure Function
  • Phase 5: JWT Authentication & REST API
  • Phase 6: Wish List Management
  • Phase 7: Analytics & Reports with Charts
  • Phase 8: Savings Accounts with Auto-Transfer
  • Phase 9: Azure Deployment Pipeline

In Progress 🚧

  • iOS Native App (SwiftUI)
  • PDF Export for Reports

Future Enhancements πŸš€

  • Chore Assignments with Rewards
  • Family Notifications (Email/Push)
  • Multi-Currency Support
  • Recurring Transactions
  • Budget Goals and Alerts

πŸ› Troubleshooting

Database Migrations

# Add new migration
dotnet ef migrations add YourMigrationName

# Apply migrations
dotnet ef database update

# Remove last migration (if not applied)
dotnet ef migrations remove

JWT Token Issues

# Verify appsettings.json has valid JWT configuration
# SecretKey must be at least 32 characters for HMAC-SHA256

{
  "Jwt": {
    "SecretKey": "your-secret-key-min-32-chars-long-for-hmac-sha256",
    "Issuer": "AllowanceTracker",
    "Audience": "AllowanceTracker"
  }
}

Docker Issues

# View logs
docker-compose logs -f

# Rebuild containers
docker-compose down
docker-compose up --build

# Reset everything
docker-compose down -v  # ⚠️ This deletes all data!

πŸ“„ License

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

πŸ™ Acknowledgments

πŸ“ž Support


Built with Test-Driven Development πŸ§ͺ 213 Tests Passing βœ… >90% Code Coverage πŸ“Š Modern Stack: React + .NET βš›οΈ Production Ready πŸš€

About

An allowance tracking app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors