around 80 bytes
Each day produces 96mb so 34GB a year of data
enter_garage(vehicleType, parking_lot_id): Return a number which can be a ticket id
exit_garage(parking_lot_id,reciept_id, vehicle_type): return True if a ticket has been paid or False if not
show_capacity(parking_lot_id): return an integer of how many spots are left in this parking lot
pay(parking_lot_id, ticket_id): return a receipt number.
User: {
ticketId: String,
parkingLotId: string,
timeStart: datetime,
timeEnd: datetime,
receiptId: string,
status: (using, left) string
}
lotCapacity: {
lotCapacityId: string,
lotType : (electric, handicap, etc) string,
spot_capacity: int,
spots_used: int,
}
transaction: {
receiptId: string,
ticketId: string,
paymentMethod: string,
paymentTime: datetime,
status: (paid, confirmed) string
}
parkingLot: {
parkingLotId: string,
lotCapacityId: string,
status
}
The payment service may go down so needs to be designed for when users are paying a fee. When the user submits a payment request for the parking lot, the parking service will generate a request in the message queue and also generate a receipt number for the user which will be stored in the transaction table. If the payment service is offline, the parking service will check the transaction table for the receipt existance, if it does then they will be able to leave. After the payment service is back online, it will return the payment status to the parking_service and parking_service will update the receipt that are in paid status to confirmed status. This approach actually implements a local payment record to keep track of the user parking status.
The biggest decision point was the database. For this service, I chose Relational Database over NoSQL Database. Because RDB provides strong consistency, which is beneficial for a payment service. Users can not leave util they pay for their parking fee, which is need to be 100% sure in this situation.
NoSQL database, for example MongoDB, would provide a better horizontal scalability than RDB. But for this service, I decided the benefit of RDB outweighs that of NoSQL DB.