Coder Social home page Coder Social logo

open-transit-old-prototype's Introduction

Transit-at-Hand-Backend

open-transit-old-prototype's People

Contributors

lonelyteapot avatar

Watchers

 avatar

open-transit-old-prototype's Issues

Provide static Network information

A transit network is where all routes are somewhat connected. It may correspond to a city or a region.

Fields

  • id
  • name
  • routes in the network

Provide static Route information

Fields

  • id
  • number AND/OR name
  • every stop along the route
  • starting and ending locations
  • transit type(s) that usually runs on the route
  • transit company(s) that usually serve the route

Possible types of routes

  • 2-way, runs from start to end, then from end to start
  • 1-way, runs from start to end
  • half-loop, runs from start to start, partially overlapping in opposite directions
  • full-loop, runs without end, MAY overlap in opposite directions

Actually, any type of route can have multiple important (start/end) stops, where passengers must disembark either always, or when a vehicle enters/exits the service.

Implement a GraphQL API

The only API will be public at least for now.

I consider omitting REST and only do GraphQL, since the transit data is heavily interconnected.

Framework choice

strawberry

  • Code-first
  • Based heavily on dataclasses and type hints -- good experience but encourages couping
  • A rolling release, well-tested in CD
  • Version 1 coming, with promises of stability and interface improvements
  • Lacks needed extensions

graphene

  • Code-first
  • Mainstream solution
  • Very stable, but infrequently updated, lacks maintainers

ariadne

  • Schema-first (the only usable framework)
  • Infrequently updated and lacks maintainers
  • Doesn't feel solid
  • Has good extensions

I really want to go Schema-first, but ariadne is not a good choice.

Best practices

Model as a graph.
Use relay's Connections on everything.
Plan for the future without versioning.
Return Payload types from mutations.

Good tips: https://graphql-rules.com/


Auth and other protection is not needed yet.

Implement an ASGI app

An ASGI app (Asynchronous Server Gateway Interface) is going to be the main server.
The GraphQL API is going to be served through it as well.

Framework choice

Both of these are very performant and provide good developer experience.
Key feature is the easy creation of JSON APIs and OpenAPI docs, but we probably won't need it much.

FastAPI

Stable and proved by the industry.
(My opinion):
Seems to be a bit bloated.
The main maintainer is very protective and doesn't approve most pull requests.
He also doesn't support some of his other projects and they become outdated.

Starlite

Basically a much better version of FastAPI.
It enforces good practices that make the code much better.
It's not really well-known, unfortunately.
It's very open to the community and frequently updated.

Create the database schema

We're going to use PostgreSQL as it's the most universal and commonly used.
Nothing complicated yet.

ORM choice

Prisma

  • Modern and quickly evolving
  • Single source of truth - the schema file. All Python code is auto-generated
  • Migrations are very easy
  • Clear and simple interface. HOWEVER, Python is not supported officially, it's mainly made for JS
  • Asynchronous by default
  • Good tools are starting to pop up

SQLAlchemy

  • Proved and stable
  • The one I'm much more familiar with
  • Slow update cycle, but it's enough
  • Migrations are streamlined but not great
  • Model with Python classes instead of a specific schema language

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.