Skip to content

Commit

Permalink
Merge branch 'subhadeeproy3902:main' into multilanguage
Browse files Browse the repository at this point in the history
  • Loading branch information
mahek0620 authored Jul 9, 2024
2 parents d18f940 + ce9d052 commit 9ffca1e
Show file tree
Hide file tree
Showing 75 changed files with 2,494 additions and 396 deletions.
13 changes: 7 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
KINDE_CLIENT_ID=3ef4fe87ca9a413eb12c975a2fc14347
KINDE_CLIENT_SECRET=EqIHTPoKkb9qG7YOtmfZO4YAdajEi5qnTGsXQ0vgUHyVCSvoRh3q
KINDE_ISSUER_URL=https://xeven.kinde.com
KINDE_SITE_URL=http://localhost:3000
KINDE_POST_LOGOUT_REDIRECT_URL=http://localhost:3000
KINDE_POST_LOGIN_REDIRECT_URL=http://localhost:3000/dashboard
CONVEX_DEPLOYMENT=dev:perfect-panther-605
NEXT_PUBLIC_CONVEX_URL=https://perfect-panther-605.convex.cloud
NEXT_PUBLIC_GEMINI_API_KEY_DOC=your-gemini-api-key
Expand All @@ -13,4 +7,11 @@ NEXT_PUBLIC_EMAILJS_API_KEY=your_id
NEXT_PUBLIC_EMAILJS_SERVICE_ID=your_id
RESEND_API_KEY=your_api_key
NEXT_PUBLIC_CLIENT_URL=http://localhost:3000

# Under Development
NEXT_PUBLIC_ACCESS_TOKEN_EXPIRY=1d
NEXT_PUBLIC_REFRESH_TOKEN_EXPIRY=10d
NEXTAUTH_SECRET=your-secret-key
MONGODB_URI=mongodb://localhost:27017/BloxAi

#use these variables only ;)
42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
<a name="top"></a>
![](https://i.postimg.cc/FF6TxJdC/home.jpg)
<center>
<img src="https://readme-typing-svg.herokuapp.com?color=45ffaa&size=40&width=900&height=80&lines=Welcome-to-Box-AI"/>
</center
# Blox AI
<a name="top"></a>
<p align="center">
<img src="https://i.postimg.cc/FF6TxJdC/home.jpg" width="900" style="border: 2px solid #000000;" alt="Blox AI Home">
</p>
<br>

Welcome to Blox AI, where crafting flowcharts and diagrams is a breeze and get an explanation from the top Google Gemini model about your creations! Seamlessly create stunning visuals and rich documentation with our intuitive tools. Collaborate effortlessly with your team, from basic flowcharts to intricate diagrams. Enjoy secure workspaces and easy sharing. Start visualizing your ideas today!

Visit the site here - [Blox AI](https://blox-ai.vercel.app/)
<p align="center"><strong>Visit the site here - <a href="https://blox-ai.vercel.app/" style="background-color: yellow; padding: 5px; border-radius: 5px;">Blox AI</a></strong></p>

## 🏆 Featured in:

<table>
<tr>
<th>Event Logo</th>
<th>Event Name</th>
<th>Event Description</th>
</tr>
<tr>
<td><img src="public/Gssoc Label.png" width="200" height="auto" loading="lazy" alt="GSSoC 24"/></td>
<td>GirlScript Summer of Code 2024</td>
<td>GirlScript Summer of Code is a three-month-long Open Source Program conducted every summer by GirlScript Foundation. It is an initiative to bring more beginners to Open-Source Software Development.
</tr>
</table>

# Table of Contents

- [Features](#features)
- [Tech Stack](#tech-stack)
- [Authors](#authors)
- [Contributors](#contributors)
- [How to Get API Keys](#how-to-get-api-keys?)
- [Licence](#licence)


## Features

Expand Down Expand Up @@ -81,10 +111,10 @@ Thanks to all contributors for helping this project grow! 🍻
<img src="https://contrib.rocks/image?repo=subhadeeproy3902/BloxAI" width=800 />
</a>

## 🙏 Support
## Support 🙏

Don't forget to leave a star ⭐ for this project!

Crafted with ♥ by @subhadeeproy3902 & @xeven777.
<p align="center"><strong> Crafted with ♥ by @subhadeeproy3902 & @xeven777. </strong></p>

<p align="right"><a href="#top">Back to top</a></p>
15 changes: 4 additions & 11 deletions convex/files.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { v } from "convex/values";
import { mutation, query } from "./_generated/server";
import { Id } from "./_generated/dataModel";

export const createFile = mutation({
args: {
Expand Down Expand Up @@ -179,25 +180,17 @@ export const changeToPublic = mutation({
});

export const updateWrite = mutation({
args: {
_id: v.id("files"),
writtenBy: v.array(v.string())
},
handler: async (ctx, args) => {
handler: async (ctx, args:{_id : Id<"files">, writtenBy:string[]}) => {
const { _id,writtenBy } = args;
const res = await ctx.db.patch(_id, { writtenBy, write:true, read:true });
return res;
},
});

export const updateRead = mutation({
args: {
_id: v.id("files"),
readBy: v.array(v.string())
},
handler: async (ctx, args) => {
handler: async (ctx, args:{_id : Id<"files">, readBy:string[]}) => {
const { _id,readBy } = args;
const res = await ctx.db.patch(_id, { readBy, write:false, read:true });
const res = await ctx.db.patch(_id, { readBy:readBy, write:false, read:true });
return res;
},
});
8 changes: 1 addition & 7 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

export async function middleware(request: NextRequest) {
const { isAuthenticated } = getKindeServerSession();
if (!(await isAuthenticated())) {
return NextResponse.redirect(
new URL("/api/auth/login?post_login_redirect_url=/dashboard", request.url)
);
}

}

export const config = {
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@excalidraw/mermaid-to-excalidraw": "^0.3.0",
"@formspree/react": "^2.5.1",
"@hookform/resolvers": "^3.4.0",
"@kinde-oss/kinde-auth-nextjs": "^2.2.6",
"@langchain/google-genai": "^0.0.16",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
Expand All @@ -43,9 +42,10 @@
"@reduxjs/toolkit": "^2.2.4",
"@studio-freight/lenis": "^1.0.42",
"axios": "^1.7.2",
"bcryptjs": "^2.4.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"convex": "^1.11.3",
"convex": "^1.12.2",
"cors": "^2.8.5",
"editorjs-button": "^3.0.3",
"emailjs": "^4.0.3",
Expand All @@ -55,11 +55,16 @@
"express": "^4.19.2",
"framer-motion": "^11.1.9",
"html2canvas": "^1.4.1",
"jsonwebtoken": "^9.0.2",
"jspdf": "^2.5.1",
"langchain": "^0.2.4",
"lottie-react": "^2.4.0",
"lucide-react": "^0.378.0",
"moment": "^2.30.1",
"mongodb": "^6.8.0",
"mongoose": "^8.4.5",
"next": "^14.2.3",
"next-auth": "^4.24.7",
"next-pwa": "^5.6.0",
"next-themes": "^0.3.0",
"react": "^18.3.1",
Expand All @@ -68,6 +73,7 @@
"react-lottie-player": "^2.0.0",
"react-redux": "^9.1.2",
"react-spring": "^9.7.3",
"redux-persist": "^6.0.0",
"remark": "^15.0.1",
"remark-parse": "^11.0.0",
"resend": "^3.3.0",
Expand All @@ -81,6 +87,8 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/jsonwebtoken": "^9.0.6",
"@types/node": "^20.12.11",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
Expand Down
Binary file added public/Gssoc Label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions public/google.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions src/app/Provider.tsx

This file was deleted.

56 changes: 56 additions & 0 deletions src/app/Redux/Auth/auth-slice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";

type UserState = {
id: string;
firstName: string;
lastName: string;
email: string;
refreshToken: string;
accessToken: string;
image: string | undefined;
};

type AuthState = {
user:{
isAuth: boolean;
id:string;
firstName: string;
lastName: string;
email: string;
refreshToken:string;
accessToken:string;
image:string | undefined;
}
};

const initialState: AuthState = {
user:{
id:"",
isAuth: false,
firstName: "",
lastName: "",
email: "",
accessToken: "",
refreshToken: "",
image:undefined
}
};

export const auth = createSlice({
name: "auth",
initialState:initialState,
reducers: {
logOut: (state) => {
state.user = { ...initialState.user };
},
logIn: (state, action: PayloadAction<UserState>) => {
state.user = {
...action.payload,
isAuth: true,
};
},
},
});

export const { logIn, logOut } = auth.actions;
export default auth.reducer;
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/app/ReduxProviders.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client";
import { Provider } from "react-redux";
import { persistor, store } from "../config/store";
import { PersistGate } from 'redux-persist/integration/react'

export function ReduxProviders({ children }: { children: React.ReactNode }) {
return (
<Provider store={store}>
<PersistGate persistor={persistor}>
{children}
</PersistGate>
</Provider>
);
}
5 changes: 5 additions & 0 deletions src/app/SessionProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use client";
import { SessionProvider } from "next-auth/react";
export const AuthProvider = ({ children }: { children: React.ReactNode; }) => {
return <SessionProvider>{children}</SessionProvider>;
};
87 changes: 87 additions & 0 deletions src/app/api/auth/[...nextauth]/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import type { NextAuthOptions } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import UserModel from "@/models/user";
import bcrypt from "bcryptjs";
import { mongoDB } from "@/lib/MongoDB";

export const options: NextAuthOptions = {
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {
email: {
label: "email:",
type: "text",
placeholder: "your-cool-email",
},
password: {
label: "Password:",
type: "password",
placeholder: "your-awesome-password",
},
},
async authorize(credentials) {
//retrieve user data
const { email, password }: any = credentials;
try {
await mongoDB();
const user = await UserModel.findOne({ email });
if (!user) {
throw new Error("Not Registered!");
}
const passCheck = await bcrypt.compare(password, user.password);

if (!passCheck) throw new Error("Incorrect Password!");

return user;
} catch (e) {
console.log(e)
}
},
}),
],
session:{
strategy:"jwt",
},
pages: {
signIn: "/signin",
},
secret: process.env.NEXTAUTH_SECRET,
callbacks:{
async session({ session, token }) {
session.user = {
...session.user,
id: token.id as string,
email: token.email as string,
accessToken: token.accessToken as string,
refreshToken: token.refreshToken as string,
firstName: token.firstName as string,
lastName: token.lastName as string,
image: token.image as string | undefined,
};
return session;
},
async jwt({ token, user }:any) {
if (user) {
// Generate access and refresh tokens when the user is defined
const accessToken = user.generateAccessToken();
const refreshToken = user.generateRefreshToken();

// Save the refresh token to the user document
user.refreshToken = refreshToken;
await user.save({ validateBeforeSave: false });

token.id = user._id;
token.email = user.email;
token.firstName = user.firstName;
token.lastName = user.lastName;

token.accessToken = accessToken;
token.refreshToken = refreshToken;

token.image = user.image
}
return token;
}
},
};
6 changes: 6 additions & 0 deletions src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import NextAuth from "next-auth"
import { options } from "./options"

const handler = NextAuth(options);

export { handler as GET, handler as POST }
12 changes: 0 additions & 12 deletions src/app/api/auth/[kindeAuth]/route.ts

This file was deleted.

Loading

0 comments on commit 9ffca1e

Please sign in to comment.