├── .env.example
├── .gitignore
├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── _eslintrc.cjs
├── next.config.mjs
├── package-lock.json
├── package.json
├── postcss.config.cjs
├── prettier.config.cjs
├── prisma
└── schema.prisma
├── public
├── assets
│ └── hero-image.svg
├── favicon.ico
├── hero.riv
└── logo.png
├── src
├── components
│ ├── animation
│ │ ├── character.tsx
│ │ ├── pop.tsx
│ │ ├── text.tsx
│ │ └── typing.tsx
│ ├── captions
│ │ └── index.tsx
│ ├── card
│ │ └── index.tsx
│ ├── features
│ │ └── index.tsx
│ ├── footer
│ │ └── index.tsx
│ ├── join
│ │ └── index.tsx
│ ├── loader
│ │ └── index.tsx
│ ├── modal
│ │ └── index.tsx
│ ├── navbar
│ │ └── index.tsx
│ ├── splashScreen
│ │ └── index.tsx
│ └── tabs
│ │ └── index.tsx
├── env.mjs
├── hooks
│ └── useTranscribe.ts
├── lib
│ ├── Debug.tsx
│ ├── client-utils.tsx
│ ├── serverUtils.ts
│ └── type.ts
├── pages
│ ├── _app.tsx
│ ├── api
│ │ ├── auth
│ │ │ └── [...nextauth].ts
│ │ ├── pusher.ts
│ │ └── trpc
│ │ │ └── [trpc].ts
│ ├── index.tsx
│ ├── profile.tsx
│ └── rooms
│ │ └── [name].tsx
├── server
│ ├── api
│ │ ├── root.ts
│ │ ├── routers
│ │ │ ├── pusher.ts
│ │ │ └── rooms.ts
│ │ └── trpc.ts
│ ├── auth.ts
│ └── db.ts
├── styles
│ └── globals.css
└── utils
│ ├── api.ts
│ ├── pusher.ts
│ └── speak.ts
├── tailwind.config.cjs
└── tsconfig.json
/.env.example:
--------------------------------------------------------------------------------
1 | # Since the ".env" file is gitignored, you can use the ".env.example" file to
2 | # build a new ".env" file when you clone the repo. Keep this file up-to-date
3 | # when you add new variables to `.env`.
4 |
5 | # This file will be committed to version control, so make sure not to have any
6 | # secrets in it. If you are cloning this repo, create a copy of this file named
7 | # ".env" and populate it with your secrets.
8 |
9 | # When adding additional environment variables, the schema in "/src/env.mjs"
10 | # should be updated accordingly.
11 |
12 | # Prisma
13 | # https://www.prisma.io/docs/reference/database-reference/connection-urls#env
14 | DATABASE_URL=""
15 |
16 | # Next Auth
17 | # You can generate a new secret on the command line with:
18 | # openssl rand -base64 32
19 | # https://next-auth.js.org/configuration/options#secret
20 | NEXTAUTH_SECRET=""
21 | NEXTAUTH_URL=""
22 |
23 | # Next Auth Google Provider
24 | GOOGLE_CLIENT_ID=""
25 | GOOGLE_CLIENT_SECRET=""
26 |
27 | # Livekit
28 | LIVEKIT_API_KEY=""
29 | LIVEKIT_API_SECRET=""
30 | NEXT_PUBLIC_LIVEKIT_API_HOST=""
31 |
32 | # Pusher
33 | PUSHER_APP_ID = ""
34 | PUSHER_KEY = ""
35 | PUSHER_SECRET = ""
36 | PUSHER_CLUSTER = ""
37 | NEXT_PUBLIC_PUSHER_KEY= ""
38 | NEXT_PUBLIC_PUSHER_CLUSTER= ""
39 |
40 | # OneAI
41 | ONEAI_API_KEY=""
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # database
12 | /prisma/db.sqlite
13 | /prisma/db.sqlite-journal
14 |
15 | # next.js
16 | /.next/
17 | /out/
18 | next-env.d.ts
19 |
20 | # production
21 | /build
22 |
23 | # misc
24 | .DS_Store
25 | *.pem
26 |
27 | # debug
28 | npm-debug.log*
29 | yarn-debug.log*
30 | yarn-error.log*
31 | .pnpm-debug.log*
32 |
33 | # local env files
34 | # do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
35 | .env
36 | .env*.local
37 |
38 | # vercel
39 | .vercel
40 |
41 | # typescript
42 | *.tsbuildinfo
43 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | "livekit"
4 | ]
5 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | > **Note**
2 | > We have rebuilt the Entire architecture during a 24 hour Hackathon and brought down the latency to just 3-5 seconds. Checkout the [new repo](https://github.com/nagarajpandith/hackverse) for the latest version of the project.
3 |
4 | 
5 | [Live Demo](https://jabwemeet.vercel.app/) | [Pitch Deck](https://www.canva.com/design/DAFdhOPv1eA/qvB2ivAdB--1m9PxY-buWw/view?utm_content=DAFdhOPv1eA&utm_campaign=designshare&utm_medium=link&utm_source=publishsharelink) | [Hackoverflow 1.0](https://hack-overflow.tech/)
6 |
7 | # Jab We Meet
8 | Jab We Meet is a web application that allows users who speak different languages to converse with ease by translating the audio on the fly and speaking the translated audio in the native language of the user as well as provide them with translated captions. It also offers HD video and screen share, and can accommodate up to 100 concurrent users. The application also generates automatic meeting summaries and transcripts, making it easy for participants to review important details from the meeting.
9 |
10 | > This is the Winning solution developed at 36-hour National Level hackathon called 'Hackoverflow 1.0' by PHCET, Navi Mumbai.
11 |
12 | 
13 |
14 | ## Use cases
15 | - Startups and MNCs with international work culture.
16 | - Freelancers with daily foreign communication.
17 | - Content creators & live streamers to reach global range audience.
18 | - Educational organizations to teach courses to multilingual students.
19 |
20 | ## Built with
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | - [**Next JS**](https://nextjs.org/): React-based framework for building server-side rendered and statically exported web apps.
32 | - [**Typescript**](https://www.typescriptlang.org/): Statically typed superset of JavaScript, adds type annotations to enhance code reliability & readability
33 | - [**Livekit**](https://livekit.io/): End-to-end WebRTC infrastructure to build live video and audio applications.
34 | - [**Pusher**](https://pusher.com/): WebSockets solution for Realtime updates and bidirectional communication.
35 | - [**TailwindCSS**](https://tailwindcss.com/): Utility-first CSS framework
36 | - [**Planetscale**](https://planetscale.com/): Highly scalable, globally distributed database
37 | - [**tRPC**](https://trpc.io/): Provides a simple, type-safe way to build APIs for TS & JS
38 | - [**Prisma ORM**](https://www.prisma.io/): Modern, type-safe ORM for Node.js and TS
39 | - **APIs used**: Browser's [Webspeech](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API) API for transcribing and tts/speech synthesis. [Google-translate-browser](https://www.npmjs.com/package/google-translate-api-browser) API for translating texts, OneAI's [Summarizer](https://www.oneai.com/summarize) for summarizations of meeting transcripts.
40 |
41 | > **Note**
42 | > This project was bootstrapped with [create-t3-app](https://create.t3.gg/). Check [package.json](https://github.com/swasthikshetty10/hackoverflow/blob/main/package.json) to know all the dependencies and tech stack we used.
43 |
44 | ## Features
45 | - Multilingual Meeting Support
46 | - Real-time Translation and Transcriptions
47 | - Automatic Meeting Minutes generation
48 | - Support to upto 100 concurrent users
49 | - Supports HQ Video streaming
50 |
51 | ## Architecture
52 |
53 |
54 | ## Installation steps
55 |
56 | 1. - Fork the [repo](https://github.com/swasthikshetty10/hackoverflow)
57 | - Clone the repo to your local system `git clone https://github.com/swasthikshetty10/hackoverflow.git`
58 | - Change current directory `cd hackoverflow`
59 | 2. Install latest version of [Nodejs](https://nodejs.org/en/) and install all the dependencies:
60 |
61 | ```bash
62 | npm install
63 | ```
64 |
65 | 3. Generate prisma client
66 |
67 | ```bash
68 | npx prisma generate
69 | ```
70 |
71 | 4. Copy and Rename the .env.example to .env, place it in the root directory and fill the essential vars.
72 |
73 | ```bash
74 | cp .env.example .env
75 | ```
76 |
77 | > **Warning**
78 | > Do not rename the original .env.example, it is used to keep track for env vars list as .env with values is gitignored
79 |
80 | 5. Run the development server:
81 |
82 | ```bash
83 | npm run dev
84 | ```
85 |
86 | ## Known Issues
87 | - There is latency of around 5-6 seconds between the original time and the time when translated audio is spoken out. The latency issue can be tackled by following ways:
88 | - Use native models for faster transcriptions
89 | - Use paid APIs for quicker translations like Whisper AI, Google translate etc.
90 | - Develop a learning model to predict the next moves of the speaker, which is a replacement for WebSpeech API's final transcription boolean.
91 | - As the app relies on browser's native Web Speech API for transcribing and tts, few browsers like Brave with known issues for this API and microphone functions tend to fail at running the app successfully.
92 |
93 | ## Future scope of development
94 | - Use deepAI models to sync video/lip movements & translated audio.
95 | - Resemble the spoken audio(translated) to source audio(speaker) pitch.
96 |
97 | ## Team Members
98 |
99 | | | | |
100 | | :-----------------------------------------------------------------------------: | :-----------------------------------------------------------------------------: | :------------------------------------------------------------------------------: |
101 | | [Nagaraj Pandith](https://github.com/nagarajpandith/) | [Swasthik Shetty](https://github.com/swasthikshetty10/](https://github.com/rudra246)>) | [Tanishka Rao](https://github.com/tanishkarao16) |
102 |
103 | ## License
104 | [](https://opensource.org/licenses/Apache-2.0)
105 |
106 | This repository is licensed under [Apache License 2.0](https://github.com/swasthikshetty10/hackoverflow/blob/main/LICENSE)
107 |
108 | ## Attributions
109 |
110 | - [Icon from - Flaticon](https://www.flaticon.com/free-icons/)
--------------------------------------------------------------------------------
/_eslintrc.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import("eslint").Linter.Config} */
2 | const config = {
3 | overrides: [
4 | {
5 | extends: [
6 | "plugin:@typescript-eslint/recommended-requiring-type-checking",
7 | ],
8 | files: ["*.ts", "*.tsx"],
9 | parserOptions: {
10 | project: "tsconfig.json",
11 | },
12 | },
13 | ],
14 | parser: "@typescript-eslint/parser",
15 | parserOptions: {
16 | project: "./tsconfig.json",
17 | },
18 | plugins: ["@typescript-eslint"],
19 | extends: ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"],
20 | rules: {
21 | "@typescript-eslint/consistent-type-imports": [
22 | "warn",
23 | {
24 | prefer: "type-imports",
25 | fixStyle: "inline-type-imports",
26 | },
27 | ],
28 | "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
29 | },
30 | };
31 |
32 | module.exports = config;
33 |
--------------------------------------------------------------------------------
/next.config.mjs:
--------------------------------------------------------------------------------
1 | // @ts-check
2 |
3 | /**
4 | * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
5 | * This is especially useful for Docker builds.
6 | */
7 | !process.env.SKIP_ENV_VALIDATION && (await import("./src/env.mjs"));
8 |
9 | /** @type {import("next").NextConfig} */
10 | const config = {
11 | reactStrictMode: true,
12 |
13 | /**
14 | * If you have the "experimental: { appDir: true }" setting enabled, then you
15 | * must comment the below `i18n` config out.
16 | *
17 | * @see https://github.com/vercel/next.js/issues/41980
18 | */
19 | i18n: {
20 | locales: ["en"],
21 | defaultLocale: "en",
22 | },
23 | images: {
24 | domains: ['lh3.googleusercontent.com']
25 | }
26 | };
27 | export default config;
28 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hackoverflow",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "build": "next build",
7 | "dev": "next dev",
8 | "postinstall": "prisma generate",
9 | "lint": "next lint",
10 | "start": "next start"
11 | },
12 | "dependencies": {
13 | "@headlessui/react": "^1.7.13",
14 | "@livekit/components-react": "0.6.2",
15 | "@livekit/components-styles": "0.2.1",
16 | "@next-auth/prisma-adapter": "^1.0.5",
17 | "@prisma/client": "^4.11.0",
18 | "@rive-app/react-canvas": "^3.0.38",
19 | "@tanstack/react-query": "^4.28.0",
20 | "@trpc/client": "^10.18.0",
21 | "@trpc/next": "^10.18.0",
22 | "@trpc/react-query": "^10.18.0",
23 | "@trpc/server": "^10.18.0",
24 | "@vitalets/google-translate-api": "^9.1.0",
25 | "axios": "^1.3.4",
26 | "framer-motion": "^10.9.0",
27 | "google-translate-api-browser": "^3.0.1",
28 | "livekit-client": "^1.7.1",
29 | "livekit-server-sdk": "^1.1.0",
30 | "next": "^13.2.4",
31 | "next-auth": "^4.20.1",
32 | "nodejs-text-summarizer": "^2.0.3",
33 | "openai": "^3.2.1",
34 | "pusher": "^5.1.2",
35 | "pusher-js": "^8.0.2",
36 | "react": "18.2.0",
37 | "react-dom": "18.2.0",
38 | "react-icons": "^4.8.0",
39 | "react-speech-recognition": "^3.10.0",
40 | "react-type-animation": "^3.0.1",
41 | "superjson": "1.12.2",
42 | "transliteration": "^2.3.5",
43 | "zod": "^3.21.4"
44 | },
45 | "devDependencies": {
46 | "@types/react-speech-recognition": "^3.9.1",
47 | "@types/eslint": "^8.21.3",
48 | "@types/google-translate-api": "^2.3.2",
49 | "@types/node": "^18.15.7",
50 | "@types/prettier": "^2.7.2",
51 | "@types/react": "^18.0.28",
52 | "@types/react-dom": "^18.0.11",
53 | "@typescript-eslint/eslint-plugin": "^5.56.0",
54 | "@typescript-eslint/parser": "^5.56.0",
55 | "autoprefixer": "^10.4.14",
56 | "eslint": "^8.36.0",
57 | "eslint-config-next": "^13.2.4",
58 | "postcss": "^8.4.21",
59 | "prettier": "^2.8.7",
60 | "prettier-plugin-tailwindcss": "^0.2.5",
61 | "prisma": "^4.11.0",
62 | "tailwindcss": "^3.2.7",
63 | "typescript": "^5.0.2"
64 | },
65 | "ct3aMetadata": {
66 | "initVersion": "7.7.0"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/postcss.config.cjs:
--------------------------------------------------------------------------------
1 | const config = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
8 | module.exports = config;
9 |
--------------------------------------------------------------------------------
/prettier.config.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import("prettier").Config} */
2 | const config = {
3 | plugins: [require.resolve("prettier-plugin-tailwindcss")],
4 | };
5 |
6 | module.exports = config;
7 |
--------------------------------------------------------------------------------
/prisma/schema.prisma:
--------------------------------------------------------------------------------
1 | // This is your Prisma schema file,
2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema
3 |
4 | generator client {
5 | provider = "prisma-client-js"
6 | }
7 |
8 | datasource db {
9 | provider = "mysql"
10 | url = env("DATABASE_URL")
11 | relationMode = "prisma"
12 | }
13 |
14 | model Example {
15 | id String @id @default(cuid())
16 | createdAt DateTime @default(now())
17 | updatedAt DateTime @updatedAt
18 | }
19 |
20 | // Necessary for Next auth
21 | model Account {
22 | id String @id @default(cuid())
23 | userId String
24 | type String
25 | provider String
26 | providerAccountId String
27 | refresh_token String? @db.Text
28 | access_token String? @db.Text
29 | expires_at Int?
30 | token_type String?
31 | scope String?
32 | id_token String? @db.Text
33 | session_state String?
34 | user User @relation(fields: [userId], references: [id], onDelete: Cascade)
35 |
36 | @@unique([provider, providerAccountId])
37 | @@index([userId], name: "userId")
38 | }
39 |
40 | model Session {
41 | id String @id @default(cuid())
42 | sessionToken String @unique
43 | userId String
44 | expires DateTime
45 | user User @relation(fields: [userId], references: [id], onDelete: Cascade)
46 |
47 | @@index([userId], name: "userId")
48 | }
49 |
50 | model User {
51 | id String @id @default(cuid())
52 | name String?
53 | email String? @unique
54 | emailVerified DateTime?
55 | image String?
56 | accounts Account[]
57 | sessions Session[]
58 | Room Room[]
59 | Participant Participant[]
60 | Transcript Transcript[]
61 | }
62 |
63 | model VerificationToken {
64 | identifier String
65 | token String @unique
66 | expires DateTime
67 |
68 | @@unique([identifier, token])
69 | }
70 |
71 | model Room {
72 | createdAt DateTime @default(now())
73 | updatedAt DateTime @updatedAt
74 | name String @id @unique @default(cuid())
75 | metadata String? @db.Text
76 | slug String?
77 | OwnerId String
78 | Owner User @relation(fields: [OwnerId], references: [id], onDelete: Cascade)
79 | summary String? @db.Text
80 | Participant Participant[]
81 | transcripts Transcript[]
82 |
83 | @@index([OwnerId])
84 | }
85 |
86 | model Transcript {
87 | id String @id @default(cuid())
88 | createdAt DateTime @default(now())
89 | updatedAt DateTime @updatedAt
90 | RoomName String
91 | Room Room @relation(fields: [RoomName], references: [name], onDelete: Cascade)
92 | text String @db.Text
93 | UserId String
94 | User User @relation(fields: [UserId], references: [id], onDelete: Cascade)
95 |
96 | @@index([RoomName])
97 | @@index([UserId])
98 | }
99 |
100 | model Participant {
101 | createdAt DateTime @default(now())
102 | updatedAt DateTime @updatedAt
103 | UserId String
104 | User User @relation(fields: [UserId], references: [id], onDelete: Cascade)
105 | RoomName String
106 | Room Room @relation(fields: [RoomName], references: [name], onDelete: Cascade)
107 |
108 | @@id([UserId, RoomName])
109 | @@index([UserId])
110 | @@index([RoomName])
111 | }
112 |
--------------------------------------------------------------------------------
/public/assets/hero-image.svg:
--------------------------------------------------------------------------------
1 |
2 | 12083704_Wavy_Bus-35_Single-02-ai
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swasthikshetty10/hackoverflow/0b245c9d147da00825536d736b0dbf096b3a5329/public/favicon.ico
--------------------------------------------------------------------------------
/public/hero.riv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swasthikshetty10/hackoverflow/0b245c9d147da00825536d736b0dbf096b3a5329/public/hero.riv
--------------------------------------------------------------------------------
/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swasthikshetty10/hackoverflow/0b245c9d147da00825536d736b0dbf096b3a5329/public/logo.png
--------------------------------------------------------------------------------
/src/components/animation/character.tsx:
--------------------------------------------------------------------------------
1 | import React, { FC, useRef } from 'react';
2 | import { motion, useInView } from 'framer-motion';
3 |
4 | const CharacterAnimation: FC<{
5 | text: string;
6 | className?: string;
7 | textStyle?: string;
8 | }> = ({ text, className, textStyle }) => {
9 | const ref = useRef(null);
10 | const isInView = useInView(ref, { once: true });
11 | const letters = Array.from(text);
12 |
13 | const container = {
14 | hidden: { opacity: 0 },
15 | visible: (i = 1) => ({
16 | opacity: 1,
17 | transition: { staggerChildren: 0.03, delayChildren: 0.04 * i },
18 | }),
19 | };
20 |
21 | const child = {
22 | visible: {
23 | opacity: 1,
24 | y: 0,
25 | transition: {
26 | type: 'spring',
27 | damping: 12,
28 | stiffness: 100,
29 | },
30 | },
31 | hidden: {
32 | opacity: 0,
33 | y: 20,
34 | transition: {
35 | type: 'spring',
36 | damping: 12,
37 | stiffness: 100,
38 | },
39 | },
40 | };
41 |
42 | return (
43 |
51 | {letters.map((letter, index) => (
52 |
53 | {letter === ' ' ? '\u00A0' : letter}
54 |
55 | ))}
56 |
57 | );
58 | };
59 |
60 | export default CharacterAnimation;
--------------------------------------------------------------------------------
/src/components/animation/pop.tsx:
--------------------------------------------------------------------------------
1 | import React, { FC, ReactNode, useRef } from "react";
2 | import { motion, useInView } from "framer-motion";
3 |
4 | const PopAnimation: FC<{
5 | className?: string;
6 | children: ReactNode;
7 | }> = ({ className, children }) => {
8 | const ref = useRef(null);
9 | const isInView = useInView(ref, { once: true });
10 |
11 | return (
12 |
38 | {children}
39 |
40 | );
41 | };
42 |
43 | export default PopAnimation;
44 |
--------------------------------------------------------------------------------
/src/components/animation/text.tsx:
--------------------------------------------------------------------------------
1 | import React, { FC, useRef } from "react";
2 | import { motion, useInView } from "framer-motion";
3 |
4 | const TextAnimation: FC<{
5 | text: string;
6 | className?: string;
7 | textStyle?: string;
8 | }> = ({ text, className, textStyle }) => {
9 | const ref = useRef(null);
10 | const isInView = useInView(ref, { once: true });
11 | const words = text.split(" ");
12 |
13 | const container = {
14 | hidden: { opacity: 0 },
15 | visible: (i = 1) => ({
16 | opacity: 1,
17 | transition: { staggerChildren: 0.12, delayChildren: 0.04 * i },
18 | }),
19 | };
20 |
21 | const child = {
22 | visible: {
23 | opacity: 1,
24 | y: 0,
25 | transition: {
26 | type: "spring",
27 | damping: 12,
28 | stiffness: 100,
29 | },
30 | },
31 | hidden: {
32 | opacity: 0,
33 | y: 20,
34 | transition: {
35 | type: "spring",
36 | damping: 12,
37 | stiffness: 100,
38 | },
39 | },
40 | };
41 |
42 | return (
43 |
51 | {words.map((word, index) => (
52 |
58 | {word}
59 |
60 | ))}
61 |
62 | );
63 | };
64 |
65 | export default TextAnimation;
66 |
--------------------------------------------------------------------------------
/src/components/animation/typing.tsx:
--------------------------------------------------------------------------------
1 | import { TypeAnimation } from "react-type-animation";
2 |
3 | export default function Typing() {
4 | return (
5 |
12 | );
13 | }
14 |
--------------------------------------------------------------------------------
/src/components/captions/index.tsx:
--------------------------------------------------------------------------------
1 | import React, { Dispatch, SetStateAction, useEffect, useState } from "react";
2 | import { setCORS } from "google-translate-api-browser";
3 | import speakOut from "~/utils/speak";
4 | import langs from "google-translate-api-browser/dist/languages";
5 |
6 | const translate = setCORS("https://corsanywhere.herokuapp.com/");
7 |
8 | type Transcription = {
9 | sender: string;
10 | message: string;
11 | senderId: string;
12 | isFinal: boolean;
13 | };
14 |
15 | interface Props {
16 | transcriptionQueue: Transcription[];
17 | setTranscriptionQueue: Dispatch>;
18 | languageCode: string;
19 | }
20 |
21 | const Captions: React.FC = ({
22 | transcriptionQueue,
23 | setTranscriptionQueue,
24 | languageCode,
25 | }) => {
26 | const [caption, setCaption] = useState<{ sender: string; message: string }>();
27 |
28 | useEffect(() => {
29 | async function translateText() {
30 | console.info("transcriptionQueue", transcriptionQueue);
31 | if (transcriptionQueue.length > 0) {
32 | const res = await translate(transcriptionQueue[0]?.message as string, {
33 | // @ts-ignore
34 | to: languageCode.split("-")[0],
35 | });
36 | setCaption({
37 | message: res.text,
38 | sender: transcriptionQueue[0]?.sender as string,
39 | });
40 | const isEmpty = transcriptionQueue.length === 0;
41 | speakOut(res.text as string, isEmpty);
42 | setTranscriptionQueue((prev) => prev.slice(1));
43 | }
44 | }
45 | translateText();
46 |
47 | // Hide the caption after 5 seconds
48 | const timer = setTimeout(() => {
49 | setCaption({
50 | message: "",
51 | sender: "",
52 | });
53 | }, 5000);
54 |
55 | return () => {
56 | clearTimeout(timer);
57 | };
58 | }, [transcriptionQueue]);
59 |
60 | return (
61 |
62 |
63 | {caption?.message ? (
64 | <>
65 |
{caption.sender}
66 |
:
67 | >
68 | ) : null}
69 |
{caption?.message}
70 |
71 |
72 | );
73 | };
74 |
75 | export default Captions;
76 |
--------------------------------------------------------------------------------
/src/components/card/index.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import Modal from "../modal";
3 | import { IoDocumentTextOutline } from "react-icons/io5";
4 | import PopAnimation from "../animation/pop";
5 | import TextAnimation from "../animation/text";
6 |
7 | function Card({
8 | room,
9 | }: {
10 | room: {
11 | name: string;
12 | slug: string | null;
13 | createdAt: Date;
14 | };
15 | }) {
16 | let [isOpen, setIsOpen] = useState(false)
17 |
18 | return (
19 |
20 |
21 |
22 |
{room.slug || room.name}
23 |
24 |
25 | {room.createdAt.toLocaleDateString("en-US", {
26 | year: "numeric",
27 | month: "long",
28 | day: "numeric",
29 | })}{" "}
30 | at{" "}
31 | {room.createdAt.toLocaleTimeString("en-US", {
32 | hour: "numeric",
33 | minute: "numeric",
34 | hour12: true,
35 | })}
36 |
37 |
38 |
39 | setIsOpen(true)}
41 | className="mt-5 flex flex-row items-center justify-center space-x-2 rounded-lg bg-gray-100 bg-opacity-5 p-2 backdrop-blur-lg backdrop-filter hover:bg-gray-100 hover:bg-opacity-10"
42 | >
43 |
47 | Details
48 |
49 |
50 |
51 | {isOpen && (
52 |
53 | )}
54 |
55 |
56 | );
57 | }
58 |
59 | export default Card;
60 |
--------------------------------------------------------------------------------
/src/components/features/index.tsx:
--------------------------------------------------------------------------------
1 | import { RiTranslate } from "react-icons/ri";
2 | import { MdHighQuality } from "react-icons/md";
3 | import { BsGlobe2 } from "react-icons/bs";
4 | import { HiOutlineDocumentText, HiUserGroup } from "react-icons/hi";
5 | import { BsFillBookmarkHeartFill } from "react-icons/bs";
6 | import TextAnimation from "../animation/text";
7 | import PopAnimation from "../animation/pop";
8 |
9 | const Features = () => {
10 | const perks = [
11 | {
12 | icon: (
13 |
14 | ),
15 | title: "Multilingual Meeting Support",
16 | desc: "Our app allows users who speak different languages to communicate with each other. The app translates the text and speaks it out to other participants in the language they have selected.",
17 | },
18 | {
19 | icon: (
20 |
21 | ),
22 | title: "Real-time Translation",
23 | desc: "Our app provides real-time translation, so you can focus on the conversation without worrying about the language barrier. The translation is done quickly and accurately, ensuring smooth communication.",
24 | },
25 | {
26 | icon: (
27 |
31 | ),
32 | title: "Meeting Minutes",
33 | desc: "Our app automatically generates a summary of the entire meeting or conference. This feature saves time and helps ensure that all participants are on the same page.",
34 | },
35 | {
36 | icon: (
37 |
38 | ),
39 | title: "Large Capacity",
40 | desc: "Our app can support up to 100 concurrent users. This means that even large meetings and conferences can be easily accommodated, making it ideal for businesses, schools, and other organizations.",
41 | },
42 | {
43 | icon: (
44 |
48 | ),
49 | title: "HQ video and Screen Sharing",
50 | desc: "Our app provides high-quality video and screen sharing, ensuring that everyone can see and hear each other clearly. This feature helps to ensure that the meeting is productive and engaging.",
51 | },
52 | {
53 | icon: (
54 |
58 | ),
59 | title: "User friendly Interface",
60 | desc: "Our app has a user-friendly interface that is easy to navigate. This ensures that everyone can participate in the meeting or conference without any technical difficulties, making it ideal for users of all skill levels.",
61 | },
62 | ];
63 |
64 | return (
65 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
105 |
106 | );
107 | };
108 |
109 | export default Features;
110 |
--------------------------------------------------------------------------------
/src/components/footer/index.tsx:
--------------------------------------------------------------------------------
1 | import Image from "next/image";
2 | import Link from "next/link";
3 | import PopAnimation from "../animation/pop";
4 | import TextAnimation from "../animation/text";
5 |
6 | const Footer = () => {
7 | const links = [
8 | {
9 | label: "Home",
10 | path: "#",
11 | },
12 | {
13 | label: "About",
14 | path: "#about",
15 | },
16 | {
17 | label: "Contact",
18 | path: "#contact",
19 | },
20 | ];
21 | return (
22 |
58 | );
59 | };
60 |
61 | export default Footer;
62 |
--------------------------------------------------------------------------------
/src/components/join/index.tsx:
--------------------------------------------------------------------------------
1 | import { useRouter } from "next/router";
2 | import { useState } from "react";
3 | import { BsKeyboard } from "react-icons/bs";
4 | import CharacterAnimation from "../animation/character";
5 |
6 | const JoinRoom = () => {
7 | const [roomName, setRoomName] = useState("");
8 | const router = useRouter();
9 | return (
10 |
11 |
12 | setRoomName(e.target.value)}
15 | type="text"
16 | placeholder="Enter Room Name"
17 | className="rounded-md bg-white bg-opacity-30 p-2 text-white"
18 | />
19 |
23 |
24 |
25 | router.push(`/rooms/${roomName}`)}
31 | >
32 |
33 |
34 |
35 | );
36 | };
37 |
38 | export default JoinRoom;
39 |
--------------------------------------------------------------------------------
/src/components/loader/index.tsx:
--------------------------------------------------------------------------------
1 | import { BiLoader } from "react-icons/bi";
2 |
3 | const Loader = ({ className }: { className?: string }) => {
4 | return (
5 |
8 |
9 |
10 | );
11 | };
12 |
13 | export default Loader;
14 |
--------------------------------------------------------------------------------
/src/components/modal/index.tsx:
--------------------------------------------------------------------------------
1 | import { Dispatch, SetStateAction, type FunctionComponent } from "react";
2 | import { api } from "~/utils/api";
3 | import { Dialog, Transition } from "@headlessui/react";
4 | import { Fragment, useState } from "react";
5 | import Loader from "../loader";
6 | import Tabs from "../tabs";
7 |
8 | type ModalProps = {
9 | setIsOpen: Dispatch>;
10 | roomName: string;
11 | visible: boolean;
12 | };
13 |
14 | const Modal: FunctionComponent = ({
15 | setIsOpen,
16 | roomName,
17 | visible,
18 | }) => {
19 | const { data, error, isLoading } = api.rooms.getRoomSummary.useQuery({
20 | roomName,
21 | });
22 | console.log(data);
23 | // input array
24 | // output array-> contents [0].utterance
25 |
26 | return (
27 |
28 | setIsOpen(false)}
32 | >
33 |
42 |
43 |
44 |
45 |
46 |
47 |
56 |
57 |
61 | Meeting Details
62 |
63 |
64 | {isLoading ? (
65 |
66 | ) : data ? (
67 |
68 | {data.output[0].contents.length > 1 && (
69 |
73 | )}
74 |
75 | ) : (
76 |
77 | No summary available
78 |
79 | )}
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | );
88 | };
89 |
90 | export default Modal;
91 |
--------------------------------------------------------------------------------
/src/components/navbar/index.tsx:
--------------------------------------------------------------------------------
1 | import Image from "next/image";
2 | import Link from "next/link";
3 | import CharacterAnimation from "../animation/character";
4 | import { BiMenuAltRight as MenuIcon } from "react-icons/bi";
5 | import { AiOutlineClose as XIcon } from "react-icons/ai";
6 | import { useState } from "react";
7 | import { signIn, signOut } from "next-auth/react";
8 | import { Session } from "next-auth";
9 | import { FcGoogle } from "react-icons/fc";
10 | import PopAnimation from "../animation/pop";
11 | import Loader from "../loader";
12 |
13 | const Navbar = ({
14 | status,
15 | session,
16 | }: {
17 | status: "loading" | "authenticated" | "unauthenticated";
18 | session: Session | null;
19 | }) => {
20 | const links = [
21 | {
22 | label: "Home",
23 | path: "#",
24 | },
25 | {
26 | label: "About",
27 | path: "#about",
28 | },
29 | {
30 | label: "Contact",
31 | path: "#contact",
32 | },
33 | ];
34 |
35 | const [isMenuOpen, setIsMenuOpen] = useState(false);
36 |
37 | const toggleMenu = () => {
38 | setIsMenuOpen(!isMenuOpen);
39 | };
40 |
41 | return (
42 |
43 |
44 |
45 |
46 |
47 |
54 |
55 |
59 |
60 |
61 |
62 | {links.map((link) => (
63 |
68 |
72 |
73 | ))}
74 |
75 | {
78 | if (status === "authenticated") {
79 | signOut();
80 | } else {
81 | signIn("google");
82 | }
83 | }}
84 | >
85 | {status === "authenticated" ? (
86 | "Sign Out"
87 | ) : (
88 |
92 | )}
93 |
94 |
95 |
96 |
97 | English
98 |
99 |
100 |
101 |
102 |
103 | {status === "loading" ? (
104 |
105 | ) : status === "authenticated" ? (
106 |
113 | ) : null}
114 |
115 |
116 |
117 |
118 |
119 | {isMenuOpen ? (
120 |
121 | ) : (
122 |
123 | )}
124 |
125 |
126 |
127 | {isMenuOpen && (
128 |
129 | {links.map((link) => (
130 |
135 | {link.label}
136 |
137 | ))}
138 |
139 | {
142 | if (status === "authenticated") {
143 | signIn("google");
144 | } else {
145 | signOut();
146 | }
147 | }}
148 | >
149 | {status === "authenticated" ? "Sign Out" : "Sign In"}
150 |
151 |
152 | English
153 |
154 |
155 |
156 |
157 | {status === "loading" ? (
158 |
159 | ) : status === "authenticated" ? (
160 |
167 | ) : null}
168 |
169 |
170 |
171 | )}
172 |
173 |
174 | );
175 | };
176 |
177 | export default Navbar;
178 |
--------------------------------------------------------------------------------
/src/components/splashScreen/index.tsx:
--------------------------------------------------------------------------------
1 | import Image from "next/image";
2 | import Loader from "../loader";
3 |
4 | const SplashScreen = () => {
5 | return (
6 |
7 |
15 |
16 |
Jab We Meet
17 |
18 | Loading your experience...
19 |
20 |
21 |
22 |
23 | );
24 | };
25 |
26 | export default SplashScreen;
27 |
--------------------------------------------------------------------------------
/src/components/tabs/index.tsx:
--------------------------------------------------------------------------------
1 | import { Tab } from "@headlessui/react";
2 |
3 | function classNames(...classes: (string | undefined)[]) {
4 | return classes.filter(Boolean).join(" ");
5 | }
6 |
7 | export default function Tabs({
8 | summary,
9 | transcriptions,
10 | }: {
11 | summary: string;
12 | transcriptions: string[];
13 | }) {
14 | return (
15 |
16 |
17 |
18 |
20 | classNames(
21 | "w-full rounded-lg py-2.5 text-sm font-medium leading-5 ",
22 | " ring-opacity-60 ring-offset-2 ring-offset-blue-400 focus:outline-none focus:ring-2",
23 | selected
24 | ? "bg-secondary/10 shadow"
25 | : "text-blue-100 hover:bg-white/[0.12] hover:text-white"
26 | )
27 | }
28 | >
29 | Summary
30 |
31 |
32 |
34 | classNames(
35 | "w-full rounded-lg py-2.5 text-sm font-medium leading-5 ",
36 | "ring-white ring-opacity-60 ring-offset-2 ring-offset-blue-400 focus:outline-none focus:ring-2",
37 | selected
38 | ? "bg-secondary-300/10 shadow"
39 | : "text-blue-100 hover:bg-white/[0.12] hover:text-white"
40 | )
41 | }
42 | >
43 | Transcription
44 |
45 |
46 |
47 |
48 | {summary}
49 |
50 |
51 | {transcriptions.map((transcription: any, index) => {
52 | return (
53 |
54 |
{transcription?.speaker}
55 |
56 | {transcription.utterance}
57 |
58 |
59 | {transcription.timestamp}
60 |
61 |
62 | );
63 | })}
64 |
65 |
66 |
67 |
68 | );
69 | }
70 |
--------------------------------------------------------------------------------
/src/env.mjs:
--------------------------------------------------------------------------------
1 | import { z } from "zod";
2 |
3 | /**
4 | * Specify your server-side environment variables schema here. This way you can ensure the app isn't
5 | * built with invalid env vars.
6 | */
7 | const server = z.object({
8 | DATABASE_URL: z.string().url(),
9 | NODE_ENV: z.enum(["development", "test", "production"]),
10 | NEXTAUTH_SECRET:
11 | process.env.NODE_ENV === "production"
12 | ? z.string().min(1)
13 | : z.string().min(1).optional(),
14 | NEXTAUTH_URL: z.preprocess(
15 | // This makes Vercel deployments not fail if you don't set NEXTAUTH_URL
16 | // Since NextAuth.js automatically uses the VERCEL_URL if present.
17 | (str) => process.env.VERCEL_URL ?? str,
18 | // VERCEL_URL doesn't include `https` so it cant be validated as a URL
19 | process.env.VERCEL ? z.string().min(1) : z.string().url(),
20 | ),
21 | // Add `.min(1) on ID and SECRET if you want to make sure they're not empty
22 | GOOGLE_CLIENT_ID: z.string(),
23 | GOOGLE_CLIENT_SECRET: z.string(),
24 | });
25 |
26 | /**
27 | * Specify your client-side environment variables schema here. This way you can ensure the app isn't
28 | * built with invalid env vars. To expose them to the client, prefix them with `NEXT_PUBLIC_`.
29 | */
30 | const client = z.object({
31 | // NEXT_PUBLIC_CLIENTVAR: z.string().min(1),
32 | });
33 |
34 | /**
35 | * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
36 | * middlewares) or client-side so we need to destruct manually.
37 | *
38 | * @type {Record | keyof z.infer, string | undefined>}
39 | */
40 | const processEnv = {
41 | DATABASE_URL: process.env.DATABASE_URL,
42 | NODE_ENV: process.env.NODE_ENV,
43 | NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
44 | NEXTAUTH_URL: process.env.NEXTAUTH_URL,
45 | GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
46 | GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
47 | // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
48 | };
49 |
50 | // Don't touch the part below
51 | // --------------------------
52 |
53 | const merged = server.merge(client);
54 |
55 | /** @typedef {z.input} MergedInput */
56 | /** @typedef {z.infer} MergedOutput */
57 | /** @typedef {z.SafeParseReturnType} MergedSafeParseReturn */
58 |
59 | let env = /** @type {MergedOutput} */ (process.env);
60 |
61 | if (!!process.env.SKIP_ENV_VALIDATION == false) {
62 | const isServer = typeof window === "undefined";
63 |
64 | const parsed = /** @type {MergedSafeParseReturn} */ (
65 | isServer
66 | ? merged.safeParse(processEnv) // on server we can validate all env vars
67 | : client.safeParse(processEnv) // on client we can only validate the ones that are exposed
68 | );
69 |
70 | if (parsed.success === false) {
71 | console.error(
72 | "❌ Invalid environment variables:",
73 | parsed.error.flatten().fieldErrors,
74 | );
75 | throw new Error("Invalid environment variables");
76 | }
77 |
78 | env = new Proxy(parsed.data, {
79 | get(target, prop) {
80 | if (typeof prop !== "string") return undefined;
81 | // Throw a descriptive error if a server-side env var is accessed on the client
82 | // Otherwise it would just be returning `undefined` and be annoying to debug
83 | if (!isServer && !prop.startsWith("NEXT_PUBLIC_"))
84 | throw new Error(
85 | process.env.NODE_ENV === "production"
86 | ? "❌ Attempted to access a server-side environment variable on the client"
87 | : `❌ Attempted to access server-side environment variable '${prop}' on the client`,
88 | );
89 | return target[/** @type {keyof typeof target} */ (prop)];
90 | },
91 | });
92 | }
93 |
94 | export { env };
95 |
--------------------------------------------------------------------------------
/src/hooks/useTranscribe.ts:
--------------------------------------------------------------------------------
1 | import { useEffect } from "react";
2 | import SpeechRecognition, {
3 | useSpeechRecognition,
4 | } from "react-speech-recognition";
5 | import { api } from "~/utils/api";
6 |
7 | type UseTranscribeProps = {
8 | roomName: string;
9 | audioEnabled: boolean;
10 | languageCode?: string;
11 | };
12 |
13 | const useTranscribe = ({
14 | roomName,
15 | audioEnabled,
16 | languageCode,
17 | }: UseTranscribeProps) => {
18 | const {
19 | transcript,
20 | resetTranscript,
21 | finalTranscript,
22 | browserSupportsSpeechRecognition,
23 | } = useSpeechRecognition();
24 |
25 | const pusherMutation = api.pusher.send.useMutation();
26 |
27 | useEffect(() => {
28 | if (finalTranscript !== "") {
29 | pusherMutation.mutate({
30 | message: transcript,
31 | roomName: roomName,
32 | isFinal: true,
33 | });
34 | resetTranscript();
35 | }
36 | }, [finalTranscript]);
37 |
38 | useEffect(() => {
39 | if (audioEnabled) {
40 | SpeechRecognition.startListening({
41 | continuous: true,
42 | language: languageCode,
43 | });
44 | }
45 | }, [audioEnabled]);
46 |
47 | return null;
48 | };
49 |
50 | export default useTranscribe;
51 |
--------------------------------------------------------------------------------
/src/lib/Debug.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { useRoomContext } from '@livekit/components-react';
3 | import { setLogLevel, LogLevel } from 'livekit-client';
4 |
5 | export const useDebugMode = ({ logLevel }: { logLevel?: LogLevel }) => {
6 | setLogLevel(logLevel ?? 'debug');
7 | const room = useRoomContext();
8 | React.useEffect(() => {
9 | // @ts-expect-error
10 | window.__lk_room = room;
11 |
12 | return () => {
13 | // @ts-expect-error
14 | window.__lk_room = undefined;
15 | };
16 | });
17 | };
18 |
19 | export const DebugMode = ({ logLevel }: { logLevel?: LogLevel }) => {
20 | useDebugMode({ logLevel });
21 | return <>>;
22 | };
23 |
--------------------------------------------------------------------------------
/src/lib/client-utils.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 |
3 | export function useServerUrl(region?: string) {
4 | const [serverUrl, setServerUrl] = useState();
5 | useEffect(() => {
6 | let endpoint = `/api/url`;
7 | if (region) {
8 | endpoint += `?region=${region}`;
9 | }
10 | fetch(endpoint).then(async (res) => {
11 | if (res.ok) {
12 | const body = await res.json();
13 | console.log(body);
14 | setServerUrl(body.url);
15 | } else {
16 | throw Error("Error fetching server url, check server logs");
17 | }
18 | });
19 | });
20 | return serverUrl;
21 | }
22 |
--------------------------------------------------------------------------------
/src/lib/serverUtils.ts:
--------------------------------------------------------------------------------
1 | import { RoomServiceClient } from "livekit-server-sdk";
2 |
3 | export function getRoomClient(): RoomServiceClient {
4 | checkKeys();
5 | return new RoomServiceClient(getLiveKitURL());
6 | }
7 |
8 | export function getLiveKitURL(region?: string | string[]): string {
9 | let targetKey = "LIVEKIT_URL";
10 | if (region && !Array.isArray(region)) {
11 | targetKey = `LIVEKIT_URL_${region}`.toUpperCase();
12 | }
13 | const url = process.env[targetKey];
14 | if (!url) {
15 | throw new Error(`${targetKey} is not defined`);
16 | }
17 | return url;
18 | }
19 |
20 | function checkKeys() {
21 | if (typeof process.env.LIVEKIT_API_KEY === "undefined") {
22 | throw new Error("LIVEKIT_API_KEY is not defined");
23 | }
24 | if (typeof process.env.LIVEKIT_API_SECRET === "undefined") {
25 | throw new Error("LIVEKIT_API_SECRET is not defined");
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/lib/type.ts:
--------------------------------------------------------------------------------
1 | import { LocalAudioTrack, LocalVideoTrack } from "livekit-client";
2 |
3 | export interface SessionProps {
4 | roomName: string;
5 | identity: string;
6 | audioTrack?: LocalAudioTrack;
7 | videoTrack?: LocalVideoTrack;
8 | region?: string;
9 | turnServer?: RTCIceServer;
10 | forceRelay?: boolean;
11 | }
12 |
13 | export interface TokenResult {
14 | identity: string;
15 | accessToken: string;
16 | }
17 |
--------------------------------------------------------------------------------
/src/pages/_app.tsx:
--------------------------------------------------------------------------------
1 | import { type AppType } from "next/app";
2 | import { type Session } from "next-auth";
3 | import { SessionProvider } from "next-auth/react";
4 |
5 | import { api } from "~/utils/api";
6 |
7 | import "~/styles/globals.css";
8 | import "@livekit/components-styles";
9 | import "@livekit/components-styles/prefabs";
10 | import Head from "next/head";
11 |
12 | const MyApp: AppType<{ session: Session | null }> = ({
13 | Component,
14 | pageProps: { session, ...pageProps },
15 | }) => {
16 | return (
17 |
18 |
19 | Jab We Meet
20 |
21 |
22 |
23 |
24 |
25 | );
26 | };
27 |
28 | export default api.withTRPC(MyApp);
29 |
--------------------------------------------------------------------------------
/src/pages/api/auth/[...nextauth].ts:
--------------------------------------------------------------------------------
1 | import NextAuth from "next-auth";
2 | import { authOptions } from "~/server/auth";
3 |
4 | export default NextAuth(authOptions);
5 |
--------------------------------------------------------------------------------
/src/pages/api/pusher.ts:
--------------------------------------------------------------------------------
1 | import { NextApiRequest, NextApiResponse } from "next";
2 | import { pusher } from "../../utils/pusher";
3 |
4 | export default async function handler(
5 | req: NextApiRequest,
6 | res: NextApiResponse
7 | ) {
8 | const { message, sender } = req.body;
9 | console.log("here", message, sender);
10 | const response = await pusher.trigger("chat", "chat-event", {
11 | message,
12 | sender,
13 | });
14 |
15 | res.json({ message: "completed" });
16 | }
17 |
--------------------------------------------------------------------------------
/src/pages/api/trpc/[trpc].ts:
--------------------------------------------------------------------------------
1 | import { createNextApiHandler } from "@trpc/server/adapters/next";
2 |
3 | import { env } from "~/env.mjs";
4 | import { createTRPCContext } from "~/server/api/trpc";
5 | import { appRouter } from "~/server/api/root";
6 |
7 | // export API handler
8 | export default createNextApiHandler({
9 | router: appRouter,
10 | createContext: createTRPCContext,
11 | onError:
12 | env.NODE_ENV === "development"
13 | ? ({ path, error }) => {
14 | console.error(
15 | `❌ tRPC failed on ${path ?? ""}: ${error.message}`,
16 | );
17 | }
18 | : undefined,
19 | });
20 |
--------------------------------------------------------------------------------
/src/pages/index.tsx:
--------------------------------------------------------------------------------
1 | // @refresh reset
2 | import type { NextPage } from "next";
3 | import { signIn, useSession } from "next-auth/react";
4 | import { useRouter } from "next/router";
5 | import React from "react";
6 | import Typing from "~/components/animation/typing";
7 | import Navbar from "~/components/navbar";
8 | import { api } from "~/utils/api";
9 | import { AiOutlineVideoCameraAdd } from "react-icons/ai";
10 | import JoinRoom from "~/components/join";
11 | import Image from "next/image";
12 | import Features from "~/components/features";
13 | import CharacterAnimation from "~/components/animation/character";
14 | import { useRive, Layout, Fit, Alignment } from "@rive-app/react-canvas";
15 | import TextAnimation from "~/components/animation/text";
16 | import Loader from "~/components/loader";
17 | import Footer from "~/components/footer";
18 | import SplashScreen from "~/components/splashScreen";
19 |
20 | function ConnectionTab() {
21 | const { data: session, status } = useSession();
22 | const createRoom = api.rooms.createRoom.useMutation();
23 | const router = useRouter();
24 | const { RiveComponent: Hero } = useRive({
25 | src: `hero.riv`,
26 | stateMachines: ["State Machine 1"],
27 | autoplay: true,
28 | layout: new Layout({
29 | fit: Fit.FitWidth,
30 |
31 | alignment: Alignment.Center,
32 | }),
33 | });
34 |
35 | const [roomLoading, setRoomLoading] = React.useState(false);
36 | const createRoomHandler = async () => {
37 | if (status === "unauthenticated") signIn("google");
38 | else {
39 | setRoomLoading(true);
40 | const data = await createRoom.mutateAsync();
41 | setRoomLoading(false);
42 | router.push(`/rooms/${data.roomName}`);
43 | }
44 | };
45 |
46 | if (status === "loading") return ;
47 |
48 | return (
49 | <>
50 |
51 |
52 |
53 |
54 |
55 |
61 |
66 |
67 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
90 |
91 |
92 |
93 | {roomLoading ? (
94 |
95 | ) : (
96 | <>
97 |
98 |
102 | >
103 | )}
104 |
105 |
106 | {!roomLoading &&
}
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
126 |
131 |
132 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 | >
148 | );
149 | }
150 |
151 | const Home: NextPage = () => {
152 | return (
153 | <>
154 |
155 |
156 |
157 | >
158 | );
159 | };
160 |
161 | export default Home;
162 |
--------------------------------------------------------------------------------
/src/pages/profile.tsx:
--------------------------------------------------------------------------------
1 | import { signIn, useSession } from "next-auth/react";
2 | import TextAnimation from "~/components/animation/text";
3 | import Card from "~/components/card";
4 | import Footer from "~/components/footer";
5 | import Loader from "~/components/loader";
6 | import Navbar from "~/components/navbar";
7 | import SplashScreen from "~/components/splashScreen";
8 | import { api } from "~/utils/api";
9 |
10 | function profile() {
11 | const { data: session, status } = useSession();
12 | const { data: rooms, isLoading, error } = api.rooms.getRoomsByUser.useQuery();
13 |
14 | if (status === "loading") return ;
15 | if (!session && status === "unauthenticated") return signIn("google");
16 |
17 | const ownedRooms =
18 | rooms?.filter((room) => room.OwnerId === session?.user.id) || [];
19 | const joinedRooms =
20 | rooms?.filter((room) => room.OwnerId !== session?.user.id) || [];
21 |
22 | return (
23 | <>
24 |
25 |
26 |
27 |
28 | Hello {session?.user.name}!👋🏻
29 |
30 |
31 |
32 |
33 |
37 | {isLoading &&
}
38 | {ownedRooms.length === 0 && (
39 |
40 | You haven't started a room yet
41 |
42 | )}
43 |
44 | {ownedRooms.map((room) => {
45 | return ;
46 | })}
47 |
48 |
49 |
50 |
51 |
55 |
56 | {joinedRooms.length === 0 && (
57 |
58 | You haven't joined any rooms yet
59 |
60 | )}
61 |
62 | {joinedRooms.map((room) => {
63 | return ;
64 | })}
65 |
66 |
67 |
68 |
69 | >
70 | );
71 | }
72 |
73 | export default profile;
74 |
--------------------------------------------------------------------------------
/src/pages/rooms/[name].tsx:
--------------------------------------------------------------------------------
1 | import {
2 | LiveKitRoom,
3 | PreJoin,
4 | LocalUserChoices,
5 | VideoConference,
6 | formatChatMessageLinks,
7 | } from "@livekit/components-react";
8 | import { LogLevel, RoomOptions, VideoPresets } from "livekit-client";
9 |
10 | import type { NextPage } from "next";
11 | import { useRouter } from "next/router";
12 | import { useEffect, useMemo, useState } from "react";
13 | import { DebugMode } from "../../lib/Debug";
14 | import { api } from "~/utils/api";
15 | import { signIn, useSession } from "next-auth/react";
16 | import Pusher from "pusher-js";
17 | import useTranscribe from "~/hooks/useTranscribe";
18 | import Captions from "~/components/captions";
19 | import SplashScreen from "~/components/splashScreen";
20 | import { AiFillSetting } from "react-icons/ai";
21 |
22 | const Home: NextPage = () => {
23 | const router = useRouter();
24 | const { name: roomName } = router.query;
25 | const { data: session, status } = useSession();
26 | const [preJoinChoices, setPreJoinChoices] = useState<
27 | LocalUserChoices | undefined
28 | >(undefined);
29 | const [selectedCode, setSelectedCode] = useState("en");
30 | if (status === "loading") return ;
31 | if (!session) signIn("google");
32 |
33 | const languageCodes = [
34 | {
35 | language: "English",
36 | code: "en-US",
37 | },
38 | {
39 | language: "Hindi",
40 | code: "hi-IN",
41 | },
42 | {
43 | language: "Japanese",
44 | code: "ja-JP",
45 | },
46 | {
47 | language: "French",
48 | code: "fr-FR",
49 | },
50 | {
51 | language: "Deutsch",
52 | code: "de-DE",
53 | },
54 | ];
55 |
56 | return (
57 |
58 | {roomName && !Array.isArray(roomName) && preJoinChoices ? (
59 | <>
60 | setPreJoinChoices(undefined)}
64 | userId={session?.user.id as string}
65 | selectedLanguage={selectedCode}
66 | >
67 |
73 |
74 |
75 |
76 | Switch Language
77 |
78 | setSelectedCode(e.target.value)}
81 | defaultValue={selectedCode}
82 | >
83 | {languageCodes.map((language) => (
84 | {language.language}
85 | ))}
86 |
87 |
88 |
89 | >
90 | ) : (
91 |
92 |
93 |
Hey, {session?.user.name}!
94 |
95 | You are joining{" "}
96 | {roomName}
97 |
98 |
99 | Choose your Language
100 |
101 |
setSelectedCode(e.target.value)}
104 | >
105 | {languageCodes.map((language) => (
106 | {language.language}
107 | ))}
108 |
109 |
110 |
112 | console.log("Error while setting up prejoin", err)
113 | }
114 | defaults={{
115 | username: session?.user.name as string,
116 | videoEnabled: true,
117 | audioEnabled: true,
118 | }}
119 | onSubmit={(values) => {
120 | console.log("Joining with: ", values);
121 | setPreJoinChoices(values);
122 | }}
123 | >
124 |
125 | )}
126 |
127 | );
128 | };
129 |
130 | export default Home;
131 |
132 | type ActiveRoomProps = {
133 | userChoices: LocalUserChoices;
134 | roomName: string;
135 | region?: string;
136 | onLeave?: () => void;
137 | userId: string;
138 | selectedLanguage: string;
139 | };
140 |
141 | const ActiveRoom = ({
142 | roomName,
143 | userChoices,
144 | onLeave,
145 | userId,
146 | selectedLanguage,
147 | }: ActiveRoomProps) => {
148 | const { data, error, isLoading } = api.rooms.joinRoom.useQuery({ roomName });
149 |
150 | const router = useRouter();
151 | const { region, hq } = router.query;
152 |
153 | // const liveKitUrl = useServerUrl(region as string | undefined);
154 |
155 | const roomOptions = useMemo((): RoomOptions => {
156 | return {
157 | videoCaptureDefaults: {
158 | deviceId: userChoices.videoDeviceId ?? undefined,
159 | resolution: hq === "true" ? VideoPresets.h2160 : VideoPresets.h720,
160 | },
161 | publishDefaults: {
162 | videoSimulcastLayers:
163 | hq === "true"
164 | ? [VideoPresets.h1080, VideoPresets.h720]
165 | : [VideoPresets.h540, VideoPresets.h216],
166 | },
167 | audioCaptureDefaults: {
168 | deviceId: userChoices.audioDeviceId ?? undefined,
169 | },
170 | adaptiveStream: { pixelDensity: "screen" },
171 | dynacast: true,
172 | };
173 | }, [userChoices, hq]);
174 |
175 | const [transcriptionQueue, setTranscriptionQueue] = useState<
176 | {
177 | sender: string;
178 | message: string;
179 | senderId: string;
180 | isFinal: boolean;
181 | }[]
182 | >([]);
183 | useTranscribe({
184 | roomName,
185 | audioEnabled: userChoices.audioEnabled,
186 | languageCode: selectedLanguage,
187 | });
188 | useEffect(() => {
189 | const pusher = new Pusher(process.env.NEXT_PUBLIC_PUSHER_KEY as string, {
190 | cluster: process.env.NEXT_PUBLIC_PUSHER_CLUSTER as string,
191 | });
192 |
193 | const channel = pusher.subscribe(roomName);
194 | channel.bind(
195 | "transcribe-event",
196 | function (data: {
197 | sender: string;
198 | message: string;
199 | senderId: string;
200 | isFinal: boolean;
201 | }) {
202 | if (data.isFinal && userId !== data.senderId) {
203 | setTranscriptionQueue((prev) => {
204 | return [...prev, data];
205 | });
206 | }
207 | }
208 | );
209 |
210 | return () => {
211 | pusher.unsubscribe(roomName);
212 | };
213 | }, []);
214 |
215 | return (
216 | <>
217 | {data && (
218 |
226 |
231 |
232 |
233 |
234 | )}
235 | >
236 | );
237 | };
238 |
--------------------------------------------------------------------------------
/src/server/api/root.ts:
--------------------------------------------------------------------------------
1 | import { createTRPCRouter } from "~/server/api/trpc";
2 | import { roomsRouter } from "./routers/rooms";
3 | import { pusherRouter } from "./routers/pusher";
4 |
5 | /**
6 | * This is the primary router for your server.
7 | *
8 | * All routers added in /api/routers should be manually added here.
9 | */
10 | export const appRouter = createTRPCRouter({
11 | rooms: roomsRouter,
12 | pusher: pusherRouter,
13 | });
14 |
15 | // export type definition of API
16 | export type AppRouter = typeof appRouter;
17 |
--------------------------------------------------------------------------------
/src/server/api/routers/pusher.ts:
--------------------------------------------------------------------------------
1 | import { string, z } from "zod";
2 | import { pusher } from "~/utils/pusher";
3 |
4 | import {
5 | createTRPCRouter,
6 | publicProcedure,
7 | protectedProcedure,
8 | } from "~/server/api/trpc";
9 | import { translate } from "@vitalets/google-translate-api";
10 | export const pusherRouter = createTRPCRouter({
11 | send: protectedProcedure
12 | .input(
13 | z.object({
14 | message: string(),
15 | roomName: string(),
16 | isFinal: z.boolean(),
17 | })
18 | )
19 | .mutation(async ({ input, ctx }) => {
20 | const { message } = input;
21 | const { user } = ctx.session;
22 | const response = await pusher.trigger(
23 | input.roomName,
24 | "transcribe-event",
25 | {
26 | message,
27 | sender: user.name,
28 | isFinal: input.isFinal,
29 | senderId: user.id,
30 | }
31 | );
32 | const { text } = await translate(message, {
33 | to: "en",
34 | });
35 | await ctx.prisma.transcript.create({
36 | data: {
37 | text: text,
38 | Room: {
39 | connect: {
40 | name: input.roomName,
41 | },
42 | },
43 | User: {
44 | connect: {
45 | id: user.id,
46 | },
47 | },
48 | },
49 | });
50 | return response;
51 | }),
52 | });
53 |
--------------------------------------------------------------------------------
/src/server/api/routers/rooms.ts:
--------------------------------------------------------------------------------
1 | import { nullable, string, z } from "zod";
2 | import { AccessToken, RoomServiceClient } from "livekit-server-sdk";
3 | import type {
4 | AccessTokenOptions,
5 | VideoGrant,
6 | CreateOptions,
7 | } from "livekit-server-sdk";
8 | import { translate } from "@vitalets/google-translate-api";
9 |
10 | const createToken = (userInfo: AccessTokenOptions, grant: VideoGrant) => {
11 | const at = new AccessToken(apiKey, apiSecret, userInfo);
12 | at.ttl = "5m";
13 | at.addGrant(grant);
14 | return at.toJwt();
15 | };
16 | import axios from "axios";
17 |
18 | const apiKey = process.env.LIVEKIT_API_KEY;
19 | const apiSecret = process.env.LIVEKIT_API_SECRET;
20 | const apiHost = process.env.NEXT_PUBLIC_LIVEKIT_API_HOST as string;
21 | import {
22 | createTRPCRouter,
23 | publicProcedure,
24 | protectedProcedure,
25 | } from "~/server/api/trpc";
26 | import { TokenResult } from "~/lib/type";
27 | import { CreateRoomRequest } from "livekit-server-sdk/dist/proto/livekit_room";
28 | const roomClient = new RoomServiceClient(apiHost, apiKey, apiSecret);
29 | const configuration = new Configuration({
30 | apiKey: process.env.OPEN_API_SECRET,
31 | });
32 | import { Configuration, OpenAIApi } from "openai";
33 | const openai = new OpenAIApi(configuration);
34 | export const roomsRouter = createTRPCRouter({
35 | joinRoom: protectedProcedure
36 | .input(
37 | z.object({
38 | roomName: z.string(),
39 | })
40 | )
41 | .query(async ({ input, ctx }) => {
42 | const identity = ctx.session.user.id;
43 | const name = ctx.session.user.name;
44 |
45 | const grant: VideoGrant = {
46 | room: input.roomName,
47 | roomJoin: true,
48 | canPublish: true,
49 | canPublishData: true,
50 | canSubscribe: true,
51 | };
52 | const { roomName } = input;
53 |
54 | const token = createToken({ identity, name: name as string }, grant);
55 | const result: TokenResult = {
56 | identity,
57 | accessToken: token,
58 | };
59 | try {
60 | // check if user is already in room
61 | console.log("here");
62 | const participant = await ctx.prisma.participant.findUnique({
63 | where: {
64 | UserId_RoomName: {
65 | UserId: ctx.session.user.id,
66 | RoomName: roomName,
67 | },
68 | },
69 | });
70 | if (participant === null)
71 | await ctx.prisma.participant.create({
72 | data: {
73 | User: {
74 | connect: {
75 | id: ctx.session.user.id,
76 | },
77 | },
78 | Room: {
79 | connect: {
80 | name: roomName,
81 | },
82 | },
83 | },
84 | });
85 | } catch (error) {
86 | console.log(error);
87 | }
88 |
89 | return result;
90 | }),
91 | createRoom: protectedProcedure.mutation(async ({ ctx }) => {
92 | const identity = ctx.session.user.id;
93 | const name = ctx.session.user.name;
94 | const room = await ctx.prisma.room.create({
95 | data: {
96 | Owner: {
97 | connect: {
98 | id: ctx.session.user.id,
99 | },
100 | },
101 | },
102 | });
103 | await roomClient.createRoom({
104 | name: room.name,
105 | });
106 |
107 | const grant: VideoGrant = {
108 | room: room.name,
109 | roomJoin: true,
110 | canPublish: true,
111 | canPublishData: true,
112 | canSubscribe: true,
113 | };
114 | const token = createToken({ identity, name: name as string }, grant);
115 | const result = {
116 | roomName: room.name,
117 | };
118 |
119 | return result;
120 | }),
121 | getRoomsByUser: protectedProcedure.query(async ({ ctx }) => {
122 | const rooms = await ctx.prisma.room.findMany({
123 | where: {
124 | OR: [
125 | {
126 | Owner: {
127 | id: ctx.session.user.id,
128 | },
129 | },
130 | {
131 | Participant: {
132 | some: {
133 | UserId: ctx.session.user.id,
134 | },
135 | },
136 | },
137 | ],
138 | },
139 | });
140 |
141 | return rooms;
142 | }),
143 | getRoomSummary: protectedProcedure
144 | .input(
145 | z.object({
146 | roomName: z.string(),
147 | })
148 | )
149 | .query(async ({ input, ctx }) => {
150 | // order all transcripts by createdAt in ascending order
151 | const transcripts = await ctx.prisma.transcript.findMany({
152 | where: {
153 | Room: {
154 | name: input.roomName,
155 | },
156 | },
157 | include: {
158 | User: true,
159 | },
160 | orderBy: {
161 | createdAt: "asc",
162 | },
163 | });
164 | const chatLog = transcripts.map((transcript) => ({
165 | speaker: transcript.User.name,
166 | utterance: transcript.text,
167 | timestamp: transcript.createdAt.toISOString(),
168 | }));
169 | if (chatLog.length === 0) {
170 | return null;
171 | }
172 |
173 | const apiKey = process.env.ONEAI_API_KEY;
174 | console.log(chatLog);
175 | try {
176 | const config = {
177 | method: "POST",
178 | url: "https://api.oneai.com/api/v0/pipeline",
179 | headers: {
180 | "api-key": apiKey,
181 | "Content-Type": "application/json",
182 | },
183 | data: {
184 | input: chatLog,
185 | input_type: "conversation",
186 | content_type: "application/json",
187 | output_type: "json",
188 | multilingual: {
189 | enabled: true,
190 | },
191 | steps: [
192 | {
193 | skill: "article-topics",
194 | },
195 | {
196 | skill: "numbers",
197 | },
198 | {
199 | skill: "names",
200 | },
201 | {
202 | skill: "emotions",
203 | },
204 | {
205 | skill: "summarize",
206 | },
207 | ],
208 | },
209 | };
210 |
211 | const res = await axios.request(config);
212 | console.log(res.status);
213 | return res.data;
214 | } catch (error) {
215 | console.log(error);
216 | }
217 | }),
218 | });
219 |
--------------------------------------------------------------------------------
/src/server/api/trpc.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * YOU PROBABLY DON'T NEED TO EDIT THIS FILE, UNLESS:
3 | * 1. You want to modify request context (see Part 1).
4 | * 2. You want to create a new middleware or type of procedure (see Part 3).
5 | *
6 | * TL;DR - This is where all the tRPC server stuff is created and plugged in. The pieces you will
7 | * need to use are documented accordingly near the end.
8 | */
9 |
10 | /**
11 | * 1. CONTEXT
12 | *
13 | * This section defines the "contexts" that are available in the backend API.
14 | *
15 | * These allow you to access things when processing a request, like the database, the session, etc.
16 | */
17 | import { type CreateNextContextOptions } from "@trpc/server/adapters/next";
18 | import { type Session } from "next-auth";
19 |
20 | import { getServerAuthSession } from "~/server/auth";
21 | import { prisma } from "~/server/db";
22 |
23 | type CreateContextOptions = {
24 | session: Session | null;
25 | };
26 |
27 | /**
28 | * This helper generates the "internals" for a tRPC context. If you need to use it, you can export
29 | * it from here.
30 | *
31 | * Examples of things you may need it for:
32 | * - testing, so we don't have to mock Next.js' req/res
33 | * - tRPC's `createSSGHelpers`, where we don't have req/res
34 | *
35 | * @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts
36 | */
37 | const createInnerTRPCContext = (opts: CreateContextOptions) => {
38 | return {
39 | session: opts.session,
40 | prisma,
41 | };
42 | };
43 |
44 | /**
45 | * This is the actual context you will use in your router. It will be used to process every request
46 | * that goes through your tRPC endpoint.
47 | *
48 | * @see https://trpc.io/docs/context
49 | */
50 | export const createTRPCContext = async (opts: CreateNextContextOptions) => {
51 | const { req, res } = opts;
52 |
53 | // Get the session from the server using the getServerSession wrapper function
54 | const session = await getServerAuthSession({ req, res });
55 |
56 | return createInnerTRPCContext({
57 | session,
58 | });
59 | };
60 |
61 | /**
62 | * 2. INITIALIZATION
63 | *
64 | * This is where the tRPC API is initialized, connecting the context and transformer.
65 | */
66 | import { initTRPC, TRPCError } from "@trpc/server";
67 | import superjson from "superjson";
68 |
69 | const t = initTRPC.context().create({
70 | transformer: superjson,
71 | errorFormatter({ shape }) {
72 | return shape;
73 | },
74 | });
75 |
76 | /**
77 | * 3. ROUTER & PROCEDURE (THE IMPORTANT BIT)
78 | *
79 | * These are the pieces you use to build your tRPC API. You should import these a lot in the
80 | * "/src/server/api/routers" directory.
81 | */
82 |
83 | /**
84 | * This is how you create new routers and sub-routers in your tRPC API.
85 | *
86 | * @see https://trpc.io/docs/router
87 | */
88 | export const createTRPCRouter = t.router;
89 |
90 | /**
91 | * Public (unauthenticated) procedure
92 | *
93 | * This is the base piece you use to build new queries and mutations on your tRPC API. It does not
94 | * guarantee that a user querying is authorized, but you can still access user session data if they
95 | * are logged in.
96 | */
97 | export const publicProcedure = t.procedure;
98 |
99 | /** Reusable middleware that enforces users are logged in before running the procedure. */
100 | const enforceUserIsAuthed = t.middleware(({ ctx, next }) => {
101 | if (!ctx.session || !ctx.session.user) {
102 | throw new TRPCError({ code: "UNAUTHORIZED" });
103 | }
104 | return next({
105 | ctx: {
106 | // infers the `session` as non-nullable
107 | session: { ...ctx.session, user: ctx.session.user },
108 | },
109 | });
110 | });
111 |
112 | /**
113 | * Protected (authenticated) procedure
114 | *
115 | * If you want a query or mutation to ONLY be accessible to logged in users, use this. It verifies
116 | * the session is valid and guarantees `ctx.session.user` is not null.
117 | *
118 | * @see https://trpc.io/docs/procedures
119 | */
120 | export const protectedProcedure = t.procedure.use(enforceUserIsAuthed);
121 |
--------------------------------------------------------------------------------
/src/server/auth.ts:
--------------------------------------------------------------------------------
1 | import { type GetServerSidePropsContext } from "next";
2 | import {
3 | getServerSession,
4 | type NextAuthOptions,
5 | type DefaultSession,
6 | } from "next-auth";
7 | import GoogleProvider from "next-auth/providers/google";
8 | import { PrismaAdapter } from "@next-auth/prisma-adapter";
9 | import { env } from "~/env.mjs";
10 | import { prisma } from "~/server/db";
11 |
12 | /**
13 | * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
14 | * object and keep type safety.
15 | *
16 | * @see https://next-auth.js.org/getting-started/typescript#module-augmentation
17 | */
18 | declare module "next-auth" {
19 | interface Session extends DefaultSession {
20 | user: {
21 | id: string;
22 | // ...other properties
23 | // role: UserRole;
24 | } & DefaultSession["user"];
25 | }
26 |
27 | // interface User {
28 | // // ...other properties
29 | // // role: UserRole;
30 | // }
31 | }
32 |
33 | /**
34 | * Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
35 | *
36 | * @see https://next-auth.js.org/configuration/options
37 | */
38 | export const authOptions: NextAuthOptions = {
39 | callbacks: {
40 | session({ session, user }) {
41 | if (session.user) {
42 | session.user.id = user.id;
43 | // session.user.role = user.role; <-- put other properties on the session here
44 | }
45 | return session;
46 | },
47 | },
48 | adapter: PrismaAdapter(prisma),
49 | providers: [
50 | GoogleProvider({
51 | clientId: env.GOOGLE_CLIENT_ID,
52 | clientSecret: env.GOOGLE_CLIENT_SECRET,
53 | }),
54 | ],
55 | };
56 |
57 | /**
58 | * Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file.
59 | *
60 | * @see https://next-auth.js.org/configuration/nextjs
61 | */
62 | export const getServerAuthSession = (ctx: {
63 | req: GetServerSidePropsContext["req"];
64 | res: GetServerSidePropsContext["res"];
65 | }) => {
66 | return getServerSession(ctx.req, ctx.res, authOptions);
67 | };
68 |
--------------------------------------------------------------------------------
/src/server/db.ts:
--------------------------------------------------------------------------------
1 | import { PrismaClient } from "@prisma/client";
2 |
3 | import { env } from "~/env.mjs";
4 |
5 | const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
6 |
7 | export const prisma =
8 | globalForPrisma.prisma ||
9 | new PrismaClient({
10 | log:
11 | env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
12 | });
13 |
14 | if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
15 |
--------------------------------------------------------------------------------
/src/styles/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | body {
6 | @apply bg-black;
7 | }
8 |
9 | .lk-username-container > #username {
10 | @apply hidden;
11 | }
12 |
13 | .closed-captions-wrapper {
14 | width: 100%;
15 | position: absolute;
16 | bottom: 20%;
17 | display: flex;
18 | justify-content: center;
19 | z-index: 100;
20 | font-size: 18px;
21 | }
22 |
23 | .closed-captions-container {
24 | background: black;
25 | color: white;
26 | display: flex;
27 | flex-direction: row;
28 | }
29 |
30 | .gradient-text {
31 | @apply bg-gradient-to-r from-primary via-secondary to-tertiary bg-clip-text text-transparent;
32 | }
33 |
34 | .lk-join-button {
35 | background: #6366f1 !important;
36 | }
37 |
38 | .lk-join-button:hover {
39 | background: #4f46e5 !important;
40 | }
41 | .lk-video-conference {
42 | @apply bg-black;
43 | }
44 |
45 | .lk-list,
46 | .lk-chat-form {
47 | @apply bg-black;
48 | }
49 |
--------------------------------------------------------------------------------
/src/utils/api.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the client-side entrypoint for your tRPC API. It is used to create the `api` object which
3 | * contains the Next.js App-wrapper, as well as your type-safe React Query hooks.
4 | *
5 | * We also create a few inference helpers for input and output types.
6 | */
7 | import { httpBatchLink, loggerLink } from "@trpc/client";
8 | import { createTRPCNext } from "@trpc/next";
9 | import { type inferRouterInputs, type inferRouterOutputs } from "@trpc/server";
10 | import superjson from "superjson";
11 |
12 | import { type AppRouter } from "~/server/api/root";
13 |
14 | const getBaseUrl = () => {
15 | if (typeof window !== "undefined") return ""; // browser should use relative url
16 | if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; // SSR should use vercel url
17 | return `http://localhost:${process.env.PORT ?? 3000}`; // dev SSR should use localhost
18 | };
19 |
20 | /** A set of type-safe react-query hooks for your tRPC API. */
21 | export const api = createTRPCNext({
22 | config() {
23 | return {
24 | /**
25 | * Transformer used for data de-serialization from the server.
26 | *
27 | * @see https://trpc.io/docs/data-transformers
28 | */
29 | transformer: superjson,
30 |
31 | /**
32 | * Links used to determine request flow from client to server.
33 | *
34 | * @see https://trpc.io/docs/links
35 | */
36 | links: [
37 | loggerLink({
38 | enabled: (opts) =>
39 | process.env.NODE_ENV === "development" ||
40 | (opts.direction === "down" && opts.result instanceof Error),
41 | }),
42 | httpBatchLink({
43 | url: `${getBaseUrl()}/api/trpc`,
44 | }),
45 | ],
46 | };
47 | },
48 | /**
49 | * Whether tRPC should await queries when server rendering pages.
50 | *
51 | * @see https://trpc.io/docs/nextjs#ssr-boolean-default-false
52 | */
53 | ssr: false,
54 | });
55 |
56 | /**
57 | * Inference helper for inputs.
58 | *
59 | * @example type HelloInput = RouterInputs['example']['hello']
60 | */
61 | export type RouterInputs = inferRouterInputs;
62 |
63 | /**
64 | * Inference helper for outputs.
65 | *
66 | * @example type HelloOutput = RouterOutputs['example']['hello']
67 | */
68 | export type RouterOutputs = inferRouterOutputs;
69 |
--------------------------------------------------------------------------------
/src/utils/pusher.ts:
--------------------------------------------------------------------------------
1 | import Pusher from "pusher";
2 |
3 | export const pusher = new Pusher({
4 | appId: process.env.PUSHER_APP_ID as string,
5 | key: process.env.PUSHER_KEY as string,
6 | secret: process.env.PUSHER_SECRET as string,
7 | cluster: process.env.PUSHER_CLUSTER as string,
8 | useTLS: true,
9 | });
10 |
--------------------------------------------------------------------------------
/src/utils/speak.ts:
--------------------------------------------------------------------------------
1 | import { transliterate } from "transliteration";
2 |
3 | let lastSpokenText = "";
4 |
5 | const speakOut = async (text: string, isEmpty: boolean, lang?: string) => {
6 | if (text === lastSpokenText) {
7 | console.log("Skipping speaking text again:", text);
8 | return;
9 | }
10 |
11 | if (isEmpty) lastSpokenText = "";
12 |
13 | console.log("speakOut function called with text:", text);
14 |
15 | let speech = new SpeechSynthesisUtterance();
16 | speech.lang = lang || "en-US";
17 |
18 | let englishText = transliterate(text);
19 | speech.text = englishText;
20 |
21 | console.log("SpeechSynthesisUtterance:", speech);
22 | speechSynthesis.speak(speech);
23 |
24 | lastSpokenText = text;
25 | };
26 |
27 | export default speakOut;
28 |
--------------------------------------------------------------------------------
/tailwind.config.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | const config = {
3 | content: ["./src/**/*.{js,ts,jsx,tsx}"],
4 | theme: {
5 | extend: {
6 | colors: {
7 | primary: '#6366f1',
8 | secondary: '#a855f7',
9 | tertiary:'#ec4899',
10 | },
11 | },
12 | },
13 | plugins: [],
14 | };
15 |
16 | module.exports = config;
17 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2017",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "checkJs": true,
7 | "skipLibCheck": true,
8 | "strict": true,
9 | "forceConsistentCasingInFileNames": true,
10 | "noEmit": true,
11 | "esModuleInterop": true,
12 | "module": "esnext",
13 | "moduleResolution": "node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "jsx": "preserve",
17 | "incremental": true,
18 | "noUncheckedIndexedAccess": true,
19 | "baseUrl": ".",
20 | "paths": {
21 | "~/*": ["./src/*"]
22 | }
23 | },
24 | "include": [
25 | ".eslintrc.cjs",
26 | "next-env.d.ts",
27 | "**/*.ts",
28 | "**/*.tsx",
29 | "**/*.cjs",
30 | "**/*.mjs"
31 | , "src/server/api/routers/pushetrts" ],
32 | "exclude": ["node_modules"]
33 | }
34 |
--------------------------------------------------------------------------------