A simple REST API built with Go (Gin) and PostgreSQL to manage mobile app pages and widgets.
Acts as a configuration backend that lets apps render UI dynamically.
- Go (Gin) - lightweight, high-performance HTTP server
- PostgreSQL - reliable relational database
- UUID - globally unique identifiers for entities
- JSONB - flexible storage for dynamic widget configuration
- Raw SQL - clear, explicit queries with minimal abstraction
- Create page
- List all pages
- Get single page (with widgets)
- Update page
- Delete page (home page protected)
- Add widget to a page
- Update widget
- Delete widget
- Reorder widgets on a page
- Page name required
- Route must be unique
- Only one home page allowed
- Home page cannot be deleted
- Widget types allowed:
- banner
- product_grid
- text
- Widget config stored as JSONB
- Consistent error response format
This service stores:
- Pages (app screens)
- Widgets (UI components)
- Widget layout order
Mobile apps fetch this configuration and render UI dynamically.
Below is a high-level view of how pages, widgets, and layout configuration flow through the system.
The original Excalidraw file is included for reference and can be edited if needed:
You can open it by:
- Visiting https://excalidraw.com
- Clicking "Open"
- Uploading the
.excalidraw
app-config-api/
├── design/
├── images/
├── postman/
├── main.go
├── db.go
├── models.go
├── handlers.go
├── routes.go
├── middleware.go
├── schema.sql
└── README.md
git clone https://github.com/manasa-bhagwat/app-config-api.git
cd app-config-api
Using CLI:
createdb configapp
psql -d configapp -f schema.sql
Or using pgAdmin:
- Create DB:
configapp - Open Query tool.
- Run
schema.sql
In db.go:
postgres://username:password@localhost:5432/configapp?sslmode=disable
go run .
Server runs at:
http://localhost:8080
- POST
/pages - GET
/pages - GET
/pages/:id - PUT
/pages/:id - DELETE
/pages/:id
- POST
/pages/:id/widgets - PUT
/widgets/:id - DELETE
/widgets/:id - POST
/pages/:id/widgets/reorder
Base URL
http://localhost:8080
POST /pages
{
"name": "Home",
"route": "/home",
"is_home": true
}Save: HOME_PAGE_ID
POST /pages
{
"name": "Products",
"route": "/products",
"is_home": false
}Save: PRODUCTS_PAGE_ID
POST /pages/HOME_PAGE_ID/widgets
Banner:
{
"type": "banner",
"position": 1,
"config": {
"image_url": "https://store.com/sale.jpg",
"title": "Mega Sale",
"cta": "Shop Now"
}
}Product Grid:
{
"type": "product_grid",
"position": 2,
"config": {
"collection": "featured",
"columns": 2
}
}Text:
{
"type": "text",
"position": 3,
"config": {
"content": "Welcome to our store!"
}
}GET /pages/HOME_PAGE_ID
Returns:
- Page details
- All widgets
- Ordered by position
POST /pages/HOME_PAGE_ID/widgets/reorder
{
"widget_ids": [
"TEXT_WIDGET_ID",
"BANNER_WIDGET_ID",
"GRID_WIDGET_ID"
]
}PUT /widgets/WIDGET_ID
{
"type": "banner",
"position": 1,
"config": {
"title": "BIGGEST SALE"
}
}DELETE /widgets/WIDGET_ID
A ready-to-use Postman collection export is included in the repository for quick testing of all API endpoints.
File location:
postman/app-config-api.postman_collection.json
To use it:
- Open Postman
- Click Import
- Select the JSON file from the
postman/folder - Set the base URL if needed:
http://localhost:8080
This collection contains pre-configured requests for:
- Pages (Create, List, Get, Update, Delete)
- Widgets (Add, Update, Delete)
- Reorder widgets
Each request logs:
- Method
- Path
- Status
- Response time
Example:
POST /pages | 201 | 2ms
GET /pages | 200 | 1ms

