Skip to content

(WIP) πŸ¦€ An Insanely Fast πŸš€ Full Stack Content Generation SaaS Platform Powered by Dioxus, Dioxus Server Functions, Axum, Unsplash, Gemini AI & MongoDB.

License

Notifications You must be signed in to change notification settings

opensass/aibook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“– AIBook πŸ€–

made-with-rust Rust Maintenance License

Open SASS Discord

🐧 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

πŸ“ Architecture

Arch

πŸ–₯️ For the .exe Enjoyers

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.

πŸ€“ For the Hardcore Nerds

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!

πŸ› οΈ Pre-requisites:

  1. Install rustup:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Install Dioxus CLI:

    cargo install dioxus-cli
  3. Fork/Clone the GitHub repository.

    git clone https://github.com/opensass/aibook

πŸ”‘ Setting Up Env Vars

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:

Create an .env File

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.

πŸ₯‘ Set Up MongoDB

Follow our quick guide to set up your MongoDB database and connect it to your project!

πŸ” Generate JWT Secret Key

Generate a secret key using OpenSSL and update its env var in the .env file.

openssl rand -hex 128

d8d0b35856c6fa90a8f3f818fa1c71785d63181945077a4c81e28f731de406c94acad5e864fc85604c520cd67e4977a06656eee081d2d0a897415bb42d8dca167662ae53078084ce70feaee104a3428797078c5bb359db277b26182114bb6b6f4e50d34dcce1ab2ed952912f5783ca89138d508f41bc2d56e60ef2480f501819

✨ Gemini AI API

To obtain your API key, navigate to Google AI Studio and generate it there. This key allows aibook to communicate with Gemini API.

πŸ“Έ Unsplash 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.

πŸ’³ Stripe API

Follow our quick guide to set up your stripe account and connect it to your project!

πŸš€ Building and Running

  • 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! πŸ˜„

βœ… Supported Features

  • Support for all Gemini models (e.g. Gemini Pro 1.5, Flash 1.5).

Gemini Models

  • Stripe support.

Stripe Demo

  • Built-in Dark and Light themes.

Light Dark Themes

  • JWT authentication.

  • Forms validations.

Email validation.

  • Instant toast notifications when submitting a form.

Toast notification.

  • Sending and receiving text messages in real time.

Sending and receiving text messages.

πŸ—‚οΈ Project Structure

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

πŸ› οΈ What's Inside?

  • Components: All modular components live here, following the DRY principle. From navbar to footer, 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. πŸ˜…

πŸ‘¨β€πŸ’» Data Models

MongDB Models

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! πŸš€

About

(WIP) πŸ¦€ An Insanely Fast πŸš€ Full Stack Content Generation SaaS Platform Powered by Dioxus, Dioxus Server Functions, Axum, Unsplash, Gemini AI & MongoDB.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages