Skip to content

Commit d8f20d9

Browse files
setup stores and vitest
1 parent 7e46acf commit d8f20d9

9 files changed

+1431
-206
lines changed

README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Discord [here](https://discord.gg/3hWPDTA4kD)
109109
### Testing
110110

111111
- [x] Manual test scenario for auth and sub workflows passing
112-
- [ ] Unit tests for server functions
112+
- [x] Unit test framework (vitest)
113113
- [ ] Integration tests for auth and sub workflows
114114

115115
## Special Mention
@@ -120,8 +120,22 @@ This https://blog.checklyhq.com/building-a-multi-tenant-saas-data-model/ Article
120120

121121
The focus is on separation of concerns and avoiding vendor lock in.
122122

123+
### Diagram
124+
123125
<img src="assets/images/technical_architecture.png">
124126

127+
### Walkthrough
128+
129+
[<img src="https://img.youtube.com/vi/AFfbGuJYRqI/hqdefault.jpg">](https://www.youtube.com/watch?v=AFfbGuJYRqI)
130+
131+
### Tricky Decisions
132+
133+
_Composition over options API_ - I have decided to use composition api and setup functions accross the board including components, pages and Pinia stores. I was resistant at first, especially with the stores as I was used to Vuex but have come to the conclusion that it is easier to go one approach all over. It's also the latest and greatest and folks don't like to use a starter that starts behind the cutting edge.
134+
135+
_Prisma over Supabase API_ - I went with Prisma for direct DB access rather than use the Supabase client. This is Primarily to avoid lock-in with Supabase too much. Supabase is great but I thought burdening my users with a future situation where it's difficult to move off it wouldn't be very cool. Also, I really like how Prisma handles schema changes and updates to the client layer and types with just two bash commands, after using other approaches, I find this super smooth.
136+
137+
_Trpc over REST_ - Primarily for full thickness types without duplication on the client. Also I think the remote procedure call paradigm works well. Note however that I still include a [REST endpoint example](/server/api/note.ts) for flexibility. My preference for mobile is Flutter and there is not a Trpc client for Flutter that i'm aware off so it was important for me to make sure REST works also.
138+
125139
## Externals Setup
126140

127141
Things you gotta do that aren't code (and are therefore not very interesting)
@@ -224,12 +238,22 @@ Your webhook signing secret is whsec_xxxxxxxxxxxxx (^C to quit)
224238

225239
take ths signing secret and update the STRIPE_ENDPOINT_SECRET value in .env
226240

241+
### Start the Server
242+
227243
Start the development server on http://localhost:3000
228244

229245
```bash
230246
npm run dev
231247
```
232248

249+
### Running the Tests
250+
251+
There are a few unit tests, just for the stores because I needed to refactor. Feel free to extend the tests for your use cases, or not, it's your SaaS, not mine.
252+
253+
```bash
254+
npm run test
255+
```
256+
233257
## Production
234258

235259
Build the application for production:

0 commit comments

Comments
 (0)