Skip to content

airpdev/Bhuman_rust_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

backend_api

Welcome to BHuman!

Users come in here to make personalized videos at scale that look & feel 100% real.

What we have?

(Click on the title to access file and see its fields)

  1. users
  2. plans
  3. workspaces
  4. folders
  5. video_instances
  6. segments
  7. audio_labels
  8. audio_variables
  9. generated_videos
  10. audio
  11. actors
  12. files
  13. videos
  14. audio_batch
  15. audio_batch_data

Where is the APIs?

All of our APIs are located on main.rs and there is a simple API documentations on main.rs in readme section.

Deep dive in core!

We put the API core in src and organize them in three branch.

Title Description
handlers Contains the functions which categorized in multiple files.
types Contains the custom data type that we defined as struct and etc.
units -

Note: There is a "mod.rs" file in each branch. They are using for create connection between modules.

Where is our main function for APIs?

The files that contain our main functions for APIs categorized in two branch, handlers and types.

(Click on the file name to access the file)

Handlers Types
1 actors.rs actors.rs
2 audio_batch_data.rs audio_batch_data.rs
3 audio_batch.rs audio_batch.rs
4 audio.rs audio.rs
5 auth.rs auth.rs
6 csv.rs csv.rs
7 export_csv.rs -
8 folders.rs folders.rs
9 generated_video.rs generated_video.rs
10 new_audio.rs new_audio.rs
11 pipeline.rs -
12 plans.rs plans.rs
13 segments.rs segments.rs
14 template_videos.rs template_videos.rs
15 user.rs user.rs
16 video.rs video.rs
17 workspace.rs workspaces.rs

Welcome to APIs!

You can have a total look on our APIs in this section. Here, APIs prepared as a list. Also, you can find the sample details you need for calling these APIs.

What we have?

(Click on the file name to access the file)

API Method Function File
1 /api/auth POST GetAuth auth.rs
2 /api/tokenauth POST GetTokenAuth auth.rs
3 /api/getuser GET GetUser auth.rs
4 /api/pipeline POST new_send_to_pipline pipeline.rs
5 /api/server POST receive_from_pipline pipeline.rs
6 /api/user GET get_user user.rs
7 /api/user PUT update_user user.rs
8 /api/workspace POST create_workspace workspace.rs
9 /api/workspace GET get_workspace workspace.rs
10 /api/workspace PUT update_workspace workspace.rs
11 /api/workspace DELETE delete_workspace workspace.rs
12 /api/folder POST create_folder folders.rs
13 /api/folder GET get_folder folders.rs
14 /api/folder PUT update_folder folders.rs
15 /api/folder delete_folder folders.rs
16 /api/actor POST create_actor actors.rs
17 /api/actor GET get_actor actors.rs
18 /api/actor PUT update_actor actors.rs
19 /api/actor DELETE delete_actor actors.rs
20 /api/audio POST new_create_and_update_audio new_audio.rs
21 /api/audio GET new_get_audio new_audio.rs
22 /api/audio PUT new_update_audio2 new_audio.rs
23 /api/audio DELETE new_delete_audio new_audio.rs
24 /api/audio_batch POST create_batch audio_batch.rs
25 /api/audio_batch GET get_batch audio_batch.rs
26 /api/audio_batch PUT update_batch audio_batch.rs
27 /api/audio_batch DELETE delete_batch audio_batch.rs
28 /api/audio_batch_data POST csv_to_db csv.rs
29 /api/audio_batch_data GET get_batch_data audio_batch_data.rs
30 /api/fetch_audio GET fetch_audio new_audio.rs
31 /api/export_csv GET export_as_csv export_csv.rs
32 /api/old_audio POST create_audio audio.rs
33 /api/old_audio GET get_audio audio.rs
34 /api/old_audio DELETE delete_audio audio.rs
35 /api/audio_variable PUT update_audio_variable audio.rs
36 /api/audio_label PUT update_audio_label audio.rs
37 /api/video_instance POST create_video video.rs
38 /api/video_instance GET get_video video.rs
39 /api/video_instance PUT update_video video.rs
40 /api/video_instance DELETE delete_video video.rs
41 /api/video GET get_video template_videos.rs
42 /api/fetch_video GET fetch_video template_videos.rs
43 /api/fetch_generated_video GET fetch_generated_video generated_video.rs
44 /api/segment POST create_segment segments.rs
45 /api/segment GET get_segment segments.rs
46 /api/segment PUT update_segment segments.rs
47 /api/segment DELETE delete_segment segments.rs
48 /api/generated_video GET get_generated_video generated_video.rs
49 /api/checkout POST get_plan_checkout plans.rs
50 /api/plans GET get_plans plans.rs
51 /api/customer_portal POST customer_portal plans.rs
52 /api/stripe_webhook POST stripe_webhook plans.rs
53 /api/signup POST signup auth.rs
54 /api/upload_video POST upload_video template_videos.rs

Welcome to core!

In this section, you can find which function located in which file.

What we have?

(Click on the file name to access the file)

File Types
1 actors.rs create_actor, update_actor, delete_actor, get_actor
2 audio_batch_data.rs create_batch_data, update_audio_records, get_converted_batch_data, get_batch_data
3 audio_batch.rs create_batch, update_batch, delete_batch, get_batch,
4 audio.rs create_audio
5 auth.rs jwt, GetUser, GetAuth, GetTokenAuth, signup
6 csv.rs csv_to_db, upload_csv, from_csv_to_json, get_csv
7 export_csv.rs export_as_csv
8 folders.rs create_folder, update_folder, delete_folder, get_folder
9 generated_video.rs get_generated_video, fetch_generated_video,
10 jwt_authorization.rs jwt_auth
10 new_audio.rs fetch_audio, new_create_and_update_audio, new_update_audio2, new_delete_audio, new_get_audio
11 pipeline.rs new_send_to_pipline, send_to_pipline, receive_from_pipline,
12 plans.rs get_plan_checkout, customer_portal, stripe_webhook, get_plans,
13 segments.rs create_segment, update_segment, delete_segment, get_segment
14 storage.rs ensure_var, upload_create_video, generate_id, generate_unique_id, retrieve, upload, video_retrieve,
14 template_videos.rs upload_video, get_video, fetch_video
15 user.rs create_user, update_user, get_user, check_user
16 video.rs create_video, update_video, delete_video, get_video
17 workspace.rs create_workspace, update_workspace, delete_workspace, get_workspace

Welcome to SQL part!

In this section, you can find the properties or fields for each table.

(click on title to access the file)

This file contains the table structure in database for β€œusers”.

NULL Title Description
𐄂 id πŸ”‘ uuid – ID for user
𐄂 stytch_user_id TEXT – authentication for payments
𐄂 stripe_customer_id TEXT – customer ID for β€œstripe”
βœ“ stripe_subscription_id TEXT – subscription ID for β€œstripe”
βœ“ stripe_subscription_item_id TEXT – subscription item ID for β€œstripe”
βœ“ stripe_metred_subscription_item_id TEXT – ID for metred plan that user use in β€œstripe”
βœ“ plan_id uuid – plan ID that using by user
βœ“ org_id uuid – organization ID (option for future)
𐄂 fullname TEXT – Full name
𐄂 username TEXT – User name
𐄂 email TEXT – Email address
𐄂 generated_videos_quota BIGINT – limit for videos depends on plan ID
𐄂 generated_videos_used BIGINT – part of that limit which used by user
𐄂 not_binded_videos BIGINT – remaining part of limit that still not use
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp

Note: β€œstripe” is a payment service we are using.

Note: generated_videos_quota and generated_videos_used are exist on both user and workspace. they are connected to each other but they are not same.

Each user have multiple workspace. the generated_videos_quota and generated_videos_used in user information are limited for the user in all user's workspace. for example if generated_videos_used is 15, the 15 point to the total of all videos in all workspace that created by user. so, maybe the user have 2 workspace and used the 7 videos in "workspace 1" and 8 videos in "workspace 2".

and this is same for generated_videos_quota in users table. so, generated_videos_quota is a limit for total videos in all workspaces of user.

