Skip to content

tenosiswono/auction

Repository files navigation

codecov

Realtime Auction System

https://auction.teno.dev

Setup

To get started with the project, follow these steps:

git clone git@github.com:tenosiswono/auction.git

Navigate to the project directory.

cd auction

Install the dependencies.

npm install

Create an environment file.

cp env.example .env

Edit the environment file and fill in your postgres connection string

# Prisma DB
DATABASE_URL="postgres://<username>:<password>@<url>:<port>/<path>"

Edit the environment file and fill in coresponding #supabase env from Supabase project

#supabase
SUPABASE_DOMAIN=odfdyvontbfhssqawmbj.supabase.co
SUPABASE_URL=https://<your-project>.supabase.co
SUPABASE_KEY=
SUPABASE_BUCKET=<bucket-name>
IMAGE_SERVER=https://<your-project>.supabase.co/storage/v1/object/public/bucket-name

Edit the environment file and fill in coresponding #inngest env from Inngest project

#inngest
INNGEST_EVENT_KEY="local"
INNGEST_SIGNING_KEY=<your-signing-key>

Edit the environment file and fill in coresponding #pusher env from Pusher project

#pusher
PUSHER_APP_ID=""
NEXT_PUBLIC_PUSHER_KEY=""
PUSHER_SECRET=""
NEXT_PUBLIC_PUSHER_CLUSTER=""

Migrate Prisma DB

npx prisma migrate dev

Start the web development server.

npm run dev

Open on your browser http://localhost:3000

Test

  • Frontend Unit Test
  • Server Unit Test
  • End-to-end Test
  • DB Test

To run the test

npm run test

To collect coverage of the test

npm run coverage

To lint on sources

npm run lint

Architecture

Stacks

ERD

erDiagram
	Auction {
		String id PK  "cuid()"
		String title
		String image
		Float startingPrice
		Float currentPrice
		Int duration
		DateTime startDate  "nullable"
		DateTime endDate  "nullable"
		DateTime createdAt  "now()"
		DateTime updatedAt  "now()"
		String creatorId FK
		String status
		String winnerId FK  "nullable"
	}
	Bid {
		String id PK  "cuid()"
		Float amount
		String bidderId FK
		String auctionId FK
		DateTime createdAt  "now()"
		DateTime updatedAt  "now()"
	}
	DepositHistory {
		String id PK  "cuid()"
		String userId FK
		Float amount
		String status
		DateTime createdAt  "now()"
		DateTime updatedAt  "now()"
	}
	Account {
		String id PK  "cuid()"
		String userId FK
		String type
		String provider
		String providerAccountId
		String refresh_token  "nullable"
		String access_token  "nullable"
		Int expires_at  "nullable"
		String token_type  "nullable"
		String scope  "nullable"
		String id_token  "nullable"
		String session_state  "nullable"
	}
	Session {
		String id PK  "cuid()"
		String sessionToken
		String userId FK
		DateTime expires
	}
	User {
		String id PK  "cuid()"
		String name  "nullable"
		String email  "nullable"
		DateTime emailVerified  "nullable"
		String image  "nullable"
		String password
		Float deposit
	}
	VerificationToken {
		String identifier
		String token
		DateTime expires
	}
	Auction }o--|| User : creator
	Auction }o--|| User : winner
	Bid }o--|| User : bidder
	Bid }o--|| Auction : auction
	DepositHistory }o--|| User : user
	Account }o--|| User : user
	Session }o--|| User : user

Auciton Creator Sequence Diagram

sequenceDiagram
    participant Creator
    participant AuctionSystem
    participant InngestJobWorker

    Creator->>AuctionSystem: Create Auction
    AuctionSystem-->>Creator: Auction Created
    Creator->>AuctionSystem: Publish Auction
		AuctionSystem->>InngestJobWorker: Create Scheduller at endDate
    AuctionSystem-->>Creator: Auction Published

    Note left of InngestJobWorker: After Scheduller at endDate
		InngestJobWorker->>AuctionSystem: Update auction to complete, select winner, refund lost bidder

Auction Bidder Sequence Diagram

sequenceDiagram
    participant Bidder1
    participant Bidder2
    participant AuctionSystem

		Bidder1->>AuctionSystem: Bid on Auction 1, price: 100
		AuctionSystem->>Bidder1: Update on websocker currentPrice 100
		AuctionSystem->>Bidder2: Update on websocker currentPrice 100
		Bidder2->>AuctionSystem: Bid on Auction 1, price: 200
		AuctionSystem->>Bidder1: Update on websocker currentPrice 200
		AuctionSystem->>Bidder2: Update on websocker currentPrice 200

Design

Home List

Inspired by ClickBids. A new way of winning in 11 clicks

License

MIT License

Copyright (c) 2023 Teno Siswono

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.