idimitrov.dev/_content/cases/stepsy.wiki.md
Ivan Dimitrov 9dcca1e3dc Squashed commit of the following:
commit d8926d88656f6eb1d7d69272e39875e383f91b14
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 16:20:17 2023 +0200

    maybe prod?

commit 4a8854e7218f4b179310daadf9b95f6833686fdb
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 15:30:31 2023 +0200

    better markdown

commit c36d0308d2a9766174fde8432866e572a4b82d5e
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 14:50:00 2023 +0200

    cases list styles

commit 905d7edaccf2c2fd447f5cae35ef7bd88d86a2b1
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 14:46:35 2023 +0200

    contact page

commit d09bd61eba53c403522d046a48ee6b66f62f9ffb
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 14:02:47 2023 +0200

    more refactor and contact page

commit d6257bb9ca35549031c9953fced97bdd53d10454
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 13:56:47 2023 +0200

    refactor

commit 7d2a6ad6002a1e3d7b2ed83822caaffa49d3f37d
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 13:51:10 2023 +0200

    working pages

commit 6fa36883854c2e702a0c8b9fa6c9e397e4981575
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 11:51:15 2023 +0200

    style fixes

commit 478412187792104b6c29e33def1cca0ef38ee2bf
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Sat Nov 11 08:42:50 2023 +0200

    making markdown workd a little bit

commit ba24b023fdbc32a2eaab15e29e10a031162287b4
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Fri Nov 10 20:01:59 2023 +0200

    content logic
2023-11-11 16:21:23 +02:00

45 lines
3.0 KiB
Markdown

---
title: Multi-tenant knowledge base website based on Google APIs
goal: Create a modern multi-tenant web app that lets users use their Google Drive as a knowledge base
role: Design and implement the web app
date: Jul 29, 2023 - Nov 5, 2023
---
<details>
<summary>Solution</summary>
I chose NextJS as the backbone for this project as it offers the greatest amount of flexibility while still being very powerful both on the client as well as on the server with an active community and thriving ecosystem.
For styles I chose TailwindCSS with DaisyUI for the optimizations and development speed that come out of using them. Tailwind uses purgecss to minimize the final bundle making the page load and feel faster.
The database is PostgreSQL with Prisma ORM running on Vercel's cloud infrastructure.
For authentication I chose NextAuth with JWT as it's the preferred way to handle auth in a NextJS project.
The actual implementation is a lengthy process involving many moving parts and lots of code. I'll go over the three most challenging problems in no particular order.
Interfacing with Google Drive is done to read the content there and almost never used for writing except for setting and removing permissions. To read the content the reader must have appropriate permissions and that's determined by the auth system with a JWT.
For each request we can get the JWT and use it in the google client to auth unless it's an anonymous user, in which case we must use a google service account JWT. This JWT holds a google client access token used by google in determining permissions.
Once the client is set up we can start making drive requests on behalf of the user getting their drive content inside the web app including folders, files, documents, pictures, shared drives and so on, which can later be rendered on a page.
These requests are a bottleneck, which required many optimizations and concurrency tricks to make the site considerably faster than the competition.
The storage API uses Prisma ORM for storing and getting all the user info including wikis and spaces. When a user logs in they can see their wiki as well as all the wikis they are allowed to manage. It's used to handle authorized requests like changing the wiki/space name, url, permissions and more. Storage is an integral part of any web application.
The UI/UX uses TailwindCSS and DaisyUI to make everything a fast, modern, optimized and intuitive experience with extra features like dozens of themes as well as a custom theme builder.
React was used with TypeScript to provide a nice modern client-side experience between transitions and interactions.
This setup supports maximum optimization as you can see in the screenshots below allowing the app to reach a lighthouse score of 100 on all but one (it has 99) pages.
Both mobile and desktop is supported.
</details>
This project aims to be a Google Drive frontend. It uses the Google APIs to fetch document data and display that data in a wiki-style web page.
![thumbnail](/thumbnail.png)
It supports Google Docs, Google Sheets, Google Slides, PDFs and regular files.