Grok is a learning tool that allows users to learn different facts about different topics
In this tutorial series we will be builing a limited version of Anki, using the following technologies:
- Clojure
- Datomic
- ClojureScript
- Re-Frame
- DataScript (via Re-Posh)
- id (uuid)
- full-name (string)
- username (string)
- email (string => unique)
- password (string => hashed)
- token (string)
- id (uuid)
- author (Ref)
- title (string)
- tags (vector of strings)
- id (uuid)
- deck (REF)
- front (string)
- back (string)
- progress (long)
- next-study-date (date|instant)
Now that we are aware of our data model, lets look at how we will design/structure our rest endpoints
/api/login
- POST => login a user /api/register
- POST => register a user
/api/users/:user-id
- GET => get a single user by ID
- PUT => Update a user
- DELETE => Delete a single user
/api/users
- POST => Post a new user
/api/users/:user-id/decks/:deck-id
- GET => get a single deck by ID belonging to a certain user
- PUT => Update a deck
- DELETE => Delete a deck
/api/users/:user-id/decks
- POST => Post a new deck
- GET => Browse a list of decks
/api/users/:user-id/decks/:deck-id/cards/:card-id
- GET => get a single cards by ID belonging to a certain deck
- PUT => Update a card
- DELETE => Delete a card
/api/users/:user-id/decks/:deck-id/cards
- POST => Post a new card
- GET => Browse a list of cards
- Create (done)
- Read (done)
- Update (done)
- Delete (done)
- List (done)
- Read (done)
- Create (done)
- Update (done)
- Delete (done)
- List
- Read
- Create
- Update
- Delete
Before we go ahead and implement CRUD functions for Decks and Cards, lets talk about run time state
What is run time state? Environment variables, database connection are considered run time state.
- Run time state can dependent on each other. For example in order to create database connection, you need database-uri, which comes from the env variables.
- Currently our application only has two run time state.
- As our application grows, so will our run time state.
- Since more state => more complexity. We need to make sure to tame it
Luckily clojure provides with libraries such as component, mount, integrant to manage these run time state.
In this case, I will be using mount.
Mount has two basic function
- start -> which starts the state
- stop -> stop which stops the state
You can also decided which resource to start, or which resources to omit when starting mount for example
In order to use convert run time state/resource -> mount state, we have to use the macro defstate provided by mount.
Another benefit mount provide is that it enables reloaded workflow... lets much easier to explain with code... so lets get started with mount
In next video we will start with the server series. Thank you so much for watching and for all the feedbacks. First step was an experimental with music and coding (Data Layer) Second step I will go over the code line by line.
Thanks for watching :D