---
# System prepended metadata

title: DesignbyAI.co

---

# DesignbyAI.co

## Database
- Asset (Images)
    - ID*
    - Name
    - Slug
    - CreatedAt
    - FileType
    - OriginalSize
    - OriginalDimension
    - ThumbnailUrl
    - PreviewUrl
    - OriginalUrl
    - Type (Free, Subscribe, Premium)
- Category
    - ID*
    - Name
    - Slug
    - CreatedAt
- AssetCategory
    - AssetID*
    - CategoryID*
- Tag
    - ID*
    - Name
- AssetTag
    - AssetID*
    - TagID*
- Download
    - UserID*
    - AssetID*
    - NumberOfDownload
    - CreatedAt
    - UpdatedAt
- Role (Admin/Collaborator/User)
    - ID*
    - RoleName
- User
    - ID*
    - Email
    - Password
    - CreatedAt
    - UpdatedAt
    - LastLoginAt
    - FirstName
    - LastName
    - RoleID
    - AccountPlan (enum: "free", "premium", "professional")
    - SubscriptionExpiredAt
    - SubscriptionStartAt


## APIs:

- UserAPI: `/v1/users`
    - Register: POST `/register`
        - Body
            ```
                {
                    "email": "",
                    "password": "",
                    "firstName": "",
                    "lastName": ""
                }
            ```
    - Login: POST `/login`
        - Body
            ```
                {
                    "email": "",
                    "password": ""
                }
            ```
    - Social Login: POST `/login/social`
    - Profile: GET `/me`
    - Profile Update: PUT `/me`



- AssetAPI: `/v1/assets`
    - Get: GET ""
        - params: category, tag, offset, size
    - AssetDetail: GET `/:id`
    - Create: POST ""
        - Permissions: Role = Admin
- CategoryAPI: `/v1/categories`
    - Get: GET ""
        - params: category, tag, offset, size
    - Create: POST ""
        - Permissions: Role = Admin

- DownloadAPI: `/v1/downloads`
    - Download: GET `/:id` (JWT authentication)
        - params: assetID
    - History: GET "" (JWT authentication)

- (TBD) PremiumAPI:

## UseCases:

- Guest:
    - Login
    - Register
    - View Categories
    - View Assets
    - View Asset Preview
    - Download Free Assets
- User: (+Guest)
    - Download SubscribeOnly Assets
    - Get Histories.
    - Manage User Info
- Collaborators: (+User)
    - Create/Upload Asset
- Admin: (+User)
    - Create Category
    - Create/Upload Asset
    - Statistic
- (TBD) Premium: (+User)
    - Download Premium Assets

## Special Flows:
- Upload Asset:

```mermaid
sequenceDiagram
autonumber

Client->>+Server: POST /v1/assets 
Server->>Server: Check Permission
Server->>Server: Validate data
Server->>+S3/Cloud Storage: Upload thumbnail/preview/original asset
S3/Cloud Storage-->>-Server: urls
Server->>Server: Save info into Database
Server-->>-Client: Status
```

- Download Asset:

```mermaid
sequenceDiagram
autonumber

Client->>+Server: GET /v1/downloads/:id
Server->>Server: QueryDB & Check for Plan & Permission
Server->>+S3/Cloud Storage: get original asset
S3/Cloud Storage-->>-Server: original asset file
Server->>Server: Save log into Download table
Server-->>-Client: Return file
```
## Infrastructure:

- A load balancer to distribute incoming traffic to multiple backend servers for scalability and reliability.
- Multiple backend servers to handle API requests and run the background jobs.
- A database cluster for storing user information and image metadata (PostgreSQL).
- A storage solution using Amazon S3
