DEV Community

EMMANUEL UDODIRIM
EMMANUEL UDODIRIM

Posted on

πŸ—οΈ Building Bivy Restaurant Microservices: My Role in the ERD Design & User/Menu Services

In today’s fast-paced digital restaurant ecosystem, scalability and modularity are non-negotiable. That’s why our team is engineering Bivy Restaurant Microservices β€” a backend system powered by FastAPI (Python) and NestJS (TypeScript) to streamline restaurant operations.

As a core backend contributor, I took ownership of:

βœ… Designing critical parts of the Entity-Relationship Diagram (ERD)
βœ… Leading the User Service (authentication + RBAC)
βœ… Architecting the Menu Service (dynamic categorization + inventory sync)

In this article, I’ll walk you through:

  1. πŸ“ My ERD design process

  2. πŸ›  The microservices I own

  3. 🧭 Key technical decisions & what’s coming next


  1. 🧩 Designing the Database: My ERD Contributions

A well-designed database is the heartbeat of any microservice architecture. Here’s how I approached Bivy’s schema design.

πŸ‘€ A. User Service Schema

The Challenge:
We needed secure authentication + flexible role management for admins, staff, and customers.

My Solution:

Built a normalized schema with USER and USER_ROLE tables

Designed it to be JWT-ready and role-extensible

erDiagram
USER {
int id PK
string email
string password_hash
string name
int role_id FK
}
USER_ROLE {
int id PK
string name
}
USER ||--o{ USER_ROLE : "has"

Why It Works:
βœ” Passwords are stored using bcrypt hashing
βœ” Roles are decoupled, enabling easy future expansions (like moderators or vendors)


🍽 B. Menu Service Schema

The Challenge:
Restaurants need menus that evolve β€” with categories, pricing, and availability β€” all while syncing with inventory without tight coupling.

My Solution:

Designed MENU_ITEM and CATEGORY tables

Introduced available flag for toggling visibility without touching inventory directly

erDiagram
MENU_ITEM {
int id PK
string name
float price
int category_id FK
bool available
}
CATEGORY {
int id PK
string name
}
MENU_ITEM }|--|| CATEGORY : "belongs_to"

Benefits:
βœ” Fully decoupled from inventory DB
βœ” Filtering is index-optimized for better performance


πŸ”— C. Cross-Service Collaboration

To maintain modularity, we ensured services communicate via event-driven architecture instead of direct DB joins.

Examples:

Orders reference both user_id and menu_item_id

Inventory syncs availability via Apache Kafka events


  1. πŸš€ Microservices I Lead

πŸ” A. User Service – FastAPI + JWT

Stack: Python, FastAPI, PostgreSQL, JWT

Core Features:

Secure Login/Registration

Role-Based Access Control (RBAC)

User profile endpoints


πŸ” B. Menu Service – Dynamic & Real-Time

Stack: Python, FastAPI, Redis, PostgreSQL,

Core Features:

Dynamic menu categories

Real-time item availability toggling

Image upload support (S3 integration)

Workflow Example:

  1. Admin adds a new item via /menu/items

  2. Menu service emits Kafka event to inventory

  3. If stock is available, item is flagged available=True and shown on the customer app


  1. πŸ“ Roadmap Ahead

🧭 User Service

[ ] OAuth 2.0 integration (Google / Facebook)

[ ] Passwordless login via magic links

🧭 Menu Service

[ ] Redis caching for fast menu queries

[ ] Seasonal menu activation (based on time or promo windows)

🧭 DevOps Goals

[ ] Kubernetes Helm Charts for scalable deployment

[ ] Monitoring via Prometheus + Grafana


🧠 Final Thoughts

By prioritizing clean ERD design, modular services, and event-driven architecture, Bivy is built to scale. This system will power:

πŸ’‘ 10,000+ concurrent users
βš™οΈ Zero-downtime deployments
πŸ”„ Real-time menu updates across all customer touchpoints

What I Learned:

The power of database-first thinking

The value of loose coupling between services

The necessity of security-by-default principles


πŸ’¬ Let’s Talk!

Have you ever built or contributed to a restaurant backend system?
How did you handle user roles, menu changes, or inventory sync?
Let’s discuss in the comments β€” I’d love to learn from your experience too.


πŸ“‘ Connect with Bivy Tech

🟦 Follow us on X (Twitter)

🟦 Connect on LinkedIn

Top comments (0)