π§ Linux (Recommended) |
πͺ Windows |
---|---|
aibook-linux.mp4 |
aibook-win.mp4 |
Download Executable | Download Executable |
Set Environment Variables | Set Environment Variables |
unzip files | unzip files |
execute ./dist/aibook |
execute .\dist\aibook.exe |
So, you're the kinda person who'd rather download an .exe
than spend 20 minutes watching code compile? No worries; I gotcha! π Each release comes with pre-compiled binaries. Just download, set env vars, run a command, and boom.
Note
- πΈ Unsplash API: Limited to 50 requests per hour.
- π Gemini credits: Unlimited!
- ποΈ MongoDB Storage: Capped at around ~512MB.
Now, navigate to the π Setting Up Env Vars section.
Aight, if you're, just like me, one of those brave souls who wants to compile everything themself, this section is for you. π οΈ No shortcuts, just raw code and dedication. Grab your favorite terminal, fire up those dependencies, and let the adventure begin!
-
Install
rustup
:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Install
Dioxus CLI
:cargo install dioxus-cli
-
Fork/Clone the GitHub repository.
git clone https://github.com/opensass/aibook
Before you can start running AIBook, you'll need to configure a few environment variables. These are essential for connecting to external services like MongoDB, Unsplash, and the Gemini AI, so let's get you set up! Here's a quick guide:
Inside the project root, copy and create a file named .env
from .env.example
. This file will securely store all your environment variables.
cp .env.example .env
Note
Replace the following values with your actual credentials.
MONGODB_USR=
MONGODB_PWD=
MONGODB_CLSTR=your-cluster.mongodb.net
MONGODB_DB_NAME=aibooks
JWT_SECRET=
GEMINI_API_KEY=
UNSPLASH_API_KEY=
STRIPE_SECRET_KEY=
WEBSITE_URL=https://opensass.org
STRIPE_PRICE_ONE=price_1...
STRIPE_PRICE_TWO=price_1...
If you're missing any of these keys, check the service's developer portal to generate them.
Follow our quick guide to set up your MongoDB database and connect it to your project!
Generate a secret key using OpenSSL and update its env var in the .env
file.
openssl rand -hex 128
d8d0b35856c6fa90a8f3f818fa1c71785d63181945077a4c81e28f731de406c94acad5e864fc85604c520cd67e4977a06656eee081d2d0a897415bb42d8dca167662ae53078084ce70feaee104a3428797078c5bb359db277b26182114bb6b6f4e50d34dcce1ab2ed952912f5783ca89138d508f41bc2d56e60ef2480f501819
To obtain your API key, navigate to Google AI Studio and generate it there. This key allows aibook to communicate with Gemini API.
AIBook uses Unsplash which provides a powerful API to search for and retrieve high-quality images. To communicate with this api you will need a Secret key. If you don't already have one, sign up for a free account at Unsplash, create a new app, and copy the Secret key at the bottom of the page after creating the app.
Follow our quick guide to set up your stripe account and connect it to your project!
-
Run the client:
dx serve --port 3000
Navigate to http://localhost:3000 to explore the landing page.
Warning
This might take a few minutes (yes, seriously). But hey, good things take time, right?
Happy compiling! π
- Support for all Gemini models (e.g. Gemini Pro 1.5, Flash 1.5).
- Stripe support.
- Built-in Dark and Light themes.
-
JWT authentication.
-
Forms validations.
- Instant toast notifications when submitting a form.
- Sending and receiving text messages in real time.
This project is packing 81 files! π But don't worry, it's all organized with love, care, and the principles of SoC and DRY in mind (peak engineering, ngl). Each file has a job to do, and it does it well; like little code ninjas in their own modular worlds.
Here's what the structure looks like:
β― cd src && tree
β― cd src && tree
.
βββ ai.rs
βββ components
βΒ Β βββ common
βΒ Β βΒ Β βββ header.rs
βΒ Β βΒ Β βββ logo.rs
βΒ Β βΒ Β βββ server.rs
βΒ Β βββ common.rs
βΒ Β βββ dashboard
βΒ Β βΒ Β βββ analytics.rs
βΒ Β βΒ Β βββ books
βΒ Β βΒ Β βΒ Β βββ create.rs
βΒ Β βΒ Β βΒ Β βββ edit.rs
βΒ Β βΒ Β βΒ Β βββ list.rs
βΒ Β βΒ Β βΒ Β βββ read.rs
βΒ Β βΒ Β βββ books.rs
βΒ Β βΒ Β βββ chat
βΒ Β βΒ Β βΒ Β βββ panel.rs
βΒ Β βΒ Β βΒ Β βββ sidebar.rs
βΒ Β βΒ Β βββ chat.rs
βΒ Β βΒ Β βββ fields
βΒ Β βΒ Β βΒ Β βββ input.rs
βΒ Β βΒ Β βΒ Β βββ number.rs
βΒ Β βΒ Β βΒ Β βββ select.rs
βΒ Β βΒ Β βββ fields.rs
βΒ Β βΒ Β βββ navbar.rs
βΒ Β βΒ Β βββ profile.rs
βΒ Β βΒ Β βββ sidebar.rs
βΒ Β βββ dashboard.rs
βΒ Β βββ features
βΒ Β βΒ Β βββ grid.rs
βΒ Β βΒ Β βββ item.rs
βΒ Β βββ features.rs
βΒ Β βββ footer
βΒ Β βΒ Β βββ bottom.rs
βΒ Β βΒ Β βββ contact.rs
βΒ Β βΒ Β βββ icon.rs
βΒ Β βΒ Β βββ links.rs
βΒ Β βΒ Β βββ logo.rs
βΒ Β βΒ Β βββ support.rs
βΒ Β βββ footer.rs
βΒ Β βββ hero.rs
βΒ Β βββ navbar
βΒ Β βΒ Β βββ btns.rs
βΒ Β βΒ Β βββ links.rs
βΒ Β βββ navbar.rs
βΒ Β βββ pricing.rs
βΒ Β βββ spinner.rs
βΒ Β βββ testimonial
βΒ Β βΒ Β βββ author.rs
βΒ Β βΒ Β βββ card.rs
βΒ Β βΒ Β βββ rating.rs
βΒ Β βββ testimonial.rs
βΒ Β βββ toast
βΒ Β βΒ Β βββ manager.rs
βΒ Β βΒ Β βββ provider.rs
βΒ Β βββ toast.rs
βββ components.rs
βββ db.rs
βββ lib.rs
βββ main.rs
βββ pages
βΒ Β βββ book.rs
βΒ Β βββ dashboard.rs
βΒ Β βββ home.rs
βΒ Β βββ login.rs
βΒ Β βββ signup.rs
βββ pages.rs
βββ router.rs
βββ server
βΒ Β βββ auth
βΒ Β βΒ Β βββ controller.rs
βΒ Β βΒ Β βββ model.rs
βΒ Β βΒ Β βββ response.rs
βΒ Β βββ auth.rs
βΒ Β βββ book
βΒ Β βΒ Β βββ controller.rs
βΒ Β βΒ Β βββ model.rs
βΒ Β βΒ Β βββ request.rs
βΒ Β βΒ Β βββ response.rs
βΒ Β βββ book.rs
βΒ Β βββ common
βΒ Β βΒ Β βββ request.rs
βΒ Β βΒ Β βββ response.rs
βΒ Β βββ common.rs
βΒ Β βββ conversation
βΒ Β βΒ Β βββ controller.rs
βΒ Β βΒ Β βββ model.rs
βΒ Β βΒ Β βββ request.rs
βΒ Β βΒ Β βββ response.rs
βΒ Β βββ conversation.rs
βΒ Β βββ subscription
βΒ Β βΒ Β βββ controller.rs
βΒ Β βΒ Β βββ model.rs
βΒ Β βΒ Β βββ request.rs
βΒ Β βΒ Β βββ response.rs
βΒ Β βββ subscription.rs
βββ server.rs
βββ theme.rs
βββ unsplash.rs
19 directories, 81 files
- Components: All modular components live here, following the DRY principle. From
navbar
tofooter
, each feature has its own place, making it easy to find and tweak when needed. - Server: Adheres to the MVC pattern, making the backend as clean as a freshly minted Linux distro. You'll find models, controllers, and response handlers for each feature, organized and ready for action.
- Pages: Each page of the app (e.g.,
dashboard.rs
,home.rs
) is set up here, so you know exactly where to go to update views.
With this structure, the project stays manageable and maintainable, despite those 81 files. Let's be honest, though: it's probably going to keep growing. π
AIBook is powered by MongoDB storage, with each model carefully structured to keep the app humming along smoothly. Here's a closer look at the data models and how they connect:
- User π§βπΌ: Stores user credentials, profiles, and role information. This model ensures each user enjoys secure, authenticated access.
- Book π: Contains details like title, type, topics, and handy timestamps for creation and updates, essentially, everything about a book except the content itself!
- Chapter π: Houses the content for each chapter, stored in both markdown and HTML formats for flexibility.
- Conversation π¬: Logs chats between users and the Gemini AI, so each interaction has a place in history.
- Message π: Tracks individual messages within each conversation, capturing the ebb and flow of the AI interaction.
- Subscription π³: Manages subscription plans, payment methods, and active status, essentially the gatekeeper for access levels and perks.
Note
MongoDB allows us to embed entire documents within another document, bypassing the need for an ID
relationship (though it does add one more DB call if we want to fetch the data separately). For now, we're not hitting any performance bottlenecks, but this option keeps things flexible as we scale.
Each model is designed to keep data tightly organized, minimize dependencies, and allow for easy scaling. So whether it's a quick query for a single user or a deep dive into chat history, these models keep AIBook streamlined and ready to grow! π