Skip to content

Commit

Permalink
Major changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mohdzain98 committed Jul 5, 2024
1 parent e86dec4 commit 5e31aeb
Show file tree
Hide file tree
Showing 23 changed files with 294 additions and 125 deletions.
1 change: 1 addition & 0 deletions Microservices/LLM/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def convert_mysql_to_sqlite(self):
mysql_sql = re.sub(r'\bUNLOCK TABLES\b;', '', mysql_sql, flags=re.IGNORECASE)
mysql_sql = re.sub(r"ALTER\s+TABLE\s+(\w+)\s+ADD\s+CONSTRAINT\s+(\w+)\s+FOREIGN\s+KEY\s+\(\s*(\w+)\s*\)\s+REFERENCES\s+(\w+)\s*\(\s*(\w+)\s*\)\s+ON\s+DELETE\s+(NO ACTION|CASCADE|SET NULL|SET DEFAULT)\s+ON\s+UPDATE\s+(NO ACTION|CASCADE|SET NULL|SET DEFAULT)\s*;",r"/* SQLite does not support ALTER TABLE ADD CONSTRAINT */",mysql_sql, flags=re.IGNORECASE)
mysql_sql = re.sub(r"N'((?:[^']|'')*)'", self.remove_n_prefix, mysql_sql, flags=re.IGNORECASE)
mysql_sql = re.sub(r'\\c\s+\w+;','', mysql_sql, flags=re.IGNORECASE)
# Replace NOW() with CURRENT_TIMESTAMP
mysql_sql = re.sub(r'\bNOW\(\)\b', 'CURRENT_TIMESTAMP', mysql_sql, flags=re.IGNORECASE)

Expand Down
3 changes: 1 addition & 2 deletions Microservices/User_auth/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ const mongoUri = process.env.REACT_APP_MDB
const connectToMongo = async () =>{
try{
await mongoose.connect(mongoUri)
console.log('mongo connected')
}catch(error){
console.log('error'+error)
console.log('not working')
}
}
module.exports = connectToMongo;
6 changes: 3 additions & 3 deletions Microservices/User_auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ app.use('/api/mail',require('./routes/mail'))

app.use('/',(req,res)=>{
return res.json({
message:"Wecome to Docster user auth microservice",
version:"1.3"
message:"Wecome to Docschat user auth microservice",
version:"1.4"
})
})

app.listen(port, () => {
console.log('Docster Microservice Running Successfully on port ***1')
console.log('Docschat Microservice Running Successfully on port ***1')
})
13 changes: 13 additions & 0 deletions Microservices/User_auth/models/Like.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mongoose = require('mongoose')
const {Schema } = mongoose;


const LikeSchema = new Schema({
count:{
type:Number,
default:0
}
})

const Like = mongoose.model('like',LikeSchema);
module.exports = Like
18 changes: 16 additions & 2 deletions Microservices/User_auth/routes/access.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const express = require('express')
const router = express.Router();
// const User = require('../models/User')
const Like = require('../models/Like')
const Access = require('../models/Acess')
const {body, validationResult} = require('express-validator')

Expand Down Expand Up @@ -29,7 +29,21 @@ router.post('/giveaccess',[
success=true
res.json({success,user})
}catch(err){
console.error(err.message)
res.status(500).send("Some Error Occured")
}
})

router.put('/likes',async(req,res)=>{
let success=false
try{
const liked = await Like.updateOne({}, { $inc: { count: 1 } }, { new: true })
if(liked){
success=true
res.json({success})
}else{
res.status(400).json({success})
}
}catch(err){
res.status(500).send("Some Error Occured")
}
})
Expand Down
12 changes: 2 additions & 10 deletions Microservices/User_auth/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const bcrypt = require('bcryptjs')
const jwt = require('jsonwebtoken')
const fetchuser = require('../middleware/fetchuser')
const Access = require('../models/Acess')
require('dotenv').config()


const JWT_SECRET = 'welcometodocster'
const JWT_SECRET = process.env.REACT_APP_JWTS

