This is a lightweight gRPC feature flagging system with only a few dependencies, some of the crucial being:
- TypeScript
- Prisma
- SQLite
The SQLite database follows a jointed table approach. Originally I had planned to use Postgres JSONB data types, but since persistent databases were discouraged I went with this approach. It turns out that SQLite 3.9 introduced JSON1, but I did not adopt it due to some C compiling issues on my machine. In the future, NoSQL approaches might be better suited for this task.
I recommend DB Browser as your SQLite GUI tool. Be sure to open the database read-only when your code is running to ensure you don't lock the database.
For a great gRPC testing GUI, I highly encourage you to download BloomRPC.
git clone git@github.com:GeorgeWillaman/gRPC-Feature-Flagging.git # Download repo
cd gRPC-Feature-Flagging # Change directory into repo
npm i # Install required packages
./scripts/protogen.sh # Generate type files for proto files
npx prisma migrate dev # Generate & apply migration to SQLite database
npm run dev # Cleans dist, copies proto files, compiles, and runs. Optimization work still needs to be done
- Sanity checks
- Currently there are barely any input validation and sanity checks. For production, this is a crucial element. I did not have time to implement them to a degree that I was happy with.
- Migration to a persistent database
- For a production implementation, SQLite should not be used. MongoDB/PostgreSQL are 2 great alternatives for both SQL and NoSQL experts
- Proper error logging
- Adopt application monitoring software such as sentry.io
(I'll come back to this!)
- There have been documented issues with SQLite locking during deletions causing the app to crash. As a bandaid solution, a socket timeout of 20 has been provided in
prisma/schema.prisma
.