but in workspace, the (1)"generated_videos_quota" and (2)"generated_videos_used" is point to the (1)"limit number of videos" and (2)"number of videos which used" in the specific workspace for user.

based on the example about user table about: user_id= 123 has generated_videos_used = 15 with 7 videos in "workspace 1" and 8 videos in "workspace 2". just imagine we are in "workspace 1". so generated_videos_quota and generated_videos_used are limited to this workspace for user with user_id= 123.

before answer your question about the code, I want to mention to another field in users => "not_binded_videos" this is very important because it's our real limit for videos. why? we have the generated_videos_quota but not_binded_videos is tell us, how many videos remained based on the videos that we used (generated_videos_used)

So about your question. in this code user want to create a workspace. The user enter information for workspace, such as name and also generated_videos_quota. but generated_videos_quota is a limit for user's workspace and should not be more than our real limit. where the real limit? it's on not_binded_videos field.

(click on title to access the file)

This file contains the table structure in database for β€œplans”.

NULL Title Description
𐄂 id πŸ”‘ uuid – plan ID
βœ“ stripe_plan_id TEXT
βœ“ metred_stripe_plan_id TEXT
𐄂 quota BIGINT – limitation
𐄂 price NUMERIC – price for package
𐄂 is_metred_plan BOOLEAN
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œworkspaces”.

NULL Title Description
𐄂 id πŸ”‘ uuid – workspace ID
𐄂 name TEXT – name
𐄂 user_id uuid – ID for user
𐄂 parent_videos_quota BIGINT – (option for the future)
𐄂 parent_videos_used BIGINT – (option for the future)
𐄂 generated_videos_quota BIGINT – limit for videos depends on plan ID
𐄂 generated_videos_used BIGINT – part of that limit which used by user
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp

Note: generated_videos_quota and generated_videos_used are exist on both user and workspace. they are connected to each other but they are not same.

Each user have multiple workspace. the generated_videos_quota and generated_videos_used in user information are limited for the user in all user's workspace. for example if generated_videos_used is 15, the 15 point to the total of all videos in all workspace that created by user. so, maybe the user have 2 workspace and used the 7 videos in "workspace 1" and 8 videos in "workspace 2".

and this is same for generated_videos_quota in users table. so, generated_videos_quota is a limit for total videos in all workspaces of user.

but in workspace, the (1)"generated_videos_quota" and (2)"generated_videos_used" is point to the (1)"limit number of videos" and (2)"number of videos which used" in the specific workspace for user.

based on the example about user table about: user_id= 123 has generated_videos_used = 15 with 7 videos in "workspace 1" and 8 videos in "workspace 2". just imagine we are in "workspace 1". so generated_videos_quota and generated_videos_used are limited to this workspace for user with user_id= 123.

before answer your question about the code, I want to mention to another field in users => "not_binded_videos" this is very important because it's our real limit for videos. why? we have the generated_videos_quota but not_binded_videos is tell us, how many videos remained based on the videos that we used (generated_videos_used)

So about your question. in this code user want to create a workspace. The user enter information for workspace, such as name and also generated_videos_quota. but generated_videos_quota is a limit for user's workspace and should not be more than our real limit. where the real limit? it's on not_binded_videos field.

(click on title to access the file)

This file contains the table structure in database for β€œfolders”.

NULL Title Description
𐄂 id πŸ”‘ uuid – folder ID
𐄂 user_id TEXT – ID of the user
𐄂 workspace_id TEXT – ID of the workspace
βœ“ name TEXT – folder name
βœ“ parent_videos BIGINT – (option for future)
βœ“ generated_videos BIGINT – number of generated videos
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œvideo_instances”.

NULL Title Description
𐄂 id πŸ”‘ uuid – video_instances ID
𐄂 name TEXT – title
𐄂 user_id uuid – ID for user
𐄂 folder_id uuid – folder ID
βœ“ video_id uuid – video ID
βœ“ actor_id uuid – actore ID
βœ“ audio_batch_id uuid – audio batch ID
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œsegments”.

