A REST API simulating ATM functionality — user authentication via PIN, balance inquiry, deposits, withdrawals, and admin account management. Built with ASP.NET Core 9 following Clean Architecture principles.
- Session-based authentication for both users (PIN) and admins (password)
- Deposit and withdraw funds with balance validation
- Admin-only account creation
- Full operation history logging
- Thread-safe in-memory storage
- Interactive API docs via Swagger UI
src/
├── Lab5/ # Entry point (ASP.NET Core host)
├── Domain/
│ └── Lab5.Domain/ # Entities: Account, PinCode, Session, Operation
├── Application/
│ ├── Lab5.Application/ # Use cases: AccountService, AuthService
│ ├── Lab5.Application.Contracts/ # Interfaces & DTOs (ports)
│ └── Lab5.Application.Abstractions/ # Repository interfaces
├── Infrastructure/
│ └── Lab5.Infrastructure.Persistence/ # In-memory repositories
└── Presentation/
└── Lab5.Presentation.Http/ # Controllers, request/response models
Dependencies point strictly inward: Presentation → Application → Domain. Infrastructure implements Application abstractions.
All authenticated requests pass the session token in the Authorization header.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/login/user |
Login with account number + PIN → returns session token |
POST |
/api/auth/login/admin |
Login with admin password → returns session token |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
GET |
/api/account/balance |
User | Get current balance |
POST |
/api/account/deposit |
User | Deposit funds |
POST |
/api/account/withdraw |
User | Withdraw funds |
POST |
/api/account/create |
Admin | Create a new account |
Request / response examples
Login as user
POST /api/auth/login/user
Content-Type: application/json
{ "accountNumber": "ACC-001", "pin": "1234" }{ "token": "3fa85f64-5717-4562-b3fc-2c963f66afa6" }Withdraw
POST /api/account/withdraw
Authorization: 3fa85f64-5717-4562-b3fc-2c963f66afa6
Content-Type: application/json
{ "amount": 500 }{ "newBalance": 1500 }Create account (admin)
POST /api/account/create
Authorization: <admin-session-token>
Content-Type: application/json
{ "accountNumber": "ACC-002", "pin": "4321" }{ "accountId": 2 }git clone https://github.com/notakeith/atm-service.git
cd atm-service
dotnet run --project src/Lab5Swagger UI: https://localhost:<port>/swagger
Default admin password in src/Lab5/appsettings.json:
"AdminSettings": { "AdminPassword": "notakeith" }dotnet test tests/Lab5.Tests| Runtime | .NET 9 / ASP.NET Core |
| Architecture | Clean Architecture |
| API docs | Swagger / Swashbuckle |
| Testing | xUnit + NSubstitute |
| Storage | In-memory (ConcurrentDictionary) |