A simple JSON API server for a banking system built with Go (Golang), Gorilla/mux (no Gin), MongoDB, and JWT for authorization and authentication.
- User Authentication: Secure JWT-based authorization and authentication.
- Account Management: Create, view, update, and delete bank accounts.
- Transaction Management: Perform and track transactions between accounts.
- Database: MongoDB for data storage.
- Golang: Backend server
- Gorilla/mux: HTTP router and dispatcher
- MongoDB: NoSQL database
- JWT: Secure token-based authentication
-
Clone the repository:
git clone https://github.com/mathis-k/bank-api.git cd bank-api
-
Install dependencies:
go mod download
-
Set up your environment variables:
cp .env.example .env
-
Start the API:
go run main.go
- POST /api/auth/register: Register a new user
Request Body:{ "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "password": "password123" }
- POST /api/auth/login: Login an existing user
Request Body:{ "email": "john.doe@example.com", "password": "password123" }
- GET /api/user: Get the current user
- PUT /api/user: Update the current user
Request Body:{ "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com" } or { "last_name": "Doey" }
- GET /api/accounts: Get all accounts for the current user
- GET /api/accounts/{number}: Get an account by ID for the current user
- POST /api/accounts: Create a new account for the current user
- DELETE /api/accounts/{number}: Delete an account by ID for the current user
- GET /api/transactions: Get all transactions for the current user
- GET /api/transactions/{id}: Get a transaction by ID for the current user
- GET /api/transactions/account/{number}: Get all transactions for an account from the current user
- POST /api/transactions/account/{number}/deposit: Deposit funds into an account from the current user
Request Body:{ "amount": 150.00 }
- POST /api/transactions/account/{number}/withdraw: Withdraw funds from an account from the current user
Request Body:{ "amount": 150.00 }
- POST /api/transactions/account/{number}/transfer: Transfer funds from an account of the current user to another account
Request Body:{ "amount": 150.00, "to_account": "7252934484834" }
.
├── main.go
├── routes/
├── controllers/
├── models/
├── middleware/
├── utils/
├── .env.example
├── go.mod
└── go.sum