NULL Title Description
𐄂 id πŸ”‘ uuid – ID for segment
𐄂 user_id uuid – ID for user
𐄂 video_instance_id uuid – video_instance ID in its table
𐄂 prefix_time_marker_start TEXT – prefix start time
𐄂 prefix_time_marker_end TEXT – prefix end time
𐄂 suffix_time_marker_start TEXT – suffix start time
𐄂 suffix_time_marker_end TEXT – suffix start time
𐄂 audio_variable_column_id BIGINT – column number for variables
𐄂 audio_variable_name TEXT – name of the audio_variable
𐄂 variable_time_marker_start TEXT – start time for variable
𐄂 variable_time_marker_end TEXT – end time for variable
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp

Note: Each segment is a part of the video that users want to insert their data in. So if user have a video with 2 minutes length, and want to add data in 01:23 time and its data be 00:15 sec.

01:23 + 00:15 = 01:38

So, the data will be insert between 01:23 and 01:38. It means the video will divided into three section:

prefix: 00:00 to 01:22 Data: 01:23 to 01:38 Suffix: 01:38 to 02:00

(click on title to access the file)

This file contains the table structure in database for β€œaudio_labels”.

NULL Title Description
𐄂 id πŸ”‘ BIGSERIAL – ID for audio_labels
𐄂 user_id uuid – ID for user
𐄂 variable_id BIGINT – variable ID in audio_variables
βœ“ row_id Bigserial – row number
𐄂 name TEXT – name of the audio_label
𐄂 audio_url TEXT – url for the audio
𐄂 audio_length TEXT – length of the audio
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œaudio_variables”.

NULL Title Description
𐄂 id πŸ”‘ BIGSERIAL – variable ID
𐄂 user_id uuid – ID for user
𐄂 video_instance_id BIGINT – ID in video_instances table
𐄂 name TEXT – variable name
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œgenerated_videos”.

NULL Title Description
𐄂 id πŸ”‘ uuid – ID for generated video
𐄂 audio_lables TEXT – lable of the audio
𐄂 name TEXT – name of the generated video
𐄂 user_id uuid – ID for user
𐄂 batch_id uuid – batch ID
𐄂 video_instance_id uuid – ID in video_instance table
βœ“ video_url TEXT – url of the video
𐄂 status TEXT – current status
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œaudio”.

NULL Title Description
𐄂 id uuid – ID for audio
𐄂 user_id uuid – ID for user
𐄂 actor_id πŸ”‘ uuid – ID for actor
𐄂 name πŸ”‘ TEXT – name of the audio
𐄂 url TEXT – url for the audio
𐄂 audio_length TEXT – length of the audio
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œactors”.

NULL Title Description
𐄂 id πŸ”‘ uuid – ID for actor
𐄂 user_id πŸ”‘ uuid – ID for user
𐄂 name TEXT – actor’s name
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œfiles”.

NULL Title Description
𐄂 id uuid – file ID
𐄂 user_id πŸ”‘ uuid – ID for user
𐄂 name πŸ”‘ TEXT – file name
𐄂 url TEXT – file url
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œvideos”.

NULL Title Description
𐄂 id πŸ”‘ uuid – video ID
𐄂 user_id uuid – ID for user
𐄂 name TEXT
𐄂 url TEXT – video url
𐄂 length TEXT – video lengtth
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œaudio_batch”.

NULL Title Description
𐄂 id πŸ”‘ uuid – ID for audio_batch
𐄂 user_id uuid – ID for user
𐄂 name TEXT – name of the audio_batch
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp
(click on title to access the file)

This file contains the table structure in database for β€œaudio_batch_data”.

NULL Title Description
𐄂 id πŸ”‘ uuid – ID of the audio_batch_data
𐄂 audio_batch_id uuid – ID of the audio_batch
𐄂 user_id uuid – ID of the user
βœ“ name TEXT – name of the audio_batch_data
βœ“ audio_id uuid – ID of the audio
βœ“ row_id BIGINT – row number
βœ“ column_id BIGINT – column number
𐄂 created_at TIMESTAMP(3) – Created timestamp
𐄂 updated_at TIMESTAMP(3) – Updated timestamp

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages