Skip to main content

Configuration

Overview

AIPDFQuery has two mode of operations: SaaS and Personal. The SaaS mode is a subscription-based model where users are charged for using the application's services.

The Personal mode is a free-to-use model where users can access the application without any subscription purchase. But the user should be activated by the admin.

Using Limits

To manage access to the application, you'll need to modify the /src/config/controller.ts file according to your specific requirements.

Usage Limit Management

On the future release, we will provide a dashboard to manage the using limit. please get in touch.

Personal Mode

Usges Mode

Ensure that the USING_MODE environment variable is set to either SaaS or PERSONAL to determine the operational mode of the application.

Users can upload documents. Chat limits might be enforced (you could limit the number of messages or the frequency of messaging). This mode seems more focused on individual users who use the application for personal use without any monetary transactions. Ensure a user-friendly interface for document upload.

Implement chat limits if necessary, considering performance and user experience. Focus on features that enhance individual productivity and user experience.

Necessary Envs

In the SaaS mode, new users are automatically set to ACTIVE upon registration, granting them immediate access to the application with limited features.

tip

You will get the .env.example file in the root directory of the application. You can rename it to .env and set the environment variables.

For the personal mode, you need to set the NEXT_PUBLIC_ USING MODE="PERSONAL" and USING_MODE="PERSONAL" in the .env file or NODE Environment as it is required.

# Required
# using mode should be {SaaS or PERSONAL} only
# case sensitive
# must be same value for both fields
USING_MODE="PERSONAL"
NEXT_PUBLIC_USING_MODE="PERSONAL"
User Inactivity

In the Personal mode, new users are initially set to INACTIVE, requiring manual activation by the admin via the dashboard interface to grant access privileges.

SaaS Mode

Users can also upload documents. Admin charges users every month for using the application. This mode seems more business-oriented, where users are charged for using the application's services.

Implement a subscription/payment system for monthly charges. Consider implementing features for managing subscriptions, such as upgrading/downgrading plans, pausing subscriptions, or managing billing information. Ensure secure payment processing to handle user transactions safely.

Necessary Envs

Transitioning between modes in the AIPDFQuery application is effortlessly achieved by simply configuring the USING_MODE variable to SaaS. This concise adjustment elegantly toggles the application into its SaaS mode.

For the SaaS mode, you need to set the NEXT_PUBLIC_USING MODE="SaaS" and USING_MODE="SaaS" in the .env file or NODE Environment as it is required.

# Required
# using mode should be {SaaS or PERSONAL} only
# case sensitive
# must be same value for both fields
USING_MODE="SaaS"
NEXT_PUBLIC_USING_MODE="SaaS"

In the SaaS mode, new users are automatically set to ACTIVE upon registration, granting them immediate access to the application with limited features.

Stripe Integration

The application uses Stripe for payment processing. Ensure that the necessary environment variables are set for the application to interact with Stripe. Go to the Stripe website, create an account, and obtain the required API key, webhook secret and subscription price ID.

You need to set those environment variables in the .env file or NODE Environment as it is required.

# Only for SaaS mode
# Stripe API Key for payment processing
# Go to this site https://stripe.com/ open a account and get a API secret key, webhook secret and subscription price id
# case sensitive
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
STRIPE_SUB_PRICE_ID=

# Pricing for the application
# Must be same with your Stripe subscription Price
# numeric value
FREE_PRICING=0 # always 0
PRO_PRICING=14

Stripe Webhook Integration

After setting the STRIPE_WEBHOOK_SECRET environment variable, you need to set the webhook URL in the Stripe dashboard. Go to the Stripe website, open the dashboard, and set the webhook URL.

Select these Events to listen to:

checkout.session.completed
invoice.payment_succeeded
subscription_schedule.canceled

Set the endpoint URL in the Stripe dashboard webhook:

https://yourdomain.com/api/webhooks/stripe
  • The webhook URL is used to listen to events from Stripe. When a user subscribes to a plan, the application listens to the checkout.session.completed event and updates the user's subscription status.

  • When a user's subscription is canceled, the application listens to the subscription_schedule.canceled event and updates the user's subscription status.

  • When a user's payment is successful, the application listens to the invoice.payment_succeeded event and updates the user's subscription status.

Stripe Webhook

Webhook endpoints is important for the application to listen to events from Stripe. To store payment information in your database.

Email Verification Integration

By default, AIPDFQuery uses Nodemailer for email verification. On the other hand, you can use SendGrid instead.

Env NameValuesDescription
EMAIL_VERIFY_OPTIONON or OFFRequired - Case sensitive - If "ON", server send mail on create new user, update password and set the isEmailVerify in database is false
IS_SENDGRIDON or OFFRequired - Case sensitive - If the value is "ON" then the email sending option will be SendGrid otherwise it will be nodemailer
SENDGRID_API_KEYCollect SendGrid api key.Only when IS_SENDGRID is ON - case sensitive - Use SendGrid for email verification
SMTP_HOSTExample: smtp.aipdfquery.comOnly when IS_SENDGRID is OFF - Case sensitive
SMTP_PORTExample: 465Only when IS_SENDGRID is OFF - Case sensitive
SMTP_EMAILExample: support@aipdfquery.comOnly when IS_SENDGRID is OFF - Case sensitive - Email sender
SMTP_EMAIL_PASSWORDExample: password123Only when IS_SENDGRID is OFF - Case sensitive - SMTP_EMAIL password
EMAIL_VERIFY_TIME_EXP600000Email validation time end
# .env file
EMAIL_VERIFY_OPTION="OFF"
IS_SENDGRID="OFF"
SENDGRID_API_KEY=
SMTP_HOST=
SMTP_PORT=
SMTP_EMAIL=
SMTP_EMAIL_PASSWORD=
EMAIL_VERIFY_TIME_EXP=600000

Resources:

Stripe Stripe Webhook SendGrid Nodemailer Nodemailer SMTP