/instabid-wallet

A digital wallet with fast money transfer capabilities and a real-time commodity auction platform. Made with GoLang, microservices, domain-driven design, and hexagonal architecture.

Primary LanguageGo

instabid-wallet

Forks Stargazers LinkedIn

A digital wallet with fast money transfer capabilities and a real-time commodity auction platform. Made with GoLang, microservices, domain-driven design, and hexagonal architecture.

Built With

go postgres aws docker redis apache-kafka github-actions

Getting Started

Clone using ssh protocol git@github.com:ashtishad/instabid-wallet.git

Environment-variables

Change environment variables in Makefile, if empty then default values listed here will be loaded, check app_helpers.go -> SanityCheck()

  • API_HOST [IP Address of the machine] : 127.0.0.1
  • USER_API_PORT [Port of the user api] : 8000
  • DB_USER [Database username] : postgres
  • DB_PASSWD [Database password]: postgres
  • DB_ADDR [IP address of the database] : 127.0.0.1
  • DB_PORT [Port of the database] : 5432
  • DB_NAME [Name of the database] : instabid
  • GIN_MODE [Name of the gin mode] : debug

Postgres-Database-Setup

  • Run docker compose: Bring the container up with docker compose up. Configurations are in compose.yaml file.
  • (optional) Remove databases and volumes:
    docker compose down
    docker volume rm instabid-wallet_data
    

Run-the-application

  • Run the application with make run command from project root. or, if you want to run it from IDE, please set environment variables by executing commands mentioned in Makefile on your terminal.

↑ Top

Project Structure

├── user-api                 <-- user-api microservice.
├── .github/workflows        <-- Github CI workflows(Build, Test, Lint).
├── config                   <-- Database initialization script with docker compose.
├── db/migrations            <-- Postgres DB migrations scripts for golang-migrate.
├── lib                      <-- Common setup, configs used across all services.
├── compose.yaml             <-- Docker services setup(databases)
├── golangci.yml             <-- Config for golangci-lint. 
├── Makefile                 <-- Builds the whole app with exporting environment variables.
├── main.go                  <-- Start all server concurrently, init logger, init db, env port check, graceful shutdown.
├── readme.md                <-- Readme for the whole app.

↑ Top

Data Flow (Hexagonal architecture)

Incoming : Client --(JSON)-> REST Handlers --(DTO)-> Service --(Domain Object)-> RepositoryDB

Outgoing : RepositoryDB --(Domain Object)-> Service --(DTO)-> REST Handlers --(JSON)-> Client

↑ Top

Routes Planned

Auth-API(:8001)

  • POST /login: Authenticate and log a user in and generate JWT access token.
  • GET /verify: Verify the user's authentication token.
  • POST /logout: Log out the currently authenticated user.
  • POST /reset-password: Reset the password for a given user.

User-API(:8000)

  • GET /users: Retrieve a paginated list of users with their profiles, with optional filtering.
  • POST /users/: Register a new user.
  • GET /users/:user_id: Fetch details for a specific user by ID.
  • POST /users/:user_id: Create profile details for a specific user by ID.
  • PUT /users/:user_id: Update the details of a specific user by ID.
  • DELETE /users/:user_id: Delete a specific user by ID.
  • GET /users/:user_id/profile: Fetch the profile details of a specific user by ID.
  • PUT /users/:user_id/profile: Update the profile details of a specific user by ID.

Wallet-API(:8002)

  • POST /users/:user_id/wallet: Create a new wallet for a specific user by ID.
  • GET /users/:user_id/wallet: Fetch the wallet details of a specific user by ID.
  • POST /users/:user_id/wallet/transfer: Transfer money from the wallet of a specific user.
  • GET /users/:user_id/wallet/transactions: Retrieve the transaction history for a specific user's wallet.

Auction-API(:8003)

  • POST /auctions: Create a new auction.
  • GET /auctions: Retrieve a list of all auctions.
  • GET /auctions/:auction_id: Fetch details of a specific auction by ID.
  • POST /auctions/:auction_id/bid: Place a bid on a specific auction by ID.
  • GET /auctions/:auction_id/bids: Retrieve a list of bids for a specific auction by ID.

Admin-API(:8004)

  • PUT /users/:user_id/role: Assign or modify the role of a specific user.
  • GET /users/inactive: Retrieve a list of all inactive users.
  • PUT /users/:user_id/activate: Activate a specific user by ID.
  • PUT /users/:user_id/deactivate: Deactivate a specific user by ID.

MISC

  • GET /health (Health check endpoint for monitoring and maintenance.)

↑ Top

Contact

Ashef Tishad - @ashef

Project Link: https://github.com/ashtishad/instabid-wallet

↑ Top

Credits

Readme template Readme Template

Badges and Icons Shields.io

↑ Top