A RESTful backend API for a digital wallet / money transfer application built with ASP.NET Core 8 and SQL Server. It includes a plain HTML/JS frontend and supports user registration, admin approval, JWT-authenticated transfers, beneficiary management, and transaction history.
- Features
- Tech Stack
- Project Structure
- Getting Started
- Configuration
- Database Setup
- API Endpoints
- Frontend Pages
- Business Rules
- User registration with admin approval workflow
- JWT-based authentication (5-hour token lifetime)
- Secure password hashing with BCrypt
- Money transfers between approved users
- Beneficiary management (add, list, delete)
- Transaction history per user
- Admin panel to view pending users and approve accounts
- New users receive an automatic ₹5,000 initial deposit on approval
- Swagger UI for API exploration
| Layer | Technology |
|---|---|
| Backend | ASP.NET Core 8 Web API (C#) |
| ORM | Entity Framework Core 9 (SQL Server provider) |
| Auth | JWT Bearer Tokens |
| Passwords | BCrypt.Net-Next |
| Docs | Swashbuckle / Swagger UI |
| Frontend | Vanilla HTML, CSS, JavaScript |
| Database | Microsoft SQL Server |
SmartPayAPI/
├── Controllers/
│ ├── AdminController.cs # Pending users, approve user
│ ├── AuthController.cs # Login, JWT token issuing
│ ├── BeneficiaryController.cs # CRUD for beneficiaries
│ ├── RegisterController.cs # New user registration
│ ├── TransactionController.cs # Transaction history
│ └── TransferController.cs # Money transfer logic
│
├── Models/
│ ├── AppDbContext.cs # EF Core DB context
│ ├── Beneficiary.cs # Beneficiary entity
│ ├── LoginRequest.cs # Login DTO
│ ├── Transaction.cs # Transaction entity
│ └── User.cs # User entity
│
├── Migrations/ # EF Core migrations
│
├── Frontend/ # Static HTML pages
│ ├── login.html
│ ├── register.html
│ ├── dashboard.html
│ ├── transfer.html
│ ├── beneficiaries.html
│ ├── history.html
│ ├── success.html
│ └── admin.html
│
├── appsettings.json # App configuration
├── Program.cs # App bootstrap & middleware
└── SmartPayAPI.csproj # Project file
- .NET 8 SDK
- Microsoft SQL Server (local or remote instance)
- (Optional) Visual Studio 2022 or VS Code
-
Clone / extract the project.
-
Restore dependencies:
dotnet restore
-
Update the connection string in
appsettings.json(see Configuration). -
Apply database migrations:
dotnet ef database update
-
Run the API:
dotnet run
-
Open Swagger UI at
https://localhost:<port>/swaggerto explore and test endpoints.
Edit appsettings.json before running:
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=SmartPayDB;Trusted_Connection=True;TrustServerCertificate=True;"
},
"Jwt": {
"Key": "YourSuperSecretKeyHere_AtLeast32Chars!!",
"Issuer": "SmartPayAPI"
}
}Security note: Replace the default
Jwt:Keywith a strong, unique secret before deploying to any environment outside localhost.
The project uses EF Core Code-First migrations. Run the following to create (or update) the database:
dotnet ef database updateTo add a new migration after model changes:
dotnet ef migrations add <MigrationName>| Table | Description |
|---|---|
Users |
Registered users with roles and balances |
Transactions |
All money movement records |
Beneficiaries |
Saved payees per user |
All protected routes require the header:
Authorization: Bearer <jwt_token>
| Method | Route | Auth | Description |
|---|---|---|---|
| POST | /Auth/login |
No | Login and receive JWT token |
Request body:
{ "mobileNumber": "03001234567", "password": "yourpassword" }| Method | Route | Auth | Description |
|---|---|---|---|
| POST | /Register |
No | Register new user |
Request body:
{
"fullName": "Ali Raza",
"email": "ali@example.com",
"mobileNumber": "03001234567",
"password": "yourpassword"
}| Method | Route | Auth | Description |
|---|---|---|---|
| GET | /Admin/pending-users |
No | List users awaiting approval |
| POST | /Admin/approve-user |
No | Approve a user and credit ₹5,000 |
Approve request body: "03001234567" (plain string)
| Method | Route | Auth | Description |
|---|---|---|---|
| GET | /api/Transfer/beneficiaries |
Yes | Get current user's saved beneficiaries |
| POST | /api/Transfer |
Yes | Send money to another user |
Transfer request body:
{
"receiverMobile": "03007654321",
"amount": 500.00,
"type": "Personal"
}| Method | Route | Auth | Description |
|---|---|---|---|
| GET | /Transaction/history |
Yes | Get current user's full history |
| Method | Route | Auth | Description |
|---|---|---|---|
| GET | /api/Beneficiary |
Yes | List saved beneficiaries |
| POST | /api/Beneficiary |
Yes | Add a new beneficiary |
| DELETE | /api/Beneficiary/{id} |
Yes | Remove a beneficiary |
Add request body:
{ "fullName": "Sara Khan", "beneficiaryMobile": "03007654321" }Open the HTML files in the Frontend/ folder directly in a browser or serve them with any static file server.
| File | Purpose |
|---|---|
login.html |
User login form |
register.html |
New user registration form |
dashboard.html |
Balance overview and quick actions |
transfer.html |
Send money to a beneficiary |
beneficiaries.html |
Manage saved payees |
history.html |
View past transactions |
success.html |
Transfer success confirmation |
admin.html |
Admin panel — approve pending users |
- Mobile numbers must be exactly 11 digits.
- New users have Pending status and a ₹0 balance until an admin approves them.
- On approval, the user automatically receives an ₹5,000 initial deposit from the system.
- Only Approved users can log in, transfer money, or be added as beneficiaries.
- Users cannot transfer money to themselves or to the admin account.
- JWT tokens expire after 5 hours.