|
| 1 | +--- |
| 2 | +title: "Organizing Resources with Taubyte Applications" |
| 3 | +author: Zaoui Amine |
| 4 | +featured: true |
| 5 | +draft: false |
| 6 | +tags: |
| 7 | + - tutorials |
| 8 | + - applications |
| 9 | + - organization |
| 10 | + - serverless |
| 11 | + - cloud |
| 12 | +image: |
| 13 | + src: /blog/images/taubyte-applications.png |
| 14 | + alt: Organizing Resources with Taubyte Applications |
| 15 | +summary: Applications in Taubyte let you group resources under logical units for better organization and access control. Learn how to create applications and scope resources to them while maintaining access to global resources. |
| 16 | +date: 2026-01-14T16:00:00Z |
| 17 | +categories: [Hand-on Learning] |
| 18 | +--- |
| 19 | + |
| 20 | +In Taubyte, resources can have either **global scope**—accessible from anywhere in your project—or **application scope**—contained within a specific application. **Applications** let you group resources under logical units for better organization, granular access control, and clearer project structure as your system grows. |
| 21 | + |
| 22 | +## What Are Applications? |
| 23 | + |
| 24 | +Applications are organizational containers within your Taubyte project. Each application: |
| 25 | + |
| 26 | +- Has access to its **own resources** plus any **global resources** |
| 27 | +- Provides logical separation between different parts of your system |
| 28 | +- Enables granular access control and management |
| 29 | +- Can have unique settings for databases, functions, and more |
| 30 | + |
| 31 | +### Example Use Cases |
| 32 | + |
| 33 | +| Application | Purpose | |
| 34 | +|-------------|---------| |
| 35 | +| `backend` | API services and business logic | |
| 36 | +| `admin` | Admin dashboard and management functions | |
| 37 | +| `public-api` | Customer-facing API endpoints | |
| 38 | +| `analytics` | Data processing and reporting | |
| 39 | + |
| 40 | +## Creating an Application |
| 41 | + |
| 42 | +From the sidebar, navigate to **Applications** and click the **+** button. |
| 43 | + |
| 44 | +Fill in the details: |
| 45 | + |
| 46 | +| Field | Description | Example | |
| 47 | +|-------|-------------|---------| |
| 48 | +| Name | Application identifier | `backend` | |
| 49 | +| Description | What this application does | `Backend API services` | |
| 50 | + |
| 51 | +Click **Validate** to save. |
| 52 | + |
| 53 | +Your application will now appear in the list. |
| 54 | + |
| 55 | +### Pushing Changes |
| 56 | + |
| 57 | +Changes are saved locally in your browser's virtual file system. To persist them: |
| 58 | + |
| 59 | +1. Click the **green button** in the bottom right corner |
| 60 | +2. Enter a commit message |
| 61 | +3. Click **Finish** |
| 62 | + |
| 63 | +> **Tip**: You don't need to push immediately. Continue working and push when you're ready. |
| 64 | +
|
| 65 | +## Adding Resources to an Application |
| 66 | + |
| 67 | +Click on the **application's name** to open it. |
| 68 | + |
| 69 | +Inside an application, you can define the same types of resources you would globally: |
| 70 | +- Functions |
| 71 | +- Databases |
| 72 | +- Websites |
| 73 | +- Storage |
| 74 | +- Messaging |
| 75 | + |
| 76 | +### Creating an Application-Scoped Function |
| 77 | + |
| 78 | +1. Go to the **Functions** tab within your application |
| 79 | +2. Click the **+** button |
| 80 | +3. Select the **ping_pong** template |
| 81 | +4. Set the domain to your generated domain |
| 82 | +5. Set the path to `/backend/ping` |
| 83 | + |
| 84 | +> **Note**: The path doesn't need to include the application name—you can use any path. |
| 85 | +
|
| 86 | +Switch to the **Code** tab and customize: |
| 87 | + |
| 88 | +```go |
| 89 | +package lib |
| 90 | + |
| 91 | +import ( |
| 92 | + "github.com/taubyte/go-sdk/event" |
| 93 | +) |
| 94 | + |
| 95 | +//export ping |
| 96 | +func ping(e event.Event) uint32 { |
| 97 | + h, err := e.HTTP() |
| 98 | + if err != nil { |
| 99 | + return 1 |
| 100 | + } |
| 101 | + |
| 102 | + h.Write([]byte("PONG from backend application!")) |
| 103 | + return 0 |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +Click **Validate** to save. |
| 108 | + |
| 109 | +### Pushing and Building |
| 110 | + |
| 111 | +Push your code—the new function will appear with a "1+ change" indicator. |
| 112 | + |
| 113 | +Add a commit message and click **Finish**. |
| 114 | + |
| 115 | +If using Dream locally, trigger a build: |
| 116 | + |
| 117 | +```bash |
| 118 | +dream inject push-all |
| 119 | +``` |
| 120 | + |
| 121 | +### Testing |
| 122 | + |
| 123 | +Once the build finishes, click the **lightning icon** to open the function's HTTP endpoint. |
| 124 | + |
| 125 | +If it doesn't open, ensure your generated domain is in your `/etc/hosts` file. |
| 126 | + |
| 127 | +The function should return: |
| 128 | +```bash |
| 129 | +PONG from backend application! |
| 130 | +``` |
| 131 | + |
| 132 | +## Resource Visibility |
| 133 | + |
| 134 | +Here's how resource visibility works with applications: |
| 135 | + |
| 136 | +```bash |
| 137 | +┌─────────────────────────────────────────────────────────────┐ |
| 138 | +│ PROJECT │ |
| 139 | +├─────────────────────────────────────────────────────────────┤ |
| 140 | +│ GLOBAL RESOURCES │ |
| 141 | +│ ├── shared_database │ |
| 142 | +│ ├── common_functions │ |
| 143 | +│ └── main_website │ |
| 144 | +├─────────────────────────────────────────────────────────────┤ |
| 145 | +│ APPLICATION: backend │ |
| 146 | +│ ├── Can access: ALL global resources │ |
| 147 | +│ ├── backend_database (application-scoped) │ |
| 148 | +│ └── api_functions (application-scoped) │ |
| 149 | +├─────────────────────────────────────────────────────────────┤ |
| 150 | +│ APPLICATION: admin │ |
| 151 | +│ ├── Can access: ALL global resources │ |
| 152 | +│ ├── admin_database (application-scoped) │ |
| 153 | +│ └── admin_functions (application-scoped) │ |
| 154 | +└─────────────────────────────────────────────────────────────┘ |
| 155 | +``` |
| 156 | + |
| 157 | +Key points: |
| 158 | +- Applications **can access global resources** |
| 159 | +- Applications **cannot access other applications' resources** |
| 160 | +- Global resources are **shared across all applications** |
| 161 | + |
| 162 | + |
| 163 | +## Benefits of Using Applications |
| 164 | + |
| 165 | +| Benefit | Description | |
| 166 | +|---------|-------------| |
| 167 | +| **Organization** | Group related resources logically | |
| 168 | +| **Access Control** | Isolate sensitive resources | |
| 169 | +| **Team Collaboration** | Different teams can own different applications | |
| 170 | +| **Maintainability** | Easier to navigate large projects | |
| 171 | +| **Scalability** | Add applications as your project grows | |
| 172 | + |
| 173 | +## When to Use Applications |
| 174 | + |
| 175 | +| Scenario | Recommendation | |
| 176 | +|----------|----------------| |
| 177 | +| Simple project (<10 resources) | Global resources only | |
| 178 | +| Multiple API domains | Separate applications | |
| 179 | +| Different access requirements | Applications for isolation | |
| 180 | +| Microservices architecture | One application per service | |
| 181 | +| Team boundaries | One application per team | |
| 182 | + |
| 183 | +## Conclusion |
| 184 | + |
| 185 | +You've learned how to: |
| 186 | + |
| 187 | +1. **Create applications** to organize resources |
| 188 | +2. **Add functions** within applications |
| 189 | +3. **Understand visibility** between global and application-scoped resources |
| 190 | + |
| 191 | +Applications provide a clean way to structure your project as it grows, enabling better organization and access control without sacrificing the ability to share common resources. |
| 192 | + |
| 193 | +Next, learn about the [CI/CD system](/blog/posts/cicd-taubyte) that builds and deploys your code automatically. |
| 194 | + |
0 commit comments