Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minibank

Architecture

Minibank is a multi-toolchain repository:

  • The main application is written in Go under cmd/, domain/, infra/, and logger/
  • MongoDB migrations live under migration/ and use Node/CommonJS
  • Data seeding lives under seeder/ and uses Python

The current Go entrypoint in cmd/main.go only loads env vars, connects to MongoDB, logs the selected database name, and exits.

Requirements

  • Docker or Docker Compose
  • Nix with flakes if you want to use the dev shell

Or install the toolchains manually:

  • Go
  • Node.js
  • Python 3

Environment

Create a .env file at the repository root:

MONGO_URL=mongodb://localhost:27017
MONGO_DB_NAME=minibank

This .env file is shared by the Go app, migrations, and seeder.

Note: cmd/main.go currently hardcodes client.Database("minibank"), so changing MONGO_DB_NAME alone does not fully retarget the Go app.

Dev Shell

Enter the development shell with:

nix develop

flake.nix currently provides tooling only:

  • Go toolchain
  • Node.js
  • Python 3
  • Python LSP packages

Python runtime dependencies for the seeder are intentionally not bundled into the flake. Install them from seeder/requirements.txt.

Run MongoDB

From the repository root:

docker compose up -d mongo

MongoDB will be available on localhost:27017.

Run The Go App

From the repository root:

go run ./cmd

Verified commands:

go test ./...
go build ./...

Do not use go build ./cmd here. In this repository, cmd/ is a directory name, so the correct verification commands are go build ./... or go run ./cmd.

Seeder

Run the seeder from the seeder/ directory because the code calls load_dotenv("../.env"):

cd seeder
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python seeder.py

The current seeder will:

  • insert branchs
  • insert customers
  • embed accounts inside each customer document
  • insert loans

The schema is not fully aligned yet between the Go structs and the seeded documents. For example:

  • domain.Customer uses dob, while the seeder writes birthdate
  • domain.Account expects customer_id, while seeded accounts are nested inside customers

Migration

Run migration tooling from the migration/ directory because the config resolves ../.env from there.

cd migration
npm install

Important notes:

  • migration/package.json does not currently declare migrate-mongo
  • There are no ready-to-use migration scripts in package.json
  • If you want to use migrate-mongo, you need to install that tooling yourself

The config file is migration/migrate-mongo-config.js.

Repository Layout

.
|- cmd/
|- domain/
|- infra/
|- logger/
|- migration/
|- seeder/
|- docker-compose.yml
|- flake.nix

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages