I built a production ready backend for a restaurant ordering platform using Go. The system called Peace Restaurant Co. covers multirole authentication, menu management, transactional order processing, real time order lifecycle tracking, and administrative analytics, all backed by PostgreSQL.
Here is the repo if you want to look through the code: https://github.com/PeaceMelodi/GolangPeace_Restaurantco_App
I also recorded a short demo on YouTube so you can watch the system working end to end before you dive into the code.
The Architecture
The project follows a clean layered structure. Handlers parse requests and write responses. Services hold the business logic. Repositories own the database layer. Models define the contracts everything else depends on.
Each layer talks to the next through interfaces. That keeps the code decoupled and easy to test, and it means I can swap out an implementation without touching the layers around it.
Data Access Without an ORM
For data access I used SQLX with PGX. There is no ORM in this project. Every repository method is explicit. Parameterized queries prevent injection. Structs map to rows using db tags. It is just typed queries returning typed results, and it makes the SQL predictable instead of hidden behind a query builder.
Transactional Checkout
The checkout path is fully transactional. The service validates the incoming payload, fetches current prices from the foods table, computes the total, inserts the order, then writes each order item. All of that runs inside a single database transaction. If any query fails, the whole thing rolls back and nothing is left half written.
Go's error handling made this straightforward to build correctly. Every call returns an error. Every error gets checked before moving on.
Multirole JWT Authentication
Authentication is JWT based, with separate flows for admin and regular users. Tokens are signed with HMAC SHA256. Middleware extracts the token from the Authorization header, verifies the signature, and injects the user ID into the request context. Admin and user routes each run through their own middleware, so the two roles never share permissions by accident. Passwords are hashed with bcrypt before they ever touch the database.
Order Lifecycle Tracking
Orders move through defined states in real time, so both the admin side and the user side always know exactly where an order stands, from the moment it is placed to the moment it is fulfilled.
Analytics in SQL
Analytics runs entirely in SQL rather than being computed in application code. Revenue, user count, and order count are aggregated using CASE statements across weekly, monthly, yearly, and lifetime buckets. Results scan directly into typed structs, and the API returns clean JSON from there.
Shipping It
The build pipeline is minimal on purpose. A multi stage Dockerfile compiles the binary. Compose brings up the API and Postgres together with one command.
Concurrency, For Free
Go handled concurrency without any extra effort on my part. The net/http server manages a goroutine per request. No worker pools. No async overhead to configure. Just predictable performance out of the box.
Wrapping Up
The result is a backend that processes orders, enforces auth, manages data, and reports metrics, built entirely in Go with no framework and no ORM. If you want to see it in action first, watch the demo on YouTube, and if you want to dig into how any specific part works, the full source is in the repo linked above.
Top comments (0)