router.post('/existuser',async(req,res)=>{
let success = true;
Expand Down Expand Up @@ -65,7 +66,6 @@ router.post('/createuser',[
success = true;
res.json({success, authToken})
}catch(err){
console.error(err.message)
res.status(500).send("Some Error Occured")
}
})
Expand Down Expand Up @@ -99,7 +99,6 @@ router.post('/login',[
success = true
res.json({success, authToken})
}catch(error){
console.error(error)
res.status(500).send("Internal server occured")
}
})
Expand All @@ -111,7 +110,6 @@ router.post('/getuser',fetchuser, async (req,res) => {
const user = await User.findById(userId).select("-password")
res.send(user)
}catch(error){
console.error(error)
res.status(500).send('internal server error')
}
})
Expand All @@ -133,7 +131,6 @@ router.post('/glogin', async (req,res) => {
success = true
res.json({success, authToken})
}catch(error){
console.error(error)
res.status(500).send("Internal server occured")
}
})
Expand All @@ -145,7 +142,6 @@ router.post('/getuser',fetchuser, async (req,res) => {
const user = await User.findById(userId).select("-password")
res.send(user)
}catch(error){
console.error(error)
res.status(500).send('internal server error')
}
})
Expand All @@ -172,7 +168,6 @@ router.put('/updatect', fetchuser, async(req,res)=>{
const useru = await User.findById(req.user.id).select("-password")
res.send(useru)
}catch(error){
console.error(error.message)
res.status(500).send("Internal Server Error")
}
})
Expand All @@ -194,7 +189,6 @@ router.put('/updatemt/:id',fetchuser, async(req,res) => {
user = await User.findByIdAndUpdate(req.params.id, {maxToken:newVal.maxToken},{new:true})
res.json({user})
}catch(error){
console.error(error.message)
res.status(500).send("Internal Server Error")
}
})
Expand Down Expand Up @@ -231,7 +225,6 @@ router.post('/checkuser',fetchuser,async(req,res) => {
}
res.json({curTokens,ready})
}catch(error){
console.error(error.message)
res.status(500).send("Internal Server Error")
}
})
Expand All @@ -250,7 +243,6 @@ router.delete('/deleteuser/:id',fetchuser, async(req,res) =>{
user = await User.findByIdAndDelete(req.params.id)
res.json({"success":"User has been deleted"})
}catch(error){
console.error(error.message)
res.status(500).send("Internal Server Error")
}
})
Expand Down
1 change: 0 additions & 1 deletion Microservices/User_auth/routes/moretokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ router.post('/getmore',fetchuser, async (req,res) => {
success=true
res.json({success})
}catch(error){
console.error(error)
res.status(500).send('internal server error')
}
})
Expand Down
Binary file added public/apple-touch-icon.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<head>
<!-- Google tag (gtag.js) -->
<meta charset="utf-8" />
<link rel="icon" href="Docster.png" />
<!-- <link rel="icon" href="Docster.png" /> -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> -->
<meta
name="description"
content="AI based Document Chat System with PDF, TXT, CSV, Excel and SQL files."
content="AI based Document Chat System with PDF, TXT, CSV, Excel, PPTX, DOCX and SQL files."
/>
<!-- <link rel="apple-touch-icon" href="%PUBLIC_URL%/apple-icon-144x144.png" /> -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
Expand Down
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Forgot from './Components/Forgot';
import Terms from './Components/Terms';
import Cookies from './Components/Cookies';
import Scrooltotop from './Components/Scrooltotop';
import Upcoming from './Components/Upcoming';

function App() {
const [alert, setAlert] = useState(null)
Expand Down Expand Up @@ -55,7 +56,7 @@ function App() {
return (
<>
<div>
<UserState host={{host}}>
<UserState host={{host, showAlert}}>
<Router>
<Scrooltotop/>
<Navbar prop={{host,Logdin,showAlert}}/>
Expand All @@ -73,6 +74,7 @@ function App() {
<Route exact path='/pricing' element={<Pricing/>}></Route>
<Route exact path='/faq' element={<Faq/>}></Route>
<Route exact path='/in/terms' element={<Terms />}></Route>
<Route exact path='/upcomings' element={<Upcoming />}></Route>
<Route exact path='/forgot-password' element={<Forgot prop={{host, showAlert}} />}></Route>
</Routes>
<Cookies/>
Expand Down
10 changes: 2 additions & 8 deletions src/Components/Alert.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import React from 'react'

export default function Alert(props) {
const capitalize = (word) => {
if(word === 'danger'){
word = "Error"
}
let nword = word.toLowerCase();
return nword.charAt(0).toUpperCase() + nword.slice(1);
}
const icons = {primary:'fa-circle-info',success:'fa-circle-check',danger:'fa-circle-exclamation'}
return (
<div>
<div style={{height :'50px',marginTop:'55px'}}>
{props.alert && <div className={`alert alert-${props.alert.type} alert-dismissible fade show fixed-top`} role="alert" style={{marginTop:'55px'}}>
<strong>{capitalize(props.alert.type)}</strong> : {props.alert.msg}
<strong><i className={`fa-solid ${icons[props.alert.type]} me-2`}></i></strong> {props.alert.msg}
</div>}
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/Components/Faq.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Faq = () => {
</h2>
<div id="flush-collapseOne" class="accordion-collapse collapse" aria-labelledby="flush-headingOne" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">
Docschat Support five types of Documents
Docschat Support Seven types of Documents
<ul>
<li><strong>PDF : </strong>Any type of PDF files: text, images or mixed</li>
<li><strong>TXT : </strong>Any type of text file</li>
Expand Down Expand Up @@ -52,7 +52,7 @@ const Faq = () => {
</button>
</h2>
<div id="flush-collapseThree" className="accordion-collapse collapse" aria-labelledby="flush-headingThree" data-bs-parent="#accordionFlushExample">
<div className="accordion-body">we do not collect and process the data contained in these documents neither we store your document to our servers , rather we convert the content in vector store which can only be understand by Large Language Model to provide you with our services.</div>
<div className="accordion-body">We do not collect and process the data contained in these documents neither we store your document to our servers , rather we convert the content in vector store which can only be understand by Large Language Model to provide you with our services.</div>
</div>
</div>
</div>
Expand Down
45 changes: 40 additions & 5 deletions src/Components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
import React from 'react'
import React, { useState } from 'react'
import { Link } from 'react-router-dom'
import '../Styling/footer.css'
import { useMediaQuery } from 'react-responsive'

const Footer = () => {
const Footer = (props) => {
const isTabletOrMobile = useMediaQuery({ query: '(max-width: 1224px)' })
const [thumbs, setThumbs] = useState(localStorage.getItem('thumbs') || 'regular')
const [info, setInfo] = useState("")
const {host} = props.prop

const changeThumb = async()=>{
if(thumbs === 'regular'){
setThumbs('solid')
localStorage.setItem('thumbs','solid')
setInfo(' Thankyou for your support')
setTimeout(()=>{
setInfo("")
},2000)
try{
await fetch(`${host}/api/access/likes`,{
method:'PUT'
})
}catch(err){}
}else{
setThumbs('regular')
localStorage.setItem('thumbs','regular')
setInfo(' Sorry! If you found it Unuseful')
setTimeout(()=>{
setInfo("")
},2000)
}
}
return (
<>
<div className='text-black pt-4' style={{background:'#e0e0e0'}}>
Expand All @@ -16,18 +44,25 @@ const Footer = () => {
<li className='list-inline-item'><button className='btn btn-default'><Link to={'/contactus'} style={{textDecoration:'none', color:'black'}}>Feedback</Link></button></li>
<li className='list-inline-item'><button className='btn btn-default'><Link to={'/contactus'} style={{textDecoration:'none', color:'black'}}>Report an Issue</Link></button></li>
<li className='list-inline-item'><button className='btn btn-default'><Link to={'/faq'} style={{textDecoration:'none', color:'black'}}>FAQs</Link></button></li>
<li className='list-inline-item'><button className='btn btn-default'><Link to={'/upcomings'} style={{textDecoration:'none', color:'black'}}>Upcoming Features</Link></button></li>

</ul>
</div>
<hr/>
<div>
<p className='ms-3' style={{fontSize:'14px'}}>If you found anything useful, kindly show support by clicking the like button <button className='btn btn-default' onClick={changeThumb}style={{color:'blue'}}> <i className={`fa-${thumbs} fa-thumbs-up fs-2`}></i></button>{info}</p>
</div>
</div>

</div>
</div>
<div className='text-white bg-dark pt-3'>
<div className="container" id='copy'>
<div>
<div style={isTabletOrMobile?{marginTop:'-2%'}:{}}>
<p className='text-center' > &copy; 2024 Docschat</p>
</div>
<div>
<p className='text-center'>Updated on : 03 July, 2024 V: 1.4</p>
<div style={isTabletOrMobile?{marginTop:'-3%'}:{}}>
<p className='text-center'>Updated on : 05 July, 2024 V: 1.4</p>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Forgot.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const Forgot = (props) => {
<form onSubmit={otp ===""?handleSubmit:verifyotp}>
<div className="mb-3">
<label for="exampleInputEmail1" class="form-label">Enter your Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder='Email' value={email} onChange={(e) =>setEmail(e.target.value)}/>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder='Email' value={email} onChange={(e) =>setEmail(e.target.value)} required/>
</div>
<div className={`mb-3 ${otptf}`} >
<input type="number" class="form-control" id="otp" aria-describedby="otpHelp" placeholder='Enter OTP' value={otp} onChange={otpChange}/>
Expand All @@ -166,7 +166,7 @@ const Forgot = (props) => {
<form onSubmit={changePass}>
<div className="mb-3">
<label for="password" class="form-label">New Password</label>
<input type="password" class="form-control" aria-describedby="passhelp" placeholder='Create Password' name='pass' value={newpass.pass} onChange={passChange}required/>
<input type="password" class="form-control" aria-describedby="passhelp" placeholder='Create Password' name='pass' value={newpass.pass} onChange={passChange} required/>
</div>
<div className="mb-3">
<label for="cpassword" class="form-label">Confirm Password</label>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Home = (props) => {
<Main prop={{login, Logdout}}/>
<Info/>
<Tasks prop={{host, showAlert, llm_host}}/>
<Footer/>
<Footer prop={{host}}/>
</>
)
}
Expand Down
8 changes: 8 additions & 0 deletions src/Components/Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ const Info = () => {

<h5 className='mt-4'>Encourage Originality and Boost Document Interactions</h5>
<p className='text-muted'>Imagine a future in which documents do more than just sit there passively on your screen—they answer your questions, carry on conversations, and help you learn new things. Docschat is an interactive conversation tool for your files, not just a reading tool. Your documents come to life thanks to this AI document interaction; they become not merely intelligent but also an extension of your team.</p>
<h5 className='mt-4'>Documents Supported</h5>
<button type="button" class="btn btn-outline-dark btn-sm me-1 mt-2" disabled>PDF</button>
<button type="button" class="btn btn-outline-dark mx-1 btn-sm mt-2" disabled>TXT</button>
<button type="button" class="btn btn-outline-dark mx-1 btn-sm mt-2" disabled>CSV</button>
<button type="button" class="btn btn-outline-dark mx-1 btn-sm mt-2" disabled>Excel</button>
<button type="button" class="btn btn-outline-dark mx-1 btn-sm mt-2" disabled>PPT</button>
<button type="button" class="btn btn-outline-dark mx-1 btn-sm mt-2" disabled>DOCX</button>
<button type="button" class="btn btn-outline-dark me-1 btn-sm mt-2" disabled>SQL</button>
<p className='text-end'><Link to='/about' style={{textDecoration:'none', color:'black', fontWeight:'bold'}}>See More</Link></p>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/Components/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Navbar = (props) => {
dispatch(changeFile("default",()=>{}))
dispatch(setSID("default",()=>{}))
navigate("/")
showAlert('Logged Out','primary')
rollNavBack()
Logdin()
}
Expand Down Expand Up @@ -120,7 +121,7 @@ const Navbar = (props) => {
<nav className="navbar fixed-top navbar-expand-lg navbar-dark bg-dark">
<div className="container-fluid">
<Link className="navbar-brand" to="/">
<img src="favicon-32x32.png" alt="" width="30" height="30"/>
<img src="apple-touch-icon.ico" alt="" width="30" height="30"/>
</Link>
<Link className="navbar-brand" to="/">Docschat</Link>
<button className="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" ref={ref}>
Expand All @@ -146,8 +147,8 @@ const Navbar = (props) => {

</ul>
{( !localStorage.getItem('token')) ?<form className='d-flex'>
<Link style={{display: `${location.pathname === '/' || location.pathname === '/login' ?"none":"initial"}`}} className='btn btn-primary mx-1' role='button' to="/login" onClick={rollNavBack}>Login</Link>
<Link style={{display: `${location.pathname === '/' || location.pathname === '/signup' ?"none":"initial"}`}} className='btn btn-primary mx-1' role='button' to='/signup' onClick={rollNavBack}>Signup</Link>
<Link style={{display: `${location.pathname === '/' || location.pathname === '/login' ?"none":"initial"}`}} className='btn btn-primary btn-sm mx-1' role='button' to="/login" onClick={rollNavBack}>Login</Link>
<Link style={{display: `${location.pathname === '/' || location.pathname === '/signup' ?"none":"initial"}`}} className='btn btn-primary btn-sm mx-1' role='button' to='/signup' onClick={rollNavBack}>Signup</Link>
</form>:
<div className="btn-group">
<button type="button" className="btn btn-secondary dropdown-toggle mx-2 me-2" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
Expand Down
Loading

0 comments on commit 5e31aeb

Please sign in to comment.