Skip to content

Repository files navigation

Hostel Management System - Fee Tracking Module

A clean architecture ASP.NET Core 8 Web API for managing hostel fee tracking, payments, and reminders.

Architecture

Controllers → Services → Repositories → Entity Framework → SQL Server

The solution follows Clean Architecture with 4 projects:

Project Type Responsibility
HostelManagement.API ASP.NET Core 8 Web API Controllers, Services, Middleware, Mapping
HostelManagement.Core Class Library Entities, Enums, DTOs, Interfaces
HostelManagement.Infrastructure Class Library DbContext, Migrations, Repositories, Seed Data
HostelManagement.Tests xUnit Test Project Unit Tests, Integration Tests

Folder Structure

HostelManagementSystem/
├── HostelManagement.API/
│   ├── Controllers/          # API endpoints
│   │   ├── FeeController.cs
│   │   ├── PaymentController.cs
│   │   ├── ReminderController.cs
│   │   └── StudentController.cs
│   ├── Mappings/             # AutoMapper profiles
│   │   └── MappingProfile.cs
│   ├── Middleware/           # Global exception handling
│   │   └── ExceptionMiddleware.cs
│   ├── Services/             # Business logic layer
│   │   ├── FeeService.cs
│   │   └── StudentService.cs
│   ├── Program.cs
│   └── appsettings.json
├── HostelManagement.Core/
│   ├── DTOs/                 # Data Transfer Objects
│   ├── Entities/             # Domain models
│   ├── Enums/                # Enumerations
│   └── Interfaces/           # Contract definitions
├── HostelManagement.Infrastructure/
│   ├── Data/
│   │   ├── HostelDbContext.cs
│   │   └── SeedData.cs
│   ├── Migrations/
│   └── Repositories/         # Data access implementations
└── HostelManagement.Tests/
    ├── FeeServiceTests.cs
    └── FeeRepositoryIntegrationTests.cs

Technologies

  • .NET 8 - Cross-platform framework
  • ASP.NET Core 8 Web API - REST API framework
  • Entity Framework Core 8 - ORM (Code First)
  • SQL Server LocalDB - Database
  • AutoMapper - Object mapping
  • Swagger / Swashbuckle - API documentation
  • xUnit - Unit testing
  • Moq - Mocking framework
  • FluentAssertions - Test assertions
  • Clean Architecture - Separation of concerns
  • Repository Pattern - Data abstraction
  • Dependency Injection - IoC container

Installation

Prerequisites

Steps

# Clone the repository
git clone <repository-url>
cd HostelManagementSystem

# Restore dependencies
dotnet restore

# Apply migrations (Database will be created automatically)
dotnet ef database update --project HostelManagement.Infrastructure --startup-project HostelManagement.API

# Run the application
dotnet run --project HostelManagement.API

The API will be available at https://localhost:7254 or http://localhost:5041.

Database

  • Provider: SQL Server LocalDB
  • Database Name: HostelManagementDB
  • Connection String: Server=(localdb)\MSSQLLocalDB;Database=HostelManagementDB;Trusted_Connection=True;TrustServerCertificate=True;

Schema

  • Students - Student registration information
  • Fees - Fee records linked to students
  • Payments - Payment transactions linked to fees
  • ReminderLogs - Reminder history linked to students

Seed Data

The application automatically seeds:

  • 5 Students
  • 10 Fee Records
  • 15 Payments
  • 3 Reminder Logs

API Endpoints

Fees

Method Endpoint Description
GET /api/fees Get all fees
GET /api/fees/{id} Get fee by ID
POST /api/fees Create a new fee
PUT /api/fees/{id} Update a fee
DELETE /api/fees/{id} Delete a fee

Payments

Method Endpoint Description
POST /api/payments Record a payment
GET /api/payments/student/{studentId} Get payments by student

Reminders

Method Endpoint Description
GET /api/reminders Get all reminders
POST /api/reminders/send Send a reminder (query: ?studentId=N)

Students

Method Endpoint Description
GET /api/students Get all students
POST /api/students Create a new student

Swagger

Swagger UI is available at /swagger when running in Development mode.

Business Logic

Fee Status Calculation

When a payment is recorded:

  • RemainingAmount = TotalFee - Sum(All Payments)
  • If RemainingAmount == 0 → Status = Paid
  • If RemainingAmount > 0 and future due date → Status = Partial
  • If DueDate < Today → Status = Overdue

Reminders

A reminder is automatically generated when a fee becomes overdue and a payment is made.

Validation

  • Fee amount must be greater than zero
  • Payment amount must be greater than zero
  • Payment cannot exceed remaining balance
  • Student must exist when creating a fee
  • Valid payment methods: Cash, BankTransfer, JazzCash, EasyPaisa, CreditCard

Testing

# Run all tests
dotnet test

# Run with verbose output
dotnet test --verbosity detailed

The test project includes:

  • Unit Tests: Service layer tests with Moq (17 tests)
  • Integration Tests: Repository tests with InMemory database (3 tests)

About

A professional ASP.NET Core 8 Web API-based Hostel Management System Fee Tracking Module featuring fee management, payment tracking, due calculations, reminder generation, Entity Framework Core, SQL Server, Clean Architecture, REST APIs, and automated testing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages