A simple demo of a warehouse software with Typescript, PostgreSQL, Prisma, Golang, NextJS...
MIT License
This project follows the Poppins manifesto guidelines as part of it's community principles and policies, focusing all the decisions and interactions on providing open source beginners mentorship with real and relevant experiences, respecting each learning pace, background experience, academic formation, questions, suggestions, doubts and opinion.
So, let's start contributing! Open an issue asking for a task to be done by you. A mentor/maintainer will come and provide a technical overview of the project and what are the possibles ways of contributing to the project. You will discuss the options and a suitable issue will be assigned or created to you.
That's it. Just make yourself at home and good luck!
A simple demo of a warehouse software with TypeScript, PostgreSQL, Prisma, Go, NextJS...
git clone https://github.com/tiagostutz/demo-warehouse-software
docker-compose up
Wait for the services to be ready and then populate the database with using the file watch:
cp assets/inventory.json local-data/incoming/article/
cp assets/products.json local-data/incoming/product/
cd web-app
yarn install
yarn build
yarn start
Open http://localhost:3000 on your Browser and check
version: "3.7"
services:
db:
image: tiagostutz/warehouse-demo-postgres:0.0.3
environment:
- POSTGRES_DB=demo-warehouse
- POSTGRES_PASSWORD=123456
- POSTGRES_INITDB_ARGS=--debug
ports:
- 5432:5432
api-backend:
image: tiagostutz/warehouse-demo-api-backend:0.0.3
ports:
- 4000:4000
environment:
- DATABASE_URL=postgres://postgres:123456@db:5432/demo-warehouse
database-updater:
image: tiagostutz/warehouse-demo-database-updater:0.0.3
volumes:
- ./local-data:/app/data
environment:
- LOG_LEVEL=debug
- WAREHOUSE_ARTICLE_ENDPOINT=http://api-backend:4000/article
- WAREHOUSE_PRODUCT_ENDPOINT=http://api-backend:4000/product
And bring it up:
docker-compose up
curl http://localhost:4000/article
curl http://localhost:4000/product
They should return and empty array []
as the response.
cp assets/inventory.json local-data/incoming/article/
Check again the return of the API:
curl http://localhost:4000/article
cp assets/products.json local-data/incoming/product/
Check again the return of the API:
curl http://localhost:4000/product
curl http://localhost:4000/product/1
curl http://localhost:4000/product/2
If all went as expected, the quantityAvailable
of this Product with id=1 should be 2
and of the Product with id=2 should be 1
.
curl --location --request POST 'http://localhost:4000/article/stock-update/by/product/2' \
--header 'Content-Type: application/json' \
--data-raw '{
"quantity": 1
}'
And let's check how the quantity available of the Products we have now:
curl http://localhost:4000/product/1
Product with id=1 should have quantityAvailable=1
curl http://localhost:4000/product/2
Product with id=2 should have quantityAvailable=0
To run each part individually in development mode, follow the steps bellow
To run api-backend in development mode, first clone this repo:
git clone https://github.com/tiagostutz/demo-warehouse-software.git
Bring the database up:
docker-compose up db
Then go to the api-backend folder and run
yarn install
Run the tests:
yarn test
Start the API in development mode:
yarn run dev
First, bring the database and the api-backend up (described in the previous session).
After that, run
go mod download
Then, to run the tests run:
go test ./...
Stage 1 (current implementation): no security, no load handling, no caching
Stage 2 (goal of this project): security, load balancing one level (API Gateway), no caching
Stage 3 (start production): security, load balancing one level (API Gateway), observability, caching
Stage 4 (scaling to the cloud): security, load handling, caching, observability, database replica/shard, job scheduling with queues and workflow management
There are two levels of tests: component/service/unit level and integration/API level test.
Running API Backend tests:
yarn run test
To run the Database Auto-updater integrated tests, you need the database and one instance of the API Backend up at localhost:4000, then run:
go test ./...
The tests here are at folders names tests
and the files has a .test.ts
suffix. To run the tests:
yarn run test
/health
/ready
What happens when running:
yarn install @prisma/client
The install command automatically invokes prisma generate for you which reads your Prisma schema and generates a version of Prisma Client that is tailored to your models.
Whenever you make changes to your Prisma schema in the future, you manually need to invoke npx prisma generate
in order to accomodate the changes in your Prisma Client API.
Used the defaults of Prisma to generate a Database, but if the data modeling would be subject to a Data Administration process with data/terms dictionary, conventions, abbreviations and that kind of stuff, some additional configuration would be needed on the schema.prisma definition.
DATABASE_URL=postgres://postgres:123456@localhost:5432/demo-warehouse npx prisma migrate dev --name init
DATABASE_URL=postgres://postgres:123456@localhost:5432/demo-warehouse npx prisma migrate dev --name init
If there's no domain involved or for a more integration and "flow setup" kind of code, go with vanilla JavaScript. If there's model, business logic or heavy componentization, go with TypeScript.
This software should hold articles, and the articles should contain:
It should be possible to load articles into the software from a file, see the provided inventory.json sample file.
The warehouse software should also have products, products are made of different articles. Products should have:
The products should also be loaded from a file, see the provided products.json sample file.
The warehouse should have at least the following functionality;
Here's a list of some more curated Poppins projects:
good first issue
tag. Project moderators add this tag to help beginners get involved with their projects.