Skip to content

A demo of GraphQL/Restful APIs for querying live flight ticket using CQRS and event driven pattern

Notifications You must be signed in to change notification settings

eedkevin/flight-ticket

Repository files navigation

Flight Ticket

Folder Structure

.
├── seed  ## seed scripts
├── src  ## source code
│   ├── configs  ## system configs
│   ├── constants  ## system constants
│   ├── domains ## main biz logics
│   ├── external  ## external apis
│   ├── facilities  ## facilities that the system depends on
│   ├── graphql  ## graphql API
│   ├── models  ## DB models
│   ├── rest  ## rest API
│   ├── types  ## public types
│   └── utils  ## utils
└── test  ## test cases
    ├── e2e  ## e2e test
    ├── stress  ## stress/performance test
    └── unit  ## unit test

Prerequisite

  1. docker
  2. docker-compose v3
  3. GNU-Make 3.81

Getting Started

  1. 启动服务
make build-up
  1. 调试接口

请用Postman导入collection文件 ./flight_ticket.postman_collection.json 进行调试

  1. 航班实时查询接口请用 graphql playground 进行调试。浏览器打开
open http://localhost:3000/api/graphql
subscription {
  getFlightThumbInstant{
    id
    capacity
    remainSeats
    currentPrice
  }
}
  1. Redis调试

启动时附带了一个 redis 管理界面,可用于调试。浏览器打开

open http://localhost:8081
  1. DB调试

可用任何 postgres 客户端连接 localhost:5432 进行调试。默认用户名/密码 root/root , 数据库名 flight_ticket

Test & Coverage

本地执行测试用例需要先安装依赖

yarn install

Unit Test

yarn test:unit

E2E Test

yarn test:e2e

Stress/Performance Test

yarn test:stress

Test Coverage

yarn test:coverage

补充

  1. 系统做了一些简化,例如航司系统和支付接口是在系统内做了mock,并未实际发出http请求;数据在启动阶段初始化,没有设计新增航班和用户注册接口

  2. 系统做了一个危险的假设:系统依赖的中间件和系统运行环境高可用。即系统对容灾和恢复没有做充分的考虑

  3. 由于航班、机票等数据是在启动是初始化的,如果因反复调试接口或运行压力测试导致无可用航班余位,请运行 seed 脚本重新导入数据

yarn seed
  1. 航班号 flight_id=999 用于压力测试

  2. 如调试中或e2e/stress测试偶发400情况,大概率因为三方航司/支付接口重试3次后失败导致

  3. 如有系统启动或其他问题,请随时联系

About

A demo of GraphQL/Restful APIs for querying live flight ticket using CQRS and event driven pattern

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages