GuwandykA 82e1aad016 Align schema, API routes, and auth with updated admin domain model.
Rename users table fields and loan documents table, expand branch billing credentials, switch to /api/admin prefix, refactor auth endpoints, replace PATCH with PUT for status updates, remove file upload APIs, and regenerate Swagger with ordered tags.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 14:09:45 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00
2026-07-04 18:34:30 +05:00

Bankline — Online Payment System Backend

Bankline is the HTTP backend for an online payment platform. It acts as the main API gateway: it accepts client requests, handles admin authentication, stores data in PostgreSQL, and manages file assets on local disk.

Overview

The service is built as a modular Go application. Admin-facing endpoints are exposed under /v1/admin. JWT-based authentication protects sensitive routes. Swagger is available for interactive API exploration.

Current capabilities

  • Admin authentication — login with email/password, JWT access and refresh tokens
  • Token refresh — exchange a valid refresh token for a new token pair
  • Admin profile — retrieve authenticated admin profile data
  • File storage — upload, serve, and delete files from the local public/ directory
  • API documentation — Swagger UI at /swagger/index.html

Planned / in progress

Additional Swagger endpoints (categories, settings) are documented but not yet implemented.

Tech stack

Layer Technology
Language Go 1.26
HTTP framework Gin
Database PostgreSQL 14
DB driver pgx
Auth JWT (HS256) + bcrypt password hashing
API docs Swaggo
Config YAML via cleanenv
Migrations golang-migrate
Containerization Docker & Docker Compose

Architecture

┌─────────────┐     HTTP      ┌──────────────────┐
│   Clients   │ ────────────► │  Bankline API    │
│  (Admin UI) │               │  (Gin, :5050)    │
└─────────────┘               └────────┬─────────┘
                                       │
                              ┌────────┴────────┐
                              ▼                 ▼
                       ┌────────────┐    ┌────────────┐
                       │ PostgreSQL │    │   Logs     │
                       │  (main-db) │    │ ./logs/    │
                       └────────────┘    └────────────┘

Project structure

.
├── app.go                  # Application entry point
├── config.yaml             # Runtime configuration
├── docker-compose.yaml     # Local development stack
├── db/migrations/          # SQL migrations
├── docs/                   # Generated Swagger docs
├── internal/
│   ├── admin/auth/         # Admin auth handlers & repository
│   ├── appresult/          # Response helpers & JWT middleware
│   ├── config/             # Config loader
│   └── handlers/manager/   # Route registration
└── pkg/
    ├── client/postgresql/  # PostgreSQL connection pool
    ├── logging/            # Structured logging
    └── utils/              # JWT & file utilities

Getting started

Prerequisites

  1. Clone the repository:

    git clone <repository-url>
    cd online-back
    
  2. Start all services:

    docker compose up -d --build
    
  3. Apply database migrations (from the host, with PostgreSQL exposed on port 5424):

    make migrate
    

The API will be available at http://localhost:5050.

Docker services

Service Container Port(s) Description
API main-app 5050 Bankline HTTP server
Database main-db 5424 → 5432 PostgreSQL

Run locally (without Docker)

  1. Start PostgreSQL (or use docker compose up main-db -d).

  2. Update config.yaml — set storage.host to localhost and match your database credentials.

  3. Apply migrations:

    make migrate
    
  4. Create required directories:

    mkdir -p logs public/images
    
  5. Run the application:

    go run app.go
    

Configuration

Settings are loaded from config.yaml:

is_debug: true
listen:
  port: 5050
jwt_key: <your-jwt-secret>
storage:
  host: main-db        # use localhost when running outside Docker
  port: 5432
  database: bank_db
  username: bank_admin
  password: <password>
  pg_pool_max_conn: 10
public_file_path: ./public
app_version: 0.0.1

Note: Replace default credentials before deploying to production.

API reference

Base path: /v1/admin

Method Endpoint Auth Description
POST /login No Admin login — returns access and refresh tokens
POST /token No Refresh access token
GET /get-profile Bearer JWT Get authenticated admin profile
POST /file Bearer JWT Upload a file to local storage
DELETE /file/:id Bearer JWT Remove a file
GET /images/:id No Serve a stored image

Authentication

Protected endpoints require an Authorization header with a valid JWT access token:

Authorization: <accessToken>

Default admin credentials (seeded by migration):

Field Value
Login admin@admin.com
Password (see migration seed — change after first login)

Swagger

Interactive API docs: http://localhost:5050/swagger/index.html

Database migrations

Requires the golang-migrate CLI.

# Create a new migration
make create-migration name='migration_name'

# Apply all pending migrations
make migrate

# Roll back the last migration
make migrate-rollback

Migration files live in db/migrations/.

Development

Run tests

mkdir -p logs
go test ./...

Regenerate Swagger docs

swag init -g app.go
Description
No description provided
Readme 18 MiB
Languages
Go 92.8%
PLpgSQL 6%
Shell 0.7%
Makefile 0.3%
Dockerfile 0.2%