├── .env.example ├── .eslintrc.json ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── images │ ├── img1.png │ ├── img2.png │ ├── img3.png │ ├── img4.png │ ├── img_main.png │ └── stats.svg ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── app ├── (auth) │ ├── (routes) │ │ ├── sign-in │ │ │ └── [[...sign-in]] │ │ │ │ └── page.tsx │ │ └── sign-up │ │ │ └── [[...sign-up]] │ │ │ └── page.tsx │ └── layout.tsx ├── (dashboard) │ ├── (routes) │ │ ├── code │ │ │ └── page.tsx │ │ ├── conversation │ │ │ └── page.tsx │ │ ├── dashboard │ │ │ └── page.tsx │ │ ├── image │ │ │ └── page.tsx │ │ ├── music │ │ │ └── page.tsx │ │ ├── settings │ │ │ └── page.tsx │ │ └── video │ │ │ └── page.tsx │ └── layout.tsx ├── (landing) │ ├── layout.tsx │ └── page.tsx ├── api │ ├── code │ │ └── route.ts │ ├── conversation │ │ └── route.ts │ ├── image │ │ └── route.ts │ ├── music │ │ └── route.ts │ ├── stripe │ │ └── route.ts │ ├── video │ │ └── route.ts │ └── webhook │ │ └── route.ts ├── apple-icon.png ├── favicon.ico ├── globals.css ├── icon1.png ├── icon2.png └── layout.tsx ├── components.json ├── components ├── bot-avatar.tsx ├── crisp-chat.tsx ├── empty.tsx ├── free-counter.tsx ├── heading.tsx ├── landing-content.tsx ├── landing-footer.tsx ├── landing-hero.tsx ├── landing-navbar.tsx ├── loader.tsx ├── mobile-sidebar.tsx ├── navbar.tsx ├── pro-modal.tsx ├── sidebar.tsx ├── subscription-button.tsx ├── ui │ ├── avatar.tsx │ ├── badge.tsx │ ├── button.tsx │ ├── card.tsx │ ├── dialog.tsx │ ├── form.tsx │ ├── input.tsx │ ├── label.tsx │ ├── progress.tsx │ ├── select.tsx │ └── sheet.tsx └── user-avatar.tsx ├── config └── index.ts ├── constants └── index.ts ├── environment.d.ts ├── hooks └── use-pro-modal.tsx ├── lib ├── api-limit.ts ├── db.ts ├── stripe.ts ├── subscription.ts └── utils.ts ├── middleware.ts ├── next.config.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── prisma └── schema.prisma ├── providers ├── crisp-provider.tsx ├── modal-provider.tsx └── toaster-provider.tsx ├── public ├── empty.png ├── logo.png └── testimonials │ ├── user-1.jpeg │ ├── user-2.jpeg │ ├── user-3.jpeg │ └── user-4.jpeg ├── schemas └── index.ts ├── tailwind.config.ts └── tsconfig.json /.env.example: -------------------------------------------------------------------------------- 1 | # .env 2 | 3 | # disable next.js telemetry 4 | NEXT_TELEMETRY_DISABLED=1 5 | 6 | # clerk auth keys 7 | NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 8 | CLERK_SECRET_KEY=sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 9 | 10 | # clerk redirect uri 11 | NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in 12 | NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up 13 | NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard 14 | NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard 15 | 16 | # openai api key 17 | OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 18 | 19 | # replicate api token 20 | REPLICATE_API_TOKEN=r8_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 21 | 22 | # aiven database url 23 | DATABASE_URL="mysql://:@:/genius-ai?ssl-mode=REQUIRED" 24 | 25 | # stripe api/webhook secret key 26 | STRIPE_API_SECRET_KEY=sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 27 | STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 28 | 29 | # app base url 30 | NEXT_PUBLIC_APP_URL=http://localhost:3000 31 | 32 | # crisp website id 33 | NEXT_PUBLIC_CRISP_WEBSITE_ID=xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx 34 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [sanidhyy] 4 | patreon: sanidhy 5 | custom: https://www.buymeacoffee.com/sanidhy 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/images/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/.github/images/img1.png -------------------------------------------------------------------------------- /.github/images/img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/.github/images/img2.png -------------------------------------------------------------------------------- /.github/images/img3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/.github/images/img3.png -------------------------------------------------------------------------------- /.github/images/img4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/.github/images/img4.png -------------------------------------------------------------------------------- /.github/images/img_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/.github/images/img_main.png -------------------------------------------------------------------------------- /.github/images/stats.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 122 | 123 | 124 | 125 | 97 126 | Performance 127 | 128 | 129 | 130 | 131 | 100 132 | Accessibility 133 | 134 | 135 | 136 | 137 | 100 138 | Best Practices 139 | 140 | 141 | 142 | 143 | 100 144 | SEO 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 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 | Progressive 211 | Web App 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 0-49 227 | 50-89 228 | 90-100 229 | 230 | 231 | -------------------------------------------------------------------------------- /.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 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env 30 | .env*.local 31 | 32 | # vercel 33 | .vercel 34 | 35 | # typescript 36 | *.tsbuildinfo 37 | next-env.d.ts 38 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct - Genius 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to make participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to a positive environment for our 15 | community include: 16 | 17 | - Demonstrating empathy and kindness toward other people 18 | - Being respectful of differing opinions, viewpoints, and experiences 19 | - Giving and gracefully accepting constructive feedback 20 | - Accepting responsibility and apologizing to those affected by our mistakes, 21 | and learning from the experience 22 | - Focusing on what is best not just for us as individuals, but for the 23 | overall community 24 | 25 | Examples of unacceptable behavior include: 26 | 27 | - The use of sexualized language or imagery, and sexual attention or 28 | advances 29 | - Trolling, insulting or derogatory comments, and personal or political attacks 30 | - Public or private harassment 31 | - Publishing others' private information, such as a physical or email 32 | address, without their explicit permission 33 | - Other conduct which could reasonably be considered inappropriate in a 34 | professional setting 35 | 36 | ## Our Responsibilities 37 | 38 | Project maintainers are responsible for clarifying and enforcing our standards of 39 | acceptable behavior and will take appropriate and fair corrective action in 40 | response to any behavior that they deem inappropriate, 41 | threatening, offensive, or harmful. 42 | 43 | Project maintainers have the right and responsibility to remove, edit, or reject 44 | comments, commits, code, wiki edits, issues, and other contributions that are 45 | not aligned to this Code of Conduct, and will 46 | communicate reasons for moderation decisions when appropriate. 47 | 48 | ## Scope 49 | 50 | This Code of Conduct applies within all community spaces, and also applies when 51 | an individual is officially representing the community in public spaces. 52 | Examples of representing our community include using an official e-mail address, 53 | posting via an official social media account, or acting as an appointed 54 | representative at an online or offline event. 55 | 56 | ## Enforcement 57 | 58 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 59 | reported to the community leaders responsible for enforcement at . 60 | All complaints will be reviewed and investigated promptly and fairly. 61 | 62 | All community leaders are obligated to respect the privacy and security of the 63 | reporter of any incident. 64 | 65 | ## Enforcement Guidelines 66 | 67 | Community leaders will follow these Community Impact Guidelines in determining 68 | the consequences for any action they deem in violation of this Code of Conduct: 69 | 70 | ### 1. Correction 71 | 72 | **Community Impact**: Use of inappropriate language or other behavior deemed 73 | unprofessional or unwelcome in the community. 74 | 75 | **Consequence**: A private, written warning from community leaders, providing 76 | clarity around the nature of the violation and an explanation of why the 77 | behavior was inappropriate. A public apology may be requested. 78 | 79 | ### 2. Warning 80 | 81 | **Community Impact**: A violation through a single incident or series 82 | of actions. 83 | 84 | **Consequence**: A warning with consequences for continued behavior. No 85 | interaction with the people involved, including unsolicited interaction with 86 | those enforcing the Code of Conduct, for a specified period of time. This 87 | includes avoiding interactions in community spaces as well as external channels 88 | like social media. Violating these terms may lead to a temporary or 89 | permanent ban. 90 | 91 | ### 3. Temporary Ban 92 | 93 | **Community Impact**: A serious violation of community standards, including 94 | sustained inappropriate behavior. 95 | 96 | **Consequence**: A temporary ban from any sort of interaction or public 97 | communication with the community for a specified period of time. No public or 98 | private interaction with the people involved, including unsolicited interaction 99 | with those enforcing the Code of Conduct, is allowed during this period. 100 | Violating these terms may lead to a permanent ban. 101 | 102 | ### 4. Permanent Ban 103 | 104 | **Community Impact**: Demonstrating a pattern of violation of community 105 | standards, including sustained inappropriate behavior, harassment of an 106 | individual, or aggression toward or disparagement of classes of individuals. 107 | 108 | **Consequence**: A permanent ban from any sort of public interaction within 109 | the community. 110 | 111 | ## Attribution 112 | 113 | This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org/), version 114 | [1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct/code_of_conduct.md) and 115 | [2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/code_of_conduct.md), 116 | and was generated by [contributing-gen](https://github.com/bttger/contributing-gen). 117 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contributing to Genius 4 | 5 | First off, thanks for taking the time to contribute! ❤️ 6 | 7 | All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉 8 | 9 | > And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: 10 | > 11 | > - Star the project 12 | > - Tweet about it 13 | > - Refer this project in your project's readme 14 | > - Mention the project at local meetups and tell your friends/colleagues 15 | 16 | 17 | 18 | ## Table of Contents 19 | 20 | - [Code of Conduct](#code-of-conduct) 21 | - [I Have a Question](#i-have-a-question) 22 | - [I Want To Contribute](#i-want-to-contribute) 23 | - [Reporting Bugs](#reporting-bugs) 24 | - [Suggesting Enhancements](#suggesting-enhancements) 25 | - [Your First Code Contribution](#your-first-code-contribution) 26 | - [Improving The Documentation](#improving-the-documentation) 27 | - [Styleguides](#styleguides) 28 | - [Commit Messages](#commit-messages) 29 | - [Join The Project Team](#join-the-project-team) 30 | 31 | ## Code of Conduct 32 | 33 | This project and everyone participating in it is governed by the 34 | [Genius Code of Conduct](https://github.com/sanidhyy/genius-aiblob/master/CODE_OF_CONDUCT.md). 35 | By participating, you are expected to uphold this code. Please report unacceptable behavior 36 | to . 37 | 38 | ## I Have a Question 39 | 40 | > If you want to ask a question, we assume that you have read the available [Documentation](https://github.com/sanidhyy/genius-ai/wiki). 41 | 42 | Before you ask a question, it is best to search for existing [Issues](https://github.com/sanidhyy/genius-ai/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first. 43 | 44 | If you then still feel the need to ask a question and need clarification, we recommend the following: 45 | 46 | - Open an [Issue](https://github.com/sanidhyy/genius-ai/issues/new). 47 | - Provide as much context as you can about what you're running into. 48 | - Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. 49 | 50 | We will then take care of the issue as soon as possible. 51 | 52 | ## I Want To Contribute 53 | 54 | > ### Legal Notice 55 | > 56 | > When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. 57 | 58 | ### Reporting Bugs 59 | 60 | 61 | 62 | #### Before Submitting a Bug Report 63 | 64 | A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. 65 | 66 | - Make sure that you are using the latest version. 67 | - Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://github.com/sanidhyy/genius-ai/wiki). If you are looking for support, you might want to check [this section](#i-have-a-question)). 68 | - To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/sanidhyy/genius-aiissues?q=label%3Abug). 69 | - Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue. 70 | - Collect information about the bug: 71 | - Stack trace (Traceback) 72 | - OS, Platform and Version (Windows, Linux, macOS, x86, ARM) 73 | - Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant. 74 | - Possibly your input and the output 75 | - Can you reliably reproduce the issue? And can you also reproduce it with older versions? 76 | 77 | 78 | 79 | #### How Do I Submit a Good Bug Report? 80 | 81 | > You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to . 82 | 83 | We use GitHub issues to track bugs and errors. If you run into an issue with the project: 84 | 85 | - Open an [Issue](https://github.com/sanidhyy/genius-ai/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.) 86 | - Explain the behavior you would expect and the actual behavior. 87 | - Please provide as much context as possible and describe the _reproduction steps_ that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. 88 | - Provide the information you collected in the previous section. 89 | 90 | Once it's filed: 91 | 92 | - The project team will label the issue accordingly. 93 | - A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. 94 | - If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution). 95 | 96 | ### Suggesting Enhancements 97 | 98 | This section guides you through submitting an enhancement suggestion for Genius, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. 99 | 100 | 101 | 102 | #### Before Submitting an Enhancement 103 | 104 | - Make sure that you are using the latest version. 105 | - Read the [documentation](https://github.com/sanidhyy/genius-ai/wiki) carefully and find out if the functionality is already covered, maybe by an individual configuration. 106 | - Perform a [search](https://github.com/sanidhyy/genius-ai/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. 107 | - Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. 108 | 109 | 110 | 111 | #### How Do I Submit a Good Enhancement Suggestion? 112 | 113 | Enhancement suggestions are tracked as [GitHub issues](https://github.com/sanidhyy/genius-ai/issues). 114 | 115 | - Use a **clear and descriptive title** for the issue to identify the suggestion. 116 | - Provide a **step-by-step description of the suggested enhancement** in as many details as possible. 117 | - **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. 118 | - You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. 119 | - **Explain why this enhancement would be useful** to most Genius users. You may also want to point out the other projects that solved it better and which could serve as inspiration. 120 | 121 | 122 | 123 | ## Attribution 124 | 125 | This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)! 126 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Sanidhya Kumar Verma 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Genius - A Modern Next.js 14 SaaS AI Platform. 4 | 5 | ![Genius - A Modern Next.js 14 SaaS AI Platform.](/.github/images/img_main.png "Genius - A Modern Next.js 14 SaaS AI Platform.") 6 | 7 | [![Ask Me Anything!](https://flat.badgen.net/static/Ask%20me/anything?icon=github&color=black&scale=1.01)](https://github.com/sanidhyy "Ask Me Anything!") 8 | [![GitHub license](https://flat.badgen.net/github/license/sanidhyy/genius-ai?icon=github&color=black&scale=1.01)](https://github.com/sanidhyy/genius-ai/blob/main/LICENSE "GitHub license") 9 | [![Maintenance](https://flat.badgen.net/static/Maintained/yes?icon=github&color=black&scale=1.01)](https://github.com/sanidhyy/genius-ai/commits/main "Maintenance") 10 | [![GitHub branches](https://flat.badgen.net/github/branches/sanidhyy/genius-ai?icon=github&color=black&scale=1.01)](https://github.com/sanidhyy/genius-ai/branches "GitHub branches") 11 | [![Github commits](https://flat.badgen.net/github/commits/sanidhyy/genius-ai?icon=github&color=black&scale=1.01)](https://github.com/sanidhyy/genius-ai/commits "Github commits") 12 | [![GitHub issues](https://flat.badgen.net/github/issues/sanidhyy/genius-ai?icon=github&color=black&scale=1.01)](https://github.com/sanidhyy/genius-ai/issues "GitHub issues") 13 | [![GitHub pull requests](https://flat.badgen.net/github/prs/sanidhyy/genius-ai?icon=github&color=black&scale=1.01)](https://github.com/sanidhyy/genius-ai/pulls "GitHub pull requests") 14 | [![Netlify Status](https://api.netlify.com/api/v1/badges/b63626db-a322-49c1-b8d7-60ab157e7da6/deploy-status)](https://ai-genius.netlify.app/ "Netlify Status") 15 | 16 | 17 |
18 | 19 | 20 | 21 | # :notebook_with_decorative_cover: Table of Contents 22 | 23 | 24 | 25 | - [Folder Structure](#bangbang-folder-structure) 26 | - [Getting Started](#toolbox-getting-started) 27 | - [Screenshots](#camera-screenshots) 28 | - [Tech Stack](#gear-tech-stack) 29 | - [Stats](#wrench-stats) 30 | - [Contribute](#raised_hands-contribute) 31 | - [Acknowledgements](#gem-acknowledgements) 32 | - [Buy Me a Coffee](#coffee-buy-me-a-coffee) 33 | - [Follow Me](#rocket-follow-me) 34 | - [Learn More](#books-learn-more) 35 | - [Deploy on Vercel](#page_with_curl-deploy-on-vercel) 36 | - [Give A Star](#star-give-a-star) 37 | - [Star History](#star2-star-history) 38 | - [Give A Star](#star-give-a-star) 39 | 40 |
41 | 42 | ## :bangbang: Folder Structure 43 | 44 | Here is the folder structure of this app. 45 | 46 | ```bash 47 | genius-ai/ 48 | |- app/ 49 | |-- (auth)/ 50 | |--- (routes)/ 51 | |---- sign-in/[[...sign-in]]/ 52 | |---- sign-up/[[...sign-up]]/ 53 | |--- layout.tsx 54 | |-- (dashboard)/ 55 | |--- (routes)/ 56 | |---- code/ 57 | |---- conversation/ 58 | |---- dashboard/ 59 | |---- image/ 60 | |---- music/ 61 | |---- settings/ 62 | |---- video/ 63 | |--- layout.tsx 64 | |-- (landing)/ 65 | |--- layout.tsx 66 | |--- page.tsx 67 | |-- api/ 68 | |--- code/ 69 | |--- conversation/ 70 | |--- image/ 71 | |--- music/ 72 | |--- stripe/ 73 | |--- video/ 74 | |--- webhook/ 75 | |-- apple-icon.png 76 | |-- favicon.ico 77 | |-- globals.css 78 | |-- icon1.png 79 | |-- icon2.png 80 | |-- layout.tsx 81 | |- components/ 82 | |-- ui/ 83 | |-- bot-avatar.tsx 84 | |-- crisp-chat.tsx 85 | |-- empty.tsx 86 | |-- free-counter.tsx 87 | |-- heading.tsx 88 | |-- landing-content.tsx 89 | |-- landing-footer.tsx 90 | |-- landing-hero.tsx 91 | |-- landing-navbar.tsx 92 | |-- loader.tsx 93 | |-- mobile-sidebar.tsx 94 | |-- navbar.tsx 95 | |-- pro-modal.tsx 96 | |-- sidebar.tsx 97 | |-- subscription-button.tsx 98 | |-- user-avatar.tsx 99 | |- config/ 100 | |-- index.ts 101 | |- constants/ 102 | |-- index.ts 103 | |- hooks/ 104 | |-- use-pro-modal.tsx 105 | |- lib/ 106 | |-- api-limit.ts 107 | |-- db.ts 108 | |-- stripe.ts 109 | |-- subscription.ts 110 | |-- utils.ts 111 | |- prisma/ 112 | |-- schema.prisma 113 | |- providers/ 114 | |-- crisp-provider.tsx 115 | |-- modal-provider.tsx 116 | |-- toaster-provider.tsx 117 | |- public/ 118 | |-- testimonials/ 119 | |-- empty.png 120 | |-- logo.png 121 | |- schemas/ 122 | |-- index.ts 123 | |- .env 124 | |- .env.example 125 | |- .eslintrc.json 126 | |- .gitignore 127 | |- components.json 128 | |- environment.d.ts 129 | |- next.config.js 130 | |- package-lock.json 131 | |- package.json 132 | |- postcss.config.js 133 | |- tailwind.config.ts 134 | |- tsconfig.json 135 | ``` 136 | 137 |
138 | 139 | ## :toolbox: Getting Started 140 | 141 | 1. Make sure **Git** and **NodeJS** is installed. 142 | 2. Clone this repository to your local computer. 143 | 3. Create `.env` file in **root** directory. 144 | 4. Contents of `.env`: 145 | 146 | ```env 147 | # .env 148 | 149 | # disable next.js telemetry 150 | NEXT_TELEMETRY_DISABLED=1 151 | 152 | # clerk auth keys 153 | NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 154 | CLERK_SECRET_KEY=sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 155 | 156 | # clerk redirect uri 157 | NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in 158 | NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up 159 | NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard 160 | NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard 161 | 162 | # openai api key 163 | OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 164 | 165 | # replicate api token 166 | REPLICATE_API_TOKEN=r8_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 167 | 168 | # aiven database url 169 | DATABASE_URL="mysql://:@:/genius-ai?ssl-mode=REQUIRED" 170 | 171 | # stripe api/webhook secret key 172 | STRIPE_API_SECRET_KEY=sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 173 | STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 174 | 175 | # app base url 176 | NEXT_PUBLIC_APP_URL=http://localhost:3000 177 | 178 | # crisp website id 179 | NEXT_PUBLIC_CRISP_WEBSITE_ID=xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx 180 | ``` 181 | 182 | ### 5. Clerk Authentication Keys 183 | 184 | - Visit the Clerk dashboard: [https://clerk.dev](https://clerk.dev) 185 | - Log in to your Clerk account or sign up if you don't have one. 186 | - Go to the "Projects" section and select your project. 187 | - Navigate to the "API Keys" tab. 188 | - Copy the "Publishable Key" and replace `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` in the `.env.local` file with the copied key. 189 | - Copy the "Secret Key" and replace `CLERK_SECRET_KEY` in the `.env.local` file with the copied key. 190 | 191 | ### 6. OpenAI API Key 192 | 193 | Visit [OpenAI](https://platform.openai.com/signup/) and sign up for an account. Once registered, you can find your API key in the API section of your account settings. Copy the key and set it as the `OPENAI_API_KEY` in your project's environment. 194 | 195 | ```env 196 | OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 197 | ``` 198 | 199 | ### 7. Replicate API Token 200 | 201 | Sign up or log in to [Replicate](https://replicate.ai/). Once logged in, navigate to your account settings, and you'll find your API token. Copy the token and set it as the `REPLICATE_API_TOKEN` in your project's environment. 202 | 203 | ```env 204 | REPLICATE_API_TOKEN=r8_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 205 | ``` 206 | 207 | ### 8. Aiven Database URL 208 | 209 | If you don't have an Aiven account, sign up [here](https://aiven.io/). After creating an account, set up a MySQL database. In the Aiven dashboard, find your database connection details and construct the `DATABASE_URL` in the following format: 210 | 211 | ```env 212 | DATABASE_URL="mysql://:@:/genius-ai?ssl-mode=REQUIRED" 213 | ``` 214 | 215 | ### 9. Stripe API and Webhook Keys 216 | 217 | For Stripe, sign up or log in to your [Stripe Dashboard](https://dashboard.stripe.com/register). Once logged in, go to Developers > API keys to find your API secret key and webhook secret. Set them as `STRIPE_API_SECRET_KEY` and `STRIPE_WEBHOOK_SECRET` in your project's environment. 218 | 219 | ```env 220 | STRIPE_API_SECRET_KEY=sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 221 | STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 222 | ``` 223 | 224 | ### 10. App Base URL 225 | 226 | Set the base URL of your application as `NEXT_PUBLIC_APP_URL` in your project's environment. 227 | 228 | ```env 229 | NEXT_PUBLIC_APP_URL=http://localhost:3000 230 | ``` 231 | 232 | ### 11. Crisp Website ID 233 | 234 | Sign up on [Crisp](https://crisp.chat/en/) and create a website. Once created, find your website ID in the Crisp dashboard and set it as `NEXT_PUBLIC_CRISP_WEBSITE_ID` in your project's environment. 235 | 236 | ```env 237 | NEXT_PUBLIC_CRISP_WEBSITE_ID=xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx 238 | ``` 239 | 240 | 12. Open terminal in root directory. Run `npm install --legacy-peer-deps` or `yarn install --legacy-peer-deps`. 241 | 242 | 13. Now app is fully configured 👍 and you can start using this app using either one of `npm run dev` or `yarn dev`. 243 | 244 | **NOTE:** Please make sure to keep your API keys and configuration values secure and do not expose them publicly. 245 | 246 | ## :camera: Screenshots: 247 | 248 | ![Modern UI/UX](/.github/images/img1.png "Modern UI/UX") 249 | 250 | ![Conversation Page](/.github/images/img2.png "Conversation Page") 251 | 252 | ![Image Generation](/.github/images/img3.png "Image Generation") 253 | 254 | ![Code Generation](/.github/images/img4.png "Code Generation") 255 | 256 | ## :gear: Tech Stack 257 | 258 | [![React JS](https://skillicons.dev/icons?i=react "React JS")](https://react.dev/ "React JS") [![Next JS](https://skillicons.dev/icons?i=next "Next JS")](https://nextjs.org/ "Next JS") [![Typescript](https://skillicons.dev/icons?i=ts "Typescript")](https://www.typescriptlang.org/ "Typescript") [![Tailwind CSS](https://skillicons.dev/icons?i=tailwind "Tailwind CSS")](https://tailwindcss.com/ "Tailwind CSS") [![Netlify](https://skillicons.dev/icons?i=netlify "Netlify")](https://netlify.app/ "Netlify") [![Prisma](https://skillicons.dev/icons?i=prisma "Prisma")](https://prisma.io/ "Prisma") [![MySQL](https://skillicons.dev/icons?i=mysql "MySQL")](https://mysql.com/ "MySQL") 259 | 260 | ## :wrench: Stats 261 | 262 | [![Stats for Genius](/.github/images/stats.svg "Stats for Genius")](https://pagespeed.web.dev/analysis?url=https%3A%2F%2Fai-genius.netlify.app%2F "Stats for Genius") 263 | 264 | ## :raised_hands: Contribute 265 | 266 | You might encounter some bugs while using this app. You are more than welcome to contribute. Just submit changes via pull request and I will review them before merging. Make sure you follow community guidelines. 267 | 268 | ## :gem: Acknowledgements 269 | 270 | Useful resources and dependencies that are used in Genius. 271 | 272 | - Thanks to CodeWithAntonio: https://codewithantonio.com/ 273 | - [@clerk/nextjs](https://www.npmjs.com/package/@clerk/nextjs): ^4.29.3 274 | - [@hookform/resolvers](https://www.npmjs.com/package/@hookform/resolvers): ^3.3.4 275 | - [@prisma/client](https://www.npmjs.com/package/@prisma/client): ^5.8.0 276 | - [@radix-ui/react-avatar](https://www.npmjs.com/package/@radix-ui/react-avatar): ^1.0.4 277 | - [@radix-ui/react-dialog](https://www.npmjs.com/package/@radix-ui/react-dialog): ^1.0.5 278 | - [@radix-ui/react-label](https://www.npmjs.com/package/@radix-ui/react-label): ^2.0.2 279 | - [@radix-ui/react-progress](https://www.npmjs.com/package/@radix-ui/react-progress): ^1.0.3 280 | - [@radix-ui/react-select](https://www.npmjs.com/package/@radix-ui/react-select): ^2.0.0 281 | - [@radix-ui/react-slot](https://www.npmjs.com/package/@radix-ui/react-slot): ^1.0.2 282 | - [axios](https://www.npmjs.com/package/axios): ^1.6.5 283 | - [class-variance-authority](https://www.npmjs.com/package/class-variance-authority): ^0.7.0 284 | - [clsx](https://www.npmjs.com/package/clsx): ^2.1.0 285 | - [crisp-sdk-web](https://www.npmjs.com/package/crisp-sdk-web): ^1.0.21 286 | - [lucide-react](https://www.npmjs.com/package/lucide-react): ^0.309.0 287 | - [next](https://www.npmjs.com/package/next): 14.0.4 288 | - [openai](https://www.npmjs.com/package/openai): ^3.3.0 289 | - [react](https://www.npmjs.com/package/react): ^18 290 | - [react-dom](https://www.npmjs.com/package/react-dom): ^18 291 | - [react-hook-form](https://www.npmjs.com/package/react-hook-form): ^7.49.3 292 | - [react-markdown](https://www.npmjs.com/package/react-markdown): ^9.0.1 293 | - [replicate](https://www.npmjs.com/package/replicate): ^0.25.2 294 | - [sonner](https://www.npmjs.com/package/sonner): ^1.3.1 295 | - [stripe](https://www.npmjs.com/package/stripe): ^14.12.0 296 | - [tailwind-merge](https://www.npmjs.com/package/tailwind-merge): ^2.2.0 297 | - [tailwindcss-animate](https://www.npmjs.com/package/tailwindcss-animate): ^1.0.7 298 | - [typewriter-effect](https://www.npmjs.com/package/typewriter-effect): ^2.21.0 299 | - [zod](https://www.npmjs.com/package/zod): ^3.22.4 300 | - [zustand](https://www.npmjs.com/package/zustand): ^4.4.7 301 | - [@types/node](https://www.npmjs.com/package/@types/node): ^20 302 | - [@types/react](https://www.npmjs.com/package/@types/react): ^18 303 | - [@types/react-dom](https://www.npmjs.com/package/@types/react-dom): ^18 304 | - [autoprefixer](https://www.npmjs.com/package/autoprefixer): ^10.0.1 305 | - [eslint](https://www.npmjs.com/package/eslint): ^8 306 | - [eslint-config-next](https://www.npmjs.com/package/eslint-config-next): 14.0.4 307 | - [postcss](https://www.npmjs.com/package/postcss): ^8 308 | - [prisma](https://www.npmjs.com/package/prisma): ^5.8.0 309 | - [tailwindcss](https://www.npmjs.com/package/tailwindcss): ^3.3.0 310 | - [typescript](https://www.npmjs.com/package/typescript): ^5 311 | 312 | ## :coffee: Buy Me a Coffee 313 | 314 | [](https://www.buymeacoffee.com/sanidhy "Buy me a Coffee") 315 | 316 | ## :rocket: Follow Me 317 | 318 | [![Follow Me](https://img.shields.io/github/followers/sanidhyy?style=social&label=Follow&maxAge=2592000)](https://github.com/sanidhyy "Follow Me") 319 | [![Tweet about this project](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2FTechnicalShubam)](https://twitter.com/intent/tweet?text=Check+out+this+amazing+app:&url=https%3A%2F%2Fgithub.com%2Fsanidhyy%2Fgenius-ai "Tweet about this project") 320 | [![Subscribe to my YouTube Channel](https://img.shields.io/youtube/channel/subscribers/UCNAz_hUVBG2ZUN8TVm0bmYw)](https://www.youtube.com/@OPGAMER./?sub_confirmation=1 "Subscribe to my YouTube Channel") 321 | 322 | ## :books: Learn More 323 | 324 | To learn more about Next.js, take a look at the following resources: 325 | 326 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 327 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 328 | 329 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 330 | 331 | ## :page_with_curl: Deploy on Vercel 332 | 333 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 334 | 335 | Check out [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 336 | 337 | ## :star: Give A Star 338 | 339 | You can also give this repository a star to show more people and they can use this repository. 340 | 341 | ## :star2: Star History 342 | 343 | 344 | 345 | 346 | 347 | Star History Chart 348 | 349 | 350 | 351 |
352 |

(back to top)

353 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /app/(auth)/(routes)/sign-in/[[...sign-in]]/page.tsx: -------------------------------------------------------------------------------- 1 | import { SignIn } from "@clerk/nextjs"; 2 | 3 | export default function Page() { 4 | return ; 5 | } 6 | -------------------------------------------------------------------------------- /app/(auth)/(routes)/sign-up/[[...sign-up]]/page.tsx: -------------------------------------------------------------------------------- 1 | import { SignUp } from "@clerk/nextjs"; 2 | 3 | export default function Page() { 4 | return ; 5 | } 6 | -------------------------------------------------------------------------------- /app/(auth)/layout.tsx: -------------------------------------------------------------------------------- 1 | import { Montserrat } from "next/font/google"; 2 | import Image from "next/image"; 3 | import Link from "next/link"; 4 | import type { PropsWithChildren } from "react"; 5 | 6 | import { cn } from "@/lib/utils"; 7 | 8 | const montserrat = Montserrat({ 9 | weight: "600", 10 | subsets: ["latin"], 11 | }); 12 | 13 | const AuthLayout = ({ children }: PropsWithChildren) => { 14 | return ( 15 |
16 | 17 |
18 | Genius logo 19 |
20 | 21 |

22 | Genius 23 |

24 | 25 | {children} 26 |
27 | ); 28 | }; 29 | 30 | export default AuthLayout; 31 | -------------------------------------------------------------------------------- /app/(dashboard)/(routes)/code/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { zodResolver } from "@hookform/resolvers/zod"; 4 | import axios from "axios"; 5 | import { Code } from "lucide-react"; 6 | import { useRouter } from "next/navigation"; 7 | import type { ChatCompletionRequestMessage } from "openai"; 8 | import { useState } from "react"; 9 | import { useForm } from "react-hook-form"; 10 | import ReactMarkdown from "react-markdown"; 11 | import { toast } from "sonner"; 12 | import * as z from "zod"; 13 | 14 | import { BotAvatar } from "@/components/bot-avatar"; 15 | import { Empty } from "@/components/empty"; 16 | import { Heading } from "@/components/heading"; 17 | import { Loader } from "@/components/loader"; 18 | import { UserAvatar } from "@/components/user-avatar"; 19 | import { Button } from "@/components/ui/button"; 20 | import { Form, FormControl, FormField, FormItem } from "@/components/ui/form"; 21 | import { Input } from "@/components/ui/input"; 22 | import { useProModal } from "@/hooks/use-pro-modal"; 23 | import { cn } from "@/lib/utils"; 24 | import { codeFormSchema } from "@/schemas"; 25 | 26 | const CodePage = () => { 27 | const proModal = useProModal(); 28 | const router = useRouter(); 29 | const [messages, setMessages] = useState([]); 30 | 31 | const form = useForm>({ 32 | resolver: zodResolver(codeFormSchema), 33 | defaultValues: { 34 | prompt: "", 35 | }, 36 | }); 37 | 38 | const isLoading = form.formState.isSubmitting; 39 | 40 | const onSubmit = async (values: z.infer) => { 41 | try { 42 | const userMessage: ChatCompletionRequestMessage = { 43 | role: "user", 44 | content: values.prompt, 45 | }; 46 | 47 | const newMessages = [...messages, userMessage]; 48 | 49 | const response = await axios.post("/api/code", { 50 | messages: newMessages, 51 | }); 52 | 53 | setMessages((current) => [...current, userMessage, response.data]); 54 | } catch (error: unknown) { 55 | if (axios.isAxiosError(error) && error?.response?.status === 403) 56 | proModal.onOpen(); 57 | else toast.error("Something went wrong."); 58 | 59 | console.error(error); 60 | } finally { 61 | form.reset(); 62 | router.refresh(); 63 | } 64 | }; 65 | 66 | return ( 67 |
68 | 75 | 76 |
77 |
78 |
79 | 85 | ( 88 | 89 | 90 | 97 | 98 | 99 | )} 100 | /> 101 | 102 | 109 | 110 | 111 |
112 | 113 |
114 | {isLoading && ( 115 |
116 | 117 |
118 | )} 119 | {messages.length === 0 && !isLoading && ( 120 | 121 | )} 122 |
123 | {messages.map((message) => ( 124 |
133 | {message.role === "user" ? : } 134 |

135 | ( 138 |

139 |
140 |                         
141 | ), 142 | code: ({ node, ...props }) => ( 143 | 147 | ), 148 | }} 149 | className="text-sm overflow-hidden leading-7" 150 | > 151 | {message.content || ""} 152 | 153 |

154 |
155 | ))} 156 |
157 |
158 |
159 |
160 | ); 161 | }; 162 | 163 | export default CodePage; 164 | -------------------------------------------------------------------------------- /app/(dashboard)/(routes)/conversation/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { zodResolver } from "@hookform/resolvers/zod"; 4 | import axios from "axios"; 5 | import { MessageSquare } from "lucide-react"; 6 | import { useRouter } from "next/navigation"; 7 | import type { ChatCompletionRequestMessage } from "openai"; 8 | import { useState } from "react"; 9 | import { useForm } from "react-hook-form"; 10 | import { toast } from "sonner"; 11 | import * as z from "zod"; 12 | 13 | import { BotAvatar } from "@/components/bot-avatar"; 14 | import { Empty } from "@/components/empty"; 15 | import { Heading } from "@/components/heading"; 16 | import { Loader } from "@/components/loader"; 17 | import { UserAvatar } from "@/components/user-avatar"; 18 | import { Button } from "@/components/ui/button"; 19 | import { Form, FormControl, FormField, FormItem } from "@/components/ui/form"; 20 | import { Input } from "@/components/ui/input"; 21 | import { useProModal } from "@/hooks/use-pro-modal"; 22 | import { cn } from "@/lib/utils"; 23 | import { conversationFormSchema } from "@/schemas"; 24 | 25 | const ConversationPage = () => { 26 | const proModal = useProModal(); 27 | const router = useRouter(); 28 | const [messages, setMessages] = useState([]); 29 | 30 | const form = useForm>({ 31 | resolver: zodResolver(conversationFormSchema), 32 | defaultValues: { 33 | prompt: "", 34 | }, 35 | }); 36 | 37 | const isLoading = form.formState.isSubmitting; 38 | 39 | const onSubmit = async (values: z.infer) => { 40 | try { 41 | const userMessage: ChatCompletionRequestMessage = { 42 | role: "user", 43 | content: values.prompt, 44 | }; 45 | 46 | const newMessages = [...messages, userMessage]; 47 | 48 | const response = await axios.post("/api/conversation", { 49 | messages: newMessages, 50 | }); 51 | 52 | setMessages((current) => [...current, userMessage, response.data]); 53 | } catch (error: any) { 54 | if (axios.isAxiosError(error) && error?.response?.status === 403) 55 | proModal.onOpen(); 56 | else toast.error("Something went wrong."); 57 | 58 | console.error(error); 59 | } finally { 60 | form.reset(); 61 | router.refresh(); 62 | } 63 | }; 64 | 65 | return ( 66 |
67 | 74 | 75 |
76 |
77 |
78 | 84 | ( 87 | 88 | 89 | 96 | 97 | 98 | )} 99 | /> 100 | 101 | 108 | 109 | 110 |
111 | 112 |
113 | {isLoading && ( 114 |
115 | 116 |
117 | )} 118 | {messages.length === 0 && !isLoading && ( 119 | 120 | )} 121 |
122 | {messages.map((message, i) => ( 123 |
132 | {message.role === "user" ? : } 133 |

{message.content}

134 |
135 | ))} 136 |
137 |
138 |
139 |
140 | ); 141 | }; 142 | 143 | export default ConversationPage; 144 | -------------------------------------------------------------------------------- /app/(dashboard)/(routes)/dashboard/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { ArrowRight } from "lucide-react"; 4 | import { useRouter } from "next/navigation"; 5 | 6 | import { Card } from "@/components/ui/card"; 7 | import { TOOLS } from "@/constants"; 8 | import { cn } from "@/lib/utils"; 9 | 10 | const DashboardPage = () => { 11 | const router = useRouter(); 12 | 13 | return ( 14 |
15 |
16 |

17 | Explore the power of AI 18 |

19 |

20 | Chat with the smartest AI - Experience the power of AI. 21 |

22 |
23 | 24 |
25 | {TOOLS.map((tool) => ( 26 | router.push(tool.href)} 30 | > 31 |
32 |
33 | 34 |
35 | 36 |
{tool.label}
37 |
38 | 39 | 40 |
41 | ))} 42 |
43 |
44 | ); 45 | }; 46 | 47 | export default DashboardPage; 48 | -------------------------------------------------------------------------------- /app/(dashboard)/(routes)/image/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { zodResolver } from "@hookform/resolvers/zod"; 4 | import axios from "axios"; 5 | import { Download, ImageIcon } from "lucide-react"; 6 | import Image from "next/image"; 7 | import { useRouter } from "next/navigation"; 8 | import { useState } from "react"; 9 | import { useForm } from "react-hook-form"; 10 | import { toast } from "sonner"; 11 | import * as z from "zod"; 12 | 13 | import { Empty } from "@/components/empty"; 14 | import { Heading } from "@/components/heading"; 15 | import { Loader } from "@/components/loader"; 16 | import { Button } from "@/components/ui/button"; 17 | import { Card, CardFooter } from "@/components/ui/card"; 18 | import { Form, FormControl, FormField, FormItem } from "@/components/ui/form"; 19 | import { Input } from "@/components/ui/input"; 20 | import { 21 | Select, 22 | SelectContent, 23 | SelectItem, 24 | SelectTrigger, 25 | SelectValue, 26 | } from "@/components/ui/select"; 27 | import { useProModal } from "@/hooks/use-pro-modal"; 28 | import { imageFormSchema } from "@/schemas"; 29 | 30 | const amountOptions = [ 31 | { 32 | value: "1", 33 | label: "1 Photo", 34 | }, 35 | { 36 | value: "2", 37 | label: "2 Photos", 38 | }, 39 | { 40 | value: "3", 41 | label: "3 Photos", 42 | }, 43 | { 44 | value: "4", 45 | label: "4 Photos", 46 | }, 47 | { 48 | value: "5", 49 | label: "5 Photos", 50 | }, 51 | ]; 52 | 53 | const resolutionOptions = [ 54 | { 55 | value: "256x256", 56 | label: "256x256", 57 | }, 58 | { 59 | value: "512x512", 60 | label: "512x512", 61 | }, 62 | { 63 | value: "1024x1024", 64 | label: "1024x1024", 65 | }, 66 | ]; 67 | 68 | const ImagePage = () => { 69 | const proModal = useProModal(); 70 | const router = useRouter(); 71 | const [images, setImages] = useState([]); 72 | 73 | const form = useForm>({ 74 | resolver: zodResolver(imageFormSchema), 75 | defaultValues: { 76 | prompt: "", 77 | amount: "1", 78 | resolution: "512x512", 79 | }, 80 | }); 81 | 82 | const isLoading = form.formState.isSubmitting; 83 | 84 | const onSubmit = async (values: z.infer) => { 85 | try { 86 | setImages([]); 87 | 88 | const response = await axios.post("/api/image", values); 89 | 90 | const urls = response.data.map((image: { url: string }) => image.url); 91 | 92 | setImages(urls); 93 | } catch (error: unknown) { 94 | if (axios.isAxiosError(error) && error?.response?.status === 403) 95 | proModal.onOpen(); 96 | else toast.error("Something went wrong."); 97 | 98 | console.error(error); 99 | } finally { 100 | form.reset(); 101 | router.refresh(); 102 | } 103 | }; 104 | 105 | return ( 106 |
107 | 114 | 115 |
116 |
117 |
118 | 124 | ( 127 | 128 | 129 | 136 | 137 | 138 | )} 139 | /> 140 | 141 | ( 145 | 146 | 166 | 167 | )} 168 | /> 169 | 170 | ( 174 | 175 | 195 | 196 | )} 197 | /> 198 | 199 | 206 | 207 | 208 |
209 | 210 |
211 | {isLoading && ( 212 |
213 | 214 |
215 | )} 216 | {images.length === 0 && !isLoading && ( 217 | 218 | )} 219 | 220 |
221 | {images.map((src, i) => ( 222 | 223 |
224 | {`Generated 225 |
226 | 227 | 228 | 236 | 237 |
238 | ))} 239 |
240 |
241 |
242 |
243 | ); 244 | }; 245 | 246 | export default ImagePage; 247 | -------------------------------------------------------------------------------- /app/(dashboard)/(routes)/music/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { zodResolver } from "@hookform/resolvers/zod"; 4 | import axios from "axios"; 5 | import { Music } from "lucide-react"; 6 | import { useRouter } from "next/navigation"; 7 | import { useState } from "react"; 8 | import { useForm } from "react-hook-form"; 9 | import { toast } from "sonner"; 10 | import * as z from "zod"; 11 | 12 | import { Empty } from "@/components/empty"; 13 | import { Heading } from "@/components/heading"; 14 | import { Loader } from "@/components/loader"; 15 | import { Button } from "@/components/ui/button"; 16 | import { Form, FormControl, FormField, FormItem } from "@/components/ui/form"; 17 | import { Input } from "@/components/ui/input"; 18 | import { useProModal } from "@/hooks/use-pro-modal"; 19 | import { musicFormSchema } from "@/schemas"; 20 | 21 | const MusicPage = () => { 22 | const proModal = useProModal(); 23 | const router = useRouter(); 24 | const [music, setMusic] = useState(); 25 | 26 | const form = useForm>({ 27 | resolver: zodResolver(musicFormSchema), 28 | defaultValues: { 29 | prompt: "", 30 | }, 31 | }); 32 | 33 | const isLoading = form.formState.isSubmitting; 34 | 35 | const onSubmit = async (values: z.infer) => { 36 | try { 37 | setMusic(undefined); 38 | 39 | const response = await axios.post("/api/music", values); 40 | 41 | setMusic(response.data.audio); 42 | } catch (error: unknown) { 43 | if (axios.isAxiosError(error) && error?.response?.status === 403) 44 | proModal.onOpen(); 45 | else toast.error("Something went wrong."); 46 | 47 | console.error(error); 48 | } finally { 49 | form.reset(); 50 | router.refresh(); 51 | } 52 | }; 53 | 54 | return ( 55 |
56 | 63 | 64 |
65 |
66 |
67 | 73 | ( 76 | 77 | 78 | 85 | 86 | 87 | )} 88 | /> 89 | 90 | 97 | 98 | 99 |
100 | 101 |
102 | {isLoading && ( 103 |
104 | 105 |
106 | )} 107 | {!music && !isLoading && } 108 | 109 | {music && ( 110 | 113 | )} 114 |
115 |
116 |
117 | ); 118 | }; 119 | 120 | export default MusicPage; 121 | -------------------------------------------------------------------------------- /app/(dashboard)/(routes)/settings/page.tsx: -------------------------------------------------------------------------------- 1 | import { Settings } from "lucide-react"; 2 | 3 | import { Heading } from "@/components/heading"; 4 | import { SubscriptionButton } from "@/components/subscription-button"; 5 | import { checkSubscription } from "@/lib/subscription"; 6 | 7 | const SettingsPage = async () => { 8 | const isPro = await checkSubscription(); 9 | 10 | return ( 11 |
12 | 19 | 20 |
21 |
22 | {isPro 23 | ? "You are currently on a pro plan." 24 | : "You are currently on a free plan."} 25 |
26 | 27 | 28 |
29 |
30 | ); 31 | }; 32 | 33 | export default SettingsPage; 34 | -------------------------------------------------------------------------------- /app/(dashboard)/(routes)/video/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { zodResolver } from "@hookform/resolvers/zod"; 4 | import axios from "axios"; 5 | import { VideoIcon } from "lucide-react"; 6 | import { useRouter } from "next/navigation"; 7 | import { useState } from "react"; 8 | import { useForm } from "react-hook-form"; 9 | import { toast } from "sonner"; 10 | import * as z from "zod"; 11 | 12 | import { Empty } from "@/components/empty"; 13 | import { Heading } from "@/components/heading"; 14 | import { Loader } from "@/components/loader"; 15 | import { Button } from "@/components/ui/button"; 16 | import { Form, FormControl, FormField, FormItem } from "@/components/ui/form"; 17 | import { Input } from "@/components/ui/input"; 18 | import { useProModal } from "@/hooks/use-pro-modal"; 19 | import { videoFormSchema } from "@/schemas"; 20 | 21 | const VideoPage = () => { 22 | const proModal = useProModal(); 23 | const router = useRouter(); 24 | const [video, setVideo] = useState(); 25 | 26 | const form = useForm>({ 27 | resolver: zodResolver(videoFormSchema), 28 | defaultValues: { 29 | prompt: "", 30 | }, 31 | }); 32 | 33 | const isLoading = form.formState.isSubmitting; 34 | 35 | const onSubmit = async (values: z.infer) => { 36 | try { 37 | setVideo(undefined); 38 | 39 | const response = await axios.post("/api/video", values); 40 | 41 | setVideo(response.data[0]); 42 | } catch (error: unknown) { 43 | if (axios.isAxiosError(error) && error?.response?.status === 403) 44 | proModal.onOpen(); 45 | else toast.error("Something went wrong."); 46 | 47 | console.error(error); 48 | } finally { 49 | form.reset(); 50 | router.refresh(); 51 | } 52 | }; 53 | 54 | return ( 55 |
56 | 63 | 64 |
65 |
66 |
67 | 73 | ( 76 | 77 | 78 | 85 | 86 | 87 | )} 88 | /> 89 | 90 | 97 | 98 | 99 |
100 | 101 |
102 | {isLoading && ( 103 |
104 | 105 |
106 | )} 107 | {!video && !isLoading && } 108 | 109 | {video && ( 110 | 116 | )} 117 |
118 |
119 |
120 | ); 121 | }; 122 | 123 | export default VideoPage; 124 | -------------------------------------------------------------------------------- /app/(dashboard)/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { PropsWithChildren } from "react"; 2 | 3 | import { Navbar } from "@/components/navbar"; 4 | import { Sidebar } from "@/components/sidebar"; 5 | import { getApiLimitCount } from "@/lib/api-limit"; 6 | import { checkSubscription } from "@/lib/subscription"; 7 | 8 | const DashboardLayout = async ({ children }: PropsWithChildren) => { 9 | const apiLimitCount = await getApiLimitCount(); 10 | const isPro = await checkSubscription(); 11 | 12 | return ( 13 |
14 |
15 | 16 |
17 | 18 |
19 | 20 | {children} 21 |
22 |
23 | ); 24 | }; 25 | 26 | export default DashboardLayout; 27 | -------------------------------------------------------------------------------- /app/(landing)/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { PropsWithChildren } from "react"; 2 | 3 | const LandingLayout = ({ children }: PropsWithChildren) => { 4 | return ( 5 |
6 |
{children}
7 |
8 | ); 9 | }; 10 | 11 | export default LandingLayout; 12 | -------------------------------------------------------------------------------- /app/(landing)/page.tsx: -------------------------------------------------------------------------------- 1 | import { LandingContent } from "@/components/landing-content"; 2 | import { LandingFooter } from "@/components/landing-footer"; 3 | import { LandingHero } from "@/components/landing-hero"; 4 | import { LandingNavbar } from "@/components/landing-navbar"; 5 | 6 | const LandingPage = () => { 7 | return ( 8 |
9 | 10 | 11 | 12 | 13 |
14 | ); 15 | }; 16 | 17 | export default LandingPage; 18 | -------------------------------------------------------------------------------- /app/api/code/route.ts: -------------------------------------------------------------------------------- 1 | import { auth } from "@clerk/nextjs"; 2 | import { type NextRequest, NextResponse } from "next/server"; 3 | import { 4 | type ChatCompletionRequestMessage, 5 | Configuration, 6 | OpenAIApi, 7 | } from "openai"; 8 | 9 | import { increaseApiLimit, checkApiLimit } from "@/lib/api-limit"; 10 | import { checkSubscription } from "@/lib/subscription"; 11 | 12 | const configuration = new Configuration({ 13 | apiKey: process.env.OPENAI_API_KEY, 14 | }); 15 | 16 | const openai = new OpenAIApi(configuration); 17 | 18 | const intructionMessage: ChatCompletionRequestMessage = { 19 | role: "system", 20 | content: 21 | "You are a code generator. You must answer only in markdown code snippets. Use code comments for explaination.", 22 | }; 23 | 24 | export async function POST(req: NextRequest) { 25 | try { 26 | const { userId } = auth(); 27 | 28 | const body = await req.json(); 29 | const { messages } = body; 30 | 31 | if (!userId) return new NextResponse("Unauthorized.", { status: 401 }); 32 | if (!configuration.apiKey) 33 | return new NextResponse("OpenAI api key not configured.", { 34 | status: 500, 35 | }); 36 | 37 | if (!messages) 38 | return new NextResponse("Messages are required.", { status: 400 }); 39 | 40 | const freeTrial = await checkApiLimit(); 41 | const isPro = await checkSubscription(); 42 | 43 | if (!freeTrial && !isPro) 44 | return new NextResponse("Free trial has expired.", { status: 403 }); 45 | 46 | const response = await openai.createChatCompletion({ 47 | model: "gpt-3.5-turbo", 48 | messages: [intructionMessage, ...messages], 49 | }); 50 | 51 | if (!isPro) await increaseApiLimit(); 52 | 53 | return NextResponse.json(response.data.choices[0].message, { status: 200 }); 54 | } catch (error: unknown) { 55 | console.error("[CODE_ERROR]: ", error); 56 | return new NextResponse("Internal server error.", { status: 500 }); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/api/conversation/route.ts: -------------------------------------------------------------------------------- 1 | import { auth } from "@clerk/nextjs"; 2 | import { type NextRequest, NextResponse } from "next/server"; 3 | import { Configuration, OpenAIApi } from "openai"; 4 | 5 | import { increaseApiLimit, checkApiLimit } from "@/lib/api-limit"; 6 | import { checkSubscription } from "@/lib/subscription"; 7 | 8 | const configuration = new Configuration({ 9 | apiKey: process.env.OPENAI_API_KEY, 10 | }); 11 | 12 | const openai = new OpenAIApi(configuration); 13 | 14 | export async function POST(req: NextRequest) { 15 | try { 16 | const { userId } = auth(); 17 | 18 | const body = await req.json(); 19 | const { messages } = body; 20 | 21 | if (!userId) return new NextResponse("Unauthorized.", { status: 401 }); 22 | if (!configuration.apiKey) 23 | return new NextResponse("OpenAI api key not configured.", { 24 | status: 500, 25 | }); 26 | 27 | if (!messages) 28 | return new NextResponse("Messages are required.", { status: 400 }); 29 | 30 | const freeTrial = await checkApiLimit(); 31 | const isPro = await checkSubscription(); 32 | 33 | if (!freeTrial && !isPro) 34 | return new NextResponse("Free trial has expired.", { status: 403 }); 35 | 36 | const response = await openai.createChatCompletion({ 37 | model: "gpt-3.5-turbo", 38 | messages, 39 | }); 40 | 41 | if (!isPro) await increaseApiLimit(); 42 | 43 | return NextResponse.json(response.data.choices[0].message, { status: 200 }); 44 | } catch (error: unknown) { 45 | console.error("[CONVERSATION_ERROR]: ", error); 46 | return new NextResponse("Internal server error.", { status: 500 }); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/api/image/route.ts: -------------------------------------------------------------------------------- 1 | import { auth } from "@clerk/nextjs"; 2 | import { type NextRequest, NextResponse } from "next/server"; 3 | import { Configuration, OpenAIApi } from "openai"; 4 | 5 | import { increaseApiLimit, checkApiLimit } from "@/lib/api-limit"; 6 | import { checkSubscription } from "@/lib/subscription"; 7 | 8 | const configuration = new Configuration({ 9 | apiKey: process.env.OPENAI_API_KEY, 10 | }); 11 | 12 | const openai = new OpenAIApi(configuration); 13 | 14 | export async function POST(req: NextRequest) { 15 | try { 16 | const { userId } = auth(); 17 | 18 | const body = await req.json(); 19 | const { prompt, amount = "1", resolution = "512x512" } = body; 20 | 21 | if (!userId) return new NextResponse("Unauthorized.", { status: 401 }); 22 | if (!configuration.apiKey) 23 | return new NextResponse("OpenAI api key not configured.", { 24 | status: 500, 25 | }); 26 | 27 | if (!prompt) 28 | return new NextResponse("Prompt is required.", { status: 400 }); 29 | 30 | if (!amount) 31 | return new NextResponse("Amount is required.", { status: 400 }); 32 | 33 | if (!resolution) 34 | return new NextResponse("Resolution is required.", { status: 400 }); 35 | 36 | const freeTrial = await checkApiLimit(); 37 | const isPro = await checkSubscription(); 38 | 39 | if (!freeTrial && !isPro) 40 | return new NextResponse("Free trial has expired.", { status: 403 }); 41 | 42 | const response = await openai.createImage({ 43 | prompt, 44 | n: parseInt(amount, 10), 45 | size: resolution, 46 | }); 47 | 48 | if (!isPro) await increaseApiLimit(); 49 | 50 | return NextResponse.json(response.data.data, { status: 200 }); 51 | } catch (error: unknown) { 52 | console.error("[IMAGE_ERROR]: ", error); 53 | return new NextResponse("Internal server error.", { status: 500 }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/api/music/route.ts: -------------------------------------------------------------------------------- 1 | import { auth } from "@clerk/nextjs"; 2 | import { type NextRequest, NextResponse } from "next/server"; 3 | import Replicate from "replicate"; 4 | 5 | import { increaseApiLimit, checkApiLimit } from "@/lib/api-limit"; 6 | import { checkSubscription } from "@/lib/subscription"; 7 | 8 | const replicate = new Replicate({ 9 | auth: process.env.REPLICATE_API_TOKEN!, 10 | }); 11 | 12 | export async function POST(req: NextRequest) { 13 | try { 14 | const { userId } = auth(); 15 | 16 | const body = await req.json(); 17 | const { prompt } = body; 18 | 19 | if (!userId) return new NextResponse("Unauthorized.", { status: 401 }); 20 | 21 | if (!prompt) 22 | return new NextResponse("Prompt is required.", { status: 400 }); 23 | 24 | const freeTrial = await checkApiLimit(); 25 | const isPro = await checkSubscription(); 26 | 27 | if (!freeTrial && !isPro) 28 | return new NextResponse("Free trial has expired.", { status: 403 }); 29 | 30 | const response = await replicate.run( 31 | "riffusion/riffusion:8cf61ea6c56afd61d8f5b9ffd14d7c216c0a93844ce2d82ac1c9ecc9c7f24e05", 32 | { 33 | input: { 34 | prompt_a: prompt, 35 | }, 36 | }, 37 | ); 38 | 39 | if (!isPro) await increaseApiLimit(); 40 | 41 | return NextResponse.json(response, { status: 200 }); 42 | } catch (error: unknown) { 43 | console.error("[MUSIC_ERROR]: ", error); 44 | return new NextResponse("Internal server error.", { status: 500 }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/api/stripe/route.ts: -------------------------------------------------------------------------------- 1 | import { auth, currentUser } from "@clerk/nextjs"; 2 | import { NextResponse } from "next/server"; 3 | 4 | import { db } from "@/lib/db"; 5 | import { stripe } from "@/lib/stripe"; 6 | import { absoluteUrl } from "@/lib/utils"; 7 | 8 | const settingsUrl = absoluteUrl("/settings"); 9 | 10 | export async function GET() { 11 | try { 12 | const { userId } = auth(); 13 | const user = await currentUser(); 14 | 15 | if (!userId || !user) 16 | return new NextResponse("Unauthorized.", { status: 401 }); 17 | 18 | const userSubscription = await db.userSubscription.findUnique({ 19 | where: { 20 | userId, 21 | }, 22 | }); 23 | 24 | if (userSubscription && userSubscription.stripeCustomerId) { 25 | const stripeSession = await stripe.billingPortal.sessions.create({ 26 | customer: userSubscription.stripeCustomerId, 27 | return_url: settingsUrl, 28 | }); 29 | 30 | return new NextResponse(JSON.stringify({ url: stripeSession.url }), { 31 | status: 200, 32 | }); 33 | } 34 | 35 | const stripeSession = await stripe.checkout.sessions.create({ 36 | success_url: settingsUrl, 37 | cancel_url: settingsUrl, 38 | payment_method_types: ["card"], 39 | mode: "subscription", 40 | billing_address_collection: "auto", 41 | customer_email: user.emailAddresses[0].emailAddress, 42 | line_items: [ 43 | { 44 | price_data: { 45 | currency: "USD", 46 | product_data: { 47 | name: "Genius Pro", 48 | description: "Unlimited AI Generations.", 49 | }, 50 | unit_amount: 2000, // $20 51 | recurring: { 52 | interval: "month", 53 | }, 54 | }, 55 | quantity: 1, 56 | }, 57 | ], 58 | metadata: { 59 | userId, 60 | }, 61 | }); 62 | 63 | return new NextResponse(JSON.stringify({ url: stripeSession.url }), { 64 | status: 200, 65 | }); 66 | } catch (error: unknown) { 67 | console.error("[STRIPE_ERROR]: ", error); 68 | return new NextResponse("Internal server error.", { status: 500 }); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/api/video/route.ts: -------------------------------------------------------------------------------- 1 | import { auth } from "@clerk/nextjs"; 2 | import { type NextRequest, NextResponse } from "next/server"; 3 | import Replicate from "replicate"; 4 | 5 | import { increaseApiLimit, checkApiLimit } from "@/lib/api-limit"; 6 | import { checkSubscription } from "@/lib/subscription"; 7 | 8 | const replicate = new Replicate({ 9 | auth: process.env.REPLICATE_API_TOKEN!, 10 | }); 11 | 12 | export async function POST(req: NextRequest) { 13 | try { 14 | const { userId } = auth(); 15 | 16 | const body = await req.json(); 17 | const { prompt } = body; 18 | 19 | if (!userId) return new NextResponse("Unauthorized.", { status: 401 }); 20 | 21 | if (!prompt) 22 | return new NextResponse("Prompt is required.", { status: 400 }); 23 | 24 | const freeTrial = await checkApiLimit(); 25 | const isPro = await checkSubscription(); 26 | 27 | if (!freeTrial && !isPro) 28 | return new NextResponse("Free trial has expired.", { status: 403 }); 29 | 30 | const response = await replicate.run( 31 | "anotherjesse/zeroscope-v2-xl:9f747673945c62801b13b84701c783929c0ee784e4748ec062204894dda1a351", 32 | { 33 | input: { 34 | prompt, 35 | }, 36 | }, 37 | ); 38 | 39 | if (!isPro) await increaseApiLimit(); 40 | 41 | return NextResponse.json(response, { status: 200 }); 42 | } catch (error: unknown) { 43 | console.error("[VIDEO_ERROR]: ", error); 44 | return new NextResponse("Internal server error.", { status: 500 }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/api/webhook/route.ts: -------------------------------------------------------------------------------- 1 | import { headers } from "next/headers"; 2 | import { type NextRequest, NextResponse } from "next/server"; 3 | import Stripe from "stripe"; 4 | 5 | import { db } from "@/lib/db"; 6 | import { stripe } from "@/lib/stripe"; 7 | 8 | export async function POST(req: NextRequest) { 9 | const body = await req.text(); 10 | const signature = headers().get("Stripe-Signature") as string; 11 | 12 | let event: Stripe.Event; 13 | 14 | try { 15 | event = stripe.webhooks.constructEvent( 16 | body, 17 | signature, 18 | process.env.STRIPE_WEBHOOK_SECRET!, 19 | ); 20 | } catch (error: any) { 21 | return new NextResponse(`Webhook Error: ${error?.message}`, { 22 | status: 400, 23 | }); 24 | } 25 | 26 | const session = event.data.object as Stripe.Checkout.Session; 27 | 28 | if (event.type === "checkout.session.completed") { 29 | const subscription = await stripe.subscriptions.retrieve( 30 | session.subscription as string, 31 | ); 32 | 33 | if (!session?.metadata?.userId) 34 | return new NextResponse("User id is required.", { status: 400 }); 35 | 36 | await db.userSubscription.create({ 37 | data: { 38 | userId: session?.metadata?.userId, 39 | stripeSubscriptionId: subscription.id, 40 | stripeCustomerId: subscription.customer as string, 41 | stripePriceId: subscription.items.data[0].price.id, 42 | stripeCurrentPeriodEnd: new Date( 43 | subscription.current_period_end * 1000, 44 | ), 45 | }, 46 | }); 47 | } 48 | 49 | if (event.type === "invoice.payment_succeeded") { 50 | const subscription = await stripe.subscriptions.retrieve( 51 | session.subscription as string, 52 | ); 53 | 54 | await db.userSubscription.update({ 55 | where: { 56 | stripeSubscriptionId: subscription.id, 57 | }, 58 | data: { 59 | stripePriceId: subscription.items.data[0].price.id, 60 | stripeCurrentPeriodEnd: new Date( 61 | subscription.current_period_end * 1000, 62 | ), 63 | }, 64 | }); 65 | } 66 | 67 | return new NextResponse(null, { status: 200 }); 68 | } 69 | -------------------------------------------------------------------------------- /app/apple-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/app/apple-icon.png -------------------------------------------------------------------------------- /app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/app/favicon.ico -------------------------------------------------------------------------------- /app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | html, 6 | body, 7 | :root { 8 | height: 100%; 9 | } 10 | 11 | @layer base { 12 | :root { 13 | --background: 0 0% 100%; 14 | --foreground: 222.2 84% 4.9%; 15 | 16 | --card: 0 0% 100%; 17 | --card-foreground: 222.2 84% 4.9%; 18 | 19 | --popover: 0 0% 100%; 20 | --popover-foreground: 222.2 84% 4.9%; 21 | 22 | --primary: 248 90% 66%; 23 | --primary-foreground: 210 40% 98%; 24 | 25 | --secondary: 210 40% 96.1%; 26 | --secondary-foreground: 222.2 47.4% 11.2%; 27 | 28 | --muted: 210 40% 96.1%; 29 | --muted-foreground: 215.4 16.3% 46.9%; 30 | 31 | --accent: 210 40% 96.1%; 32 | --accent-foreground: 222.2 47.4% 11.2%; 33 | 34 | --destructive: 0 84.2% 60.2%; 35 | --destructive-foreground: 210 40% 98%; 36 | 37 | --border: 214.3 31.8% 91.4%; 38 | --input: 214.3 31.8% 91.4%; 39 | --ring: 222.2 84% 4.9%; 40 | 41 | --radius: 0.5rem; 42 | } 43 | 44 | .dark { 45 | --background: 222.2 84% 4.9%; 46 | --foreground: 210 40% 98%; 47 | 48 | --card: 222.2 84% 4.9%; 49 | --card-foreground: 210 40% 98%; 50 | 51 | --popover: 222.2 84% 4.9%; 52 | --popover-foreground: 210 40% 98%; 53 | 54 | --primary: 210 40% 98%; 55 | --primary-foreground: 222.2 47.4% 11.2%; 56 | 57 | --secondary: 217.2 32.6% 17.5%; 58 | --secondary-foreground: 210 40% 98%; 59 | 60 | --muted: 217.2 32.6% 17.5%; 61 | --muted-foreground: 215 20.2% 65.1%; 62 | 63 | --accent: 217.2 32.6% 17.5%; 64 | --accent-foreground: 210 40% 98%; 65 | 66 | --destructive: 0 62.8% 30.6%; 67 | --destructive-foreground: 210 40% 98%; 68 | 69 | --border: 217.2 32.6% 17.5%; 70 | --input: 217.2 32.6% 17.5%; 71 | --ring: 212.7 26.8% 83.9%; 72 | } 73 | } 74 | 75 | @layer base { 76 | * { 77 | @apply border-border; 78 | } 79 | body { 80 | @apply bg-background text-foreground; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/app/icon1.png -------------------------------------------------------------------------------- /app/icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanidhyy/genius-ai/5cfdea2d7ee48b4671d06a00e9338e7cf756d906/app/icon2.png -------------------------------------------------------------------------------- /app/layout.tsx: -------------------------------------------------------------------------------- 1 | import { ClerkProvider } from "@clerk/nextjs"; 2 | import type { Metadata } from "next"; 3 | import { Inter } from "next/font/google"; 4 | import type { PropsWithChildren } from "react"; 5 | 6 | import { siteConfig } from "@/config"; 7 | import { CrispProvider } from "@/providers/crisp-provider"; 8 | import { ModalProvider } from "@/providers/modal-provider"; 9 | import { ToasterProvider } from "@/providers/toaster-provider"; 10 | 11 | import "./globals.css"; 12 | 13 | const inter = Inter({ subsets: ["latin"] }); 14 | 15 | export const metadata: Metadata = siteConfig; 16 | 17 | export default function RootLayout({ children }: PropsWithChildren) { 18 | return ( 19 | 29 | 30 | 31 | 32 | 33 | 34 | {children} 35 | 36 | 37 | 38 | ); 39 | } 40 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "default", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.ts", 8 | "css": "app/globals.css", 9 | "baseColor": "slate", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /components/bot-avatar.tsx: -------------------------------------------------------------------------------- 1 | import { Avatar, AvatarImage } from "@/components/ui/avatar"; 2 | 3 | export const BotAvatar = () => { 4 | return ( 5 | 6 | 7 | 8 | ); 9 | }; 10 | -------------------------------------------------------------------------------- /components/crisp-chat.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { useEffect } from "react"; 4 | import { Crisp } from "crisp-sdk-web"; 5 | 6 | export const CrispChat = () => { 7 | useEffect(() => { 8 | Crisp.configure(process.env.NEXT_PUBLIC_CRISP_WEBSITE_ID); 9 | }, []); 10 | 11 | return null; 12 | }; 13 | -------------------------------------------------------------------------------- /components/empty.tsx: -------------------------------------------------------------------------------- 1 | import Image from "next/image"; 2 | 3 | type EmptyProps = { 4 | label: string; 5 | }; 6 | 7 | export const Empty = ({ label }: EmptyProps) => { 8 | return ( 9 |
10 |
11 | Empty 12 |
13 | 14 |

{label}

15 |
16 | ); 17 | }; 18 | -------------------------------------------------------------------------------- /components/free-counter.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { Zap } from "lucide-react"; 4 | import { useEffect, useState } from "react"; 5 | 6 | import { Button } from "@/components/ui/button"; 7 | import { Card, CardContent } from "@/components/ui/card"; 8 | import { Progress } from "@/components/ui/progress"; 9 | import { MAX_FREE_COUNTS } from "@/constants"; 10 | import { useProModal } from "@/hooks/use-pro-modal"; 11 | 12 | type FreeCounterProps = { 13 | apiLimitCount: number; 14 | isPro: boolean; 15 | }; 16 | 17 | export const FreeCounter = ({ 18 | apiLimitCount = 0, 19 | isPro = false, 20 | }: FreeCounterProps) => { 21 | const proModal = useProModal(); 22 | const [isMounted, setIsMounted] = useState(false); 23 | 24 | useEffect(() => { 25 | setIsMounted(true); 26 | }, []); 27 | 28 | if (!isMounted) return null; 29 | 30 | if (isPro) return null; 31 | 32 | return ( 33 |
34 | 35 | 36 |
37 |

38 | {apiLimitCount} / {MAX_FREE_COUNTS} Free Generations 39 |

40 | 41 | 46 |
47 | 48 | 55 |
56 |
57 |
58 | ); 59 | }; 60 | -------------------------------------------------------------------------------- /components/heading.tsx: -------------------------------------------------------------------------------- 1 | import type { LucideIcon } from "lucide-react"; 2 | 3 | import { cn } from "@/lib/utils"; 4 | 5 | type HeadingProps = { 6 | title: string; 7 | description: string; 8 | icon: LucideIcon; 9 | iconColor?: string; 10 | bgColor?: string; 11 | }; 12 | 13 | export const Heading = ({ 14 | title, 15 | description, 16 | icon: Icon, 17 | iconColor, 18 | bgColor, 19 | }: HeadingProps) => { 20 | return ( 21 |
22 |
23 | 24 |
25 | 26 |
27 |

{title}

28 |

{description}

29 |
30 |
31 | ); 32 | }; 33 | -------------------------------------------------------------------------------- /components/landing-content.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { TESTIMONIALS } from "@/constants"; 4 | import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; 5 | import Image from "next/image"; 6 | 7 | export const LandingContent = () => { 8 | return ( 9 |
10 |

11 | Testimonials 12 |

13 | 14 |
15 | {TESTIMONIALS.map((testimonial) => ( 16 | 20 | 21 | 22 |
23 | user 30 |
31 |
32 |

{testimonial.name}

33 |

{testimonial.title}

34 |
35 |
36 | 37 | 38 | {testimonial.description} 39 | 40 |
41 |
42 | ))} 43 |
44 |
45 | ); 46 | }; 47 | -------------------------------------------------------------------------------- /components/landing-footer.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import Image from "next/image"; 4 | import Link from "next/link"; 5 | 6 | import { FOOTER_LINKS } from "@/constants"; 7 | 8 | export const LandingFooter = () => { 9 | return ( 10 | 35 | ); 36 | }; 37 | -------------------------------------------------------------------------------- /components/landing-hero.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { useAuth } from "@clerk/nextjs"; 4 | import Link from "next/link"; 5 | import TypewriterComponent from "typewriter-effect"; 6 | import { Button } from "./ui/button"; 7 | 8 | export const LandingHero = () => { 9 | const { isSignedIn } = useAuth(); 10 | 11 | return ( 12 |
13 |
14 |

The Best AI Tool for

15 |
16 | 29 |
30 |
31 | 32 |
33 | Create content using AI 10x faster. 34 |
35 | 36 |
37 | 46 |
47 | 48 |
49 | No credit card required. 50 |
51 |
52 | ); 53 | }; 54 | -------------------------------------------------------------------------------- /components/landing-navbar.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { useAuth } from "@clerk/nextjs"; 4 | import { Github } from "lucide-react"; 5 | import { Montserrat } from "next/font/google"; 6 | import Image from "next/image"; 7 | import Link from "next/link"; 8 | 9 | import { Button } from "@/components/ui/button"; 10 | import { links } from "@/config"; 11 | import { cn } from "@/lib/utils"; 12 | 13 | const font = Montserrat({ 14 | weight: "600", 15 | subsets: ["latin"], 16 | }); 17 | 18 | export const LandingNavbar = () => { 19 | const { isSignedIn } = useAuth(); 20 | 21 | return ( 22 | 49 | ); 50 | }; 51 | -------------------------------------------------------------------------------- /components/loader.tsx: -------------------------------------------------------------------------------- 1 | import Image from "next/image"; 2 | 3 | export const Loader = () => { 4 | return ( 5 |
6 |
7 | logo 8 |
9 | 10 |

Genius is thinking...

11 |
12 | ); 13 | }; 14 | -------------------------------------------------------------------------------- /components/mobile-sidebar.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { Menu } from "lucide-react"; 4 | import { useEffect, useState } from "react"; 5 | 6 | import { Button } from "@/components/ui/button"; 7 | import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; 8 | 9 | import { Sidebar } from "./sidebar"; 10 | 11 | type MobileSidebarProps = { 12 | apiLimitCount: number; 13 | isPro: boolean; 14 | }; 15 | 16 | export const MobileSidebar = ({ 17 | apiLimitCount = 0, 18 | isPro = false, 19 | }: MobileSidebarProps) => { 20 | const [isMounted, setIsMounted] = useState(false); 21 | 22 | useEffect(() => { 23 | setIsMounted(true); 24 | }, []); 25 | 26 | if (!isMounted) return null; 27 | 28 | return ( 29 | 30 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | ); 41 | }; 42 | -------------------------------------------------------------------------------- /components/navbar.tsx: -------------------------------------------------------------------------------- 1 | import { UserButton } from "@clerk/nextjs"; 2 | 3 | import { getApiLimitCount } from "@/lib/api-limit"; 4 | import { checkSubscription } from "@/lib/subscription"; 5 | 6 | import { MobileSidebar } from "./mobile-sidebar"; 7 | 8 | export const Navbar = async () => { 9 | const apiLimitCount = await getApiLimitCount(); 10 | const isPro = await checkSubscription(); 11 | 12 | return ( 13 |
14 | 15 | 16 |
17 | 18 |
19 |
20 | ); 21 | }; 22 | -------------------------------------------------------------------------------- /components/pro-modal.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import axios from "axios"; 4 | import { Check, Zap } from "lucide-react"; 5 | import { useState } from "react"; 6 | import { toast } from "sonner"; 7 | 8 | import { Badge } from "@/components/ui/badge"; 9 | import { Button } from "@/components/ui/button"; 10 | import { Card } from "@/components/ui/card"; 11 | import { 12 | Dialog, 13 | DialogContent, 14 | DialogDescription, 15 | DialogFooter, 16 | DialogHeader, 17 | DialogTitle, 18 | } from "@/components/ui/dialog"; 19 | import { TOOLS } from "@/constants"; 20 | import { useProModal } from "@/hooks/use-pro-modal"; 21 | import { cn } from "@/lib/utils"; 22 | 23 | export const ProModal = () => { 24 | const proModal = useProModal(); 25 | const [isLoading, setIsLoading] = useState(false); 26 | 27 | const onSubscribe = async () => { 28 | try { 29 | setIsLoading(true); 30 | 31 | const response = await axios.get("/api/stripe"); 32 | 33 | window.location.href = response.data.url; 34 | } catch (error: unknown) { 35 | toast.error("Something went wrong."); 36 | console.error("[STRIPE_CLIENT_ERROR]: ", error); 37 | } finally { 38 | setIsLoading(false); 39 | } 40 | }; 41 | 42 | return ( 43 | 44 | 45 | 46 | 47 |
48 | Upgrade to Genius 49 | 50 | pro 51 | 52 |
53 |
54 | 55 | 56 | {TOOLS.map((tool) => ( 57 | 61 |
62 |
63 | 64 |
65 | 66 |
{tool.label}
67 |
68 | 69 | 70 |
71 | ))} 72 |
73 |
74 | 75 | 76 | 87 | 88 |
89 |
90 | ); 91 | }; 92 | -------------------------------------------------------------------------------- /components/sidebar.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { Montserrat } from "next/font/google"; 4 | import Image from "next/image"; 5 | import Link from "next/link"; 6 | import { usePathname } from "next/navigation"; 7 | 8 | import { ROUTES } from "@/constants"; 9 | import { cn } from "@/lib/utils"; 10 | 11 | import { FreeCounter } from "./free-counter"; 12 | 13 | const montserrat = Montserrat({ 14 | weight: "600", 15 | subsets: ["latin"], 16 | }); 17 | 18 | type SidebarProps = { 19 | apiLimitCount: number; 20 | isPro: boolean; 21 | }; 22 | 23 | export const Sidebar = ({ apiLimitCount = 0, isPro = false }: SidebarProps) => { 24 | const pathname = usePathname(); 25 | 26 | return ( 27 |
28 |
29 | 30 |
31 | Genius logo 32 |
33 | 34 |

35 | Genius 36 |

37 | 38 | 39 |
40 | {ROUTES.map((route) => ( 41 | 51 |
52 | 53 | {route.label} 54 |
55 | 56 | ))} 57 |
58 |
59 | 60 | 61 |
62 | ); 63 | }; 64 | -------------------------------------------------------------------------------- /components/subscription-button.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import axios from "axios"; 4 | import { Zap } from "lucide-react"; 5 | import { useState } from "react"; 6 | import { toast } from "sonner"; 7 | 8 | import { Button } from "@/components/ui/button"; 9 | 10 | type SubscriptionButtonProps = { 11 | isPro: boolean; 12 | }; 13 | 14 | export const SubscriptionButton = ({ 15 | isPro = false, 16 | }: SubscriptionButtonProps) => { 17 | const [isLoading, setIsLoading] = useState(false); 18 | 19 | const onClick = async () => { 20 | try { 21 | setIsLoading(true); 22 | const response = await axios.get("/api/stripe"); 23 | 24 | window.location.href = response.data.url; 25 | } catch (error: unknown) { 26 | toast.error("Something went wrong."); 27 | console.error("[BILLING_ERROR]: ", error); 28 | } finally { 29 | setIsLoading(false); 30 | } 31 | }; 32 | 33 | return ( 34 | 43 | ); 44 | }; 45 | -------------------------------------------------------------------------------- /components/ui/avatar.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import * as React from "react"; 4 | import * as AvatarPrimitive from "@radix-ui/react-avatar"; 5 | 6 | import { cn } from "@/lib/utils"; 7 | 8 | const Avatar = React.forwardRef< 9 | React.ElementRef, 10 | React.ComponentPropsWithoutRef 11 | >(({ className, ...props }, ref) => ( 12 | 20 | )); 21 | Avatar.displayName = AvatarPrimitive.Root.displayName; 22 | 23 | const AvatarImage = React.forwardRef< 24 | React.ElementRef, 25 | React.ComponentPropsWithoutRef 26 | >(({ className, ...props }, ref) => ( 27 | 32 | )); 33 | AvatarImage.displayName = AvatarPrimitive.Image.displayName; 34 | 35 | const AvatarFallback = React.forwardRef< 36 | React.ElementRef, 37 | React.ComponentPropsWithoutRef 38 | >(({ className, ...props }, ref) => ( 39 | 47 | )); 48 | AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; 49 | 50 | export { Avatar, AvatarImage, AvatarFallback }; 51 | -------------------------------------------------------------------------------- /components/ui/badge.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { cva, type VariantProps } from "class-variance-authority"; 3 | 4 | import { cn } from "@/lib/utils"; 5 | 6 | const badgeVariants = cva( 7 | "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", 8 | { 9 | variants: { 10 | variant: { 11 | default: 12 | "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", 13 | secondary: 14 | "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", 15 | destructive: 16 | "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", 17 | outline: "text-foreground", 18 | 19 | // custom 20 | premium: 21 | "bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-primary-foreground border-0", 22 | }, 23 | }, 24 | defaultVariants: { 25 | variant: "default", 26 | }, 27 | }, 28 | ); 29 | 30 | export interface BadgeProps 31 | extends React.HTMLAttributes, 32 | VariantProps {} 33 | 34 | function Badge({ className, variant, ...props }: BadgeProps) { 35 | return ( 36 |
37 | ); 38 | } 39 | 40 | export { Badge, badgeVariants }; 41 | -------------------------------------------------------------------------------- /components/ui/button.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { Slot } from "@radix-ui/react-slot"; 3 | import { cva, type VariantProps } from "class-variance-authority"; 4 | 5 | import { cn } from "@/lib/utils"; 6 | 7 | const buttonVariants = cva( 8 | "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", 9 | { 10 | variants: { 11 | variant: { 12 | default: "bg-primary text-primary-foreground hover:bg-primary/90", 13 | destructive: 14 | "bg-destructive text-destructive-foreground hover:bg-destructive/90", 15 | outline: 16 | "border border-input bg-background hover:bg-accent hover:text-accent-foreground", 17 | secondary: 18 | "bg-secondary text-secondary-foreground hover:bg-secondary/80", 19 | ghost: "hover:bg-accent hover:text-accent-foreground", 20 | link: "text-primary underline-offset-4 hover:underline", 21 | 22 | // custom 23 | premium: 24 | "bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-white border-0", 25 | }, 26 | size: { 27 | default: "h-10 px-4 py-2", 28 | sm: "h-9 rounded-md px-3", 29 | lg: "h-11 rounded-md px-8", 30 | icon: "h-10 w-10", 31 | }, 32 | }, 33 | defaultVariants: { 34 | variant: "default", 35 | size: "default", 36 | }, 37 | }, 38 | ); 39 | 40 | export interface ButtonProps 41 | extends React.ButtonHTMLAttributes, 42 | VariantProps { 43 | asChild?: boolean; 44 | } 45 | 46 | const Button = React.forwardRef( 47 | ({ className, variant, size, asChild = false, ...props }, ref) => { 48 | const Comp = asChild ? Slot : "button"; 49 | return ( 50 | 55 | ); 56 | }, 57 | ); 58 | Button.displayName = "Button"; 59 | 60 | export { Button, buttonVariants }; 61 | -------------------------------------------------------------------------------- /components/ui/card.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | import { cn } from "@/lib/utils"; 4 | 5 | const Card = React.forwardRef< 6 | HTMLDivElement, 7 | React.HTMLAttributes 8 | >(({ className, ...props }, ref) => ( 9 |
17 | )); 18 | Card.displayName = "Card"; 19 | 20 | const CardHeader = React.forwardRef< 21 | HTMLDivElement, 22 | React.HTMLAttributes 23 | >(({ className, ...props }, ref) => ( 24 |
29 | )); 30 | CardHeader.displayName = "CardHeader"; 31 | 32 | const CardTitle = React.forwardRef< 33 | HTMLParagraphElement, 34 | React.HTMLAttributes 35 | >(({ className, ...props }, ref) => ( 36 |

44 | )); 45 | CardTitle.displayName = "CardTitle"; 46 | 47 | const CardDescription = React.forwardRef< 48 | HTMLParagraphElement, 49 | React.HTMLAttributes 50 | >(({ className, ...props }, ref) => ( 51 |

56 | )); 57 | CardDescription.displayName = "CardDescription"; 58 | 59 | const CardContent = React.forwardRef< 60 | HTMLDivElement, 61 | React.HTMLAttributes 62 | >(({ className, ...props }, ref) => ( 63 |

64 | )); 65 | CardContent.displayName = "CardContent"; 66 | 67 | const CardFooter = React.forwardRef< 68 | HTMLDivElement, 69 | React.HTMLAttributes 70 | >(({ className, ...props }, ref) => ( 71 |
76 | )); 77 | CardFooter.displayName = "CardFooter"; 78 | 79 | export { 80 | Card, 81 | CardHeader, 82 | CardFooter, 83 | CardTitle, 84 | CardDescription, 85 | CardContent, 86 | }; 87 | -------------------------------------------------------------------------------- /components/ui/dialog.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import * as React from "react"; 4 | import * as DialogPrimitive from "@radix-ui/react-dialog"; 5 | import { X } from "lucide-react"; 6 | 7 | import { cn } from "@/lib/utils"; 8 | 9 | const Dialog = DialogPrimitive.Root; 10 | 11 | const DialogTrigger = DialogPrimitive.Trigger; 12 | 13 | const DialogPortal = DialogPrimitive.Portal; 14 | 15 | const DialogClose = DialogPrimitive.Close; 16 | 17 | const DialogOverlay = React.forwardRef< 18 | React.ElementRef, 19 | React.ComponentPropsWithoutRef 20 | >(({ className, ...props }, ref) => ( 21 | 29 | )); 30 | DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; 31 | 32 | const DialogContent = React.forwardRef< 33 | React.ElementRef, 34 | React.ComponentPropsWithoutRef 35 | >(({ className, children, ...props }, ref) => ( 36 | 37 | 38 | 46 | {children} 47 | 48 | 49 | Close 50 | 51 | 52 | 53 | )); 54 | DialogContent.displayName = DialogPrimitive.Content.displayName; 55 | 56 | const DialogHeader = ({ 57 | className, 58 | ...props 59 | }: React.HTMLAttributes) => ( 60 |
67 | ); 68 | DialogHeader.displayName = "DialogHeader"; 69 | 70 | const DialogFooter = ({ 71 | className, 72 | ...props 73 | }: React.HTMLAttributes) => ( 74 |
81 | ); 82 | DialogFooter.displayName = "DialogFooter"; 83 | 84 | const DialogTitle = React.forwardRef< 85 | React.ElementRef, 86 | React.ComponentPropsWithoutRef 87 | >(({ className, ...props }, ref) => ( 88 | 96 | )); 97 | DialogTitle.displayName = DialogPrimitive.Title.displayName; 98 | 99 | const DialogDescription = React.forwardRef< 100 | React.ElementRef, 101 | React.ComponentPropsWithoutRef 102 | >(({ className, ...props }, ref) => ( 103 | 108 | )); 109 | DialogDescription.displayName = DialogPrimitive.Description.displayName; 110 | 111 | export { 112 | Dialog, 113 | DialogPortal, 114 | DialogOverlay, 115 | DialogClose, 116 | DialogTrigger, 117 | DialogContent, 118 | DialogHeader, 119 | DialogFooter, 120 | DialogTitle, 121 | DialogDescription, 122 | }; 123 | -------------------------------------------------------------------------------- /components/ui/form.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import * as LabelPrimitive from "@radix-ui/react-label"; 3 | import { Slot } from "@radix-ui/react-slot"; 4 | import { 5 | Controller, 6 | ControllerProps, 7 | FieldPath, 8 | FieldValues, 9 | FormProvider, 10 | useFormContext, 11 | } from "react-hook-form"; 12 | 13 | import { cn } from "@/lib/utils"; 14 | import { Label } from "@/components/ui/label"; 15 | 16 | const Form = FormProvider; 17 | 18 | type FormFieldContextValue< 19 | TFieldValues extends FieldValues = FieldValues, 20 | TName extends FieldPath = FieldPath, 21 | > = { 22 | name: TName; 23 | }; 24 | 25 | const FormFieldContext = React.createContext( 26 | {} as FormFieldContextValue, 27 | ); 28 | 29 | const FormField = < 30 | TFieldValues extends FieldValues = FieldValues, 31 | TName extends FieldPath = FieldPath, 32 | >({ 33 | ...props 34 | }: ControllerProps) => { 35 | return ( 36 | 37 | 38 | 39 | ); 40 | }; 41 | 42 | const useFormField = () => { 43 | const fieldContext = React.useContext(FormFieldContext); 44 | const itemContext = React.useContext(FormItemContext); 45 | const { getFieldState, formState } = useFormContext(); 46 | 47 | const fieldState = getFieldState(fieldContext.name, formState); 48 | 49 | if (!fieldContext) { 50 | throw new Error("useFormField should be used within "); 51 | } 52 | 53 | const { id } = itemContext; 54 | 55 | return { 56 | id, 57 | name: fieldContext.name, 58 | formItemId: `${id}-form-item`, 59 | formDescriptionId: `${id}-form-item-description`, 60 | formMessageId: `${id}-form-item-message`, 61 | ...fieldState, 62 | }; 63 | }; 64 | 65 | type FormItemContextValue = { 66 | id: string; 67 | }; 68 | 69 | const FormItemContext = React.createContext( 70 | {} as FormItemContextValue, 71 | ); 72 | 73 | const FormItem = React.forwardRef< 74 | HTMLDivElement, 75 | React.HTMLAttributes 76 | >(({ className, ...props }, ref) => { 77 | const id = React.useId(); 78 | 79 | return ( 80 | 81 |
82 | 83 | ); 84 | }); 85 | FormItem.displayName = "FormItem"; 86 | 87 | const FormLabel = React.forwardRef< 88 | React.ElementRef, 89 | React.ComponentPropsWithoutRef 90 | >(({ className, ...props }, ref) => { 91 | const { error, formItemId } = useFormField(); 92 | 93 | return ( 94 |