Skip to content

imparthibank/banking-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏦 BankingApp - Clean Hexagonal Architecture with .NET 5 Web API

A clean and modular banking web API built using .NET 5, Hexagonal Architecture, and key open-source tools like Dapper, PostgreSQL, AutoMapper, and NUnit.


πŸ“¦ Project Structure

BankingApp.sln
β”‚
β”œβ”€β”€ BankingApp.WebApi/                  β†’ Driving Adapter (API)
β”‚   β”œβ”€β”€ Adapters/Input/Controllers/     β†’ REST Controllers
β”‚   β”œβ”€β”€ Startup.cs / Program.cs
β”‚   └── appsettings.json
β”‚
β”œβ”€β”€ BankingApp.Application/            β†’ Application Layer
β”‚   β”œβ”€β”€ DTOs/                           β†’ Input/Output Models
β”‚   β”œβ”€β”€ UseCases/                       β†’ Service Logic
β”‚   β”œβ”€β”€ Validation/                     β†’ Validation Logic
β”‚   β”œβ”€β”€ Ports/Input/                    β†’ Input Ports (Interfaces)
β”‚   └── Common/                         β†’ Result wrappers
β”‚
β”œβ”€β”€ BankingApp.Core/                   β†’ Domain Layer
β”‚   β”œβ”€β”€ Entities/                       β†’ Core domain entities
β”‚   └── Ports/Output/                   β†’ Output Ports (Repository Interfaces)
β”‚
β”œβ”€β”€ BankingApp.Infrastructure/         β†’ Driven Adapter (DB)
β”‚   β”œβ”€β”€ Adapters/Output/Repositories/  β†’ Dapper-based Repos
β”‚   └── Config/ConnectionFactory.cs    β†’ PostgreSQL Connection Factory
β”‚
β”œβ”€β”€ BankingApp.Tests/                  β†’ Unit Tests
β”‚   β”œβ”€β”€ UseCases/
β”‚   β”œβ”€β”€ Validation/
β”‚   β”œβ”€β”€ Adapters/Input/Controllers/
β”‚   └── Adapters/Output/Repositories/

🧱 Architecture

This project follows Hexagonal (Ports and Adapters) architecture:

  • Core (Domain) β€” contains Entities and Repository interfaces
  • Application β€” contains use cases, validation, DTOs, and input port interfaces
  • Infrastructure β€” database interaction using Dapper and PostgreSQL
  • Web API β€” the input adapter, exposes REST endpoints
  • Tests β€” unit test projects for all layers using NUnit and Moq

πŸ”§ Tech Stack

Layer Stack / Tool
Framework .NET 5 Web API
ORM Dapper
Database PostgreSQL
Mapping AutoMapper
Validation Manual + Fluent-style (custom logic)
Testing NUnit + Moq
Logging ILogger with file-based logging
Architecture Hexagonal (Clean Ports and Adapters)
DI/Startup Microsoft.Extensions.DependencyInjection

βœ… Features

  • Create, Read, Update, Delete (CRUD) for Bank Accounts
  • Validation for:
    • Name, Email, Mobile, PAN, AccountNumber uniqueness
    • Date of Birth presence
  • Uses Result / Result<T> pattern for uniform API responses
  • AutoMapper-powered mapping between DTOs and Entities
  • Unit-tested business logic and validation
  • Logging integrated using ILogger<T>

πŸ§ͺ Run Tests

dotnet test

πŸ–₯️ Run the Application

  1. Ensure PostgreSQL is running (e.g. via Docker or local)
  2. Update appsettings.json with correct DB credentials
  3. Run the app:
dotnet run --project BankingApp.WebApi

Visit Swagger at: http://localhost:5000/swagger


πŸ—ƒοΈ SQL Table

CREATE TABLE bank_accounts (
    id UUID PRIMARY KEY,
    name TEXT NOT NULL,
    account_number TEXT NOT NULL UNIQUE,
    email TEXT NOT NULL UNIQUE,
    date_of_birth DATE NOT NULL,
    nominee TEXT,
    mobile_number TEXT NOT NULL UNIQUE,
    pan TEXT NOT NULL UNIQUE
);

πŸ§ͺ Automate Local Code Coverage Report Generation

A single-click .bat file can automate the entire coverage pipeline:


🐳 Docker Support (Optional)

Want to add Docker + docker-compose for PostgreSQL and the API? Open an issue or PR!


🀝 Contributing

Feel free to fork and contribute. PRs are welcome!


πŸ“„ License

This project is licensed under the MIT License.

About

🧱 BankingApp β€” A clean and modular .NET 5 Web API built using Hexagonal Architecture, Dapper, PostgreSQL, AutoMapper, and NUnit. Handles CRUD operations for bank accounts with robust validation and logging.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors