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 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 (caching), PostgreSQL
Core Features:

Dynamic menu categories

Real-time item availability toggling

AWS S3 image upload support

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

[ ] OAuth2.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

[ ] Prometheus + Grafana for monitoring


๐Ÿง  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

๐ŸŸฆ X (Twitter)

๐ŸŸฆ LinkedIn


Top comments (0)