Backend as a Service
BaaS
Backend
Cloud
Desenvolvimento

Backend As A Service - Good Practices For Beginners

You learned HTML, CSS and JavaScript (or React Native/Flutter). You made the frontend of your app and it looks beautiful. Now you need to save the user data.

Backend As A Service - Good Practices For Beginners

You learned HTML, CSS and JavaScript (or React Native/Flutter). You made the frontend of your app and it looks beautiful. Now you need to save the user data. And you discover that you need to learn: Linux, Docker, SQL, Node.js, Express, JWT, Nginx, SSL...

Disheartening, right? This is where Backend as a Service (BaaS) saves you. Platforms like Firebase, Supabase and Appwrite give you all of this ready-made. You focus on the app, they focus on the server.

But be careful: "easy" doesn't mean "anyway." If you use it wrong, your app will be slow, insecure and expensive. Here are best practices to get you started on the right foot.

1. Client-Side Security

In the traditional model, the server hides the database. In BaaS, your app speaks directly to the bank. If you don't configure the rules, anyone can delete everything.

  • Golden Rule: Never trust the frontend.
  • The Practice: Configure the "Security Rules" (Firebase) or "Row Level Security" (Supabase).
    • Wrong: allow read, write: if true; (Door open).
    • Right: allow write: if request.auth.uid == resource.data.ownerId; (Only the owner edits).

2. Don't Search for Too Much Data (Querying)

NoSQL databases (like Firestore) charge per read. If you download 1,000 documents every time the user opens the app, you will exceed the free quota in one day.

  • Use Pagination: Download 10 items. When the user scrolls, download 10 more.
  • Filter on the Server: Don't download everything and filter with array.filter() in JavaScript. Use the bank filter (.where('status', '==', 'active')).

3. Data Structure (Data Modeling)

In SQL, you avoid duplicating data (Normalization). In NoSQL (Firestore), you must duplicate data (Denormalization).

  • If you have a post and want to show the author's name, save the author's name inside the post document.
  • Why?: To avoid having to read two documents (Post + User) to create a screen. Reading is money.

4. Indexes

If your app starts to slow down when searching, you probably forgot to create indexes.

  • An index is like the index of a book. It tells the bank where the information is without having to read the entire bank.
  • The Firebase/Supabase console usually warns you when an index is missing. Click on the link they suggest.

Conclusion

BaaS is a superpower for beginners. You can build an "Uber" or "Instagram" by yourself in weeks. But remember: ease has a price. Study the security rules and data modeling of your chosen platform. This will save you a lot of money and headaches in the future.

Also read