Full-Stack Integration Tutorial
This tutorial uses the "Article Management" module as an example to connect the backend and frontend end to end, covering permission configuration, menu configuration, API integration, and the complete workflow in between.
1. Preparation
1.1 Environment Check
Make sure the following environment is ready:
- Go 1.18+
- Node.js 16+
- pnpm
- Docker Compose (used to start the dependency services)
- PostgreSQL / MySQL
- Redis
1.2 Start the Backend Dependencies
cd backend
./scripts/docker/libs_only.sh
This starts PostgreSQL, Redis, MinIO, and other dependency services.
2. Backend Development (Completed)
Assume the backend "Article Management" module has already been developed (see Backend Tutorial: Adding a New Business Module), including:
- ✅ Protobuf definitions
- ✅ Ent schema
- ✅ Data layer implementation
- ✅ Service layer implementation
- ✅ Server registration
- ✅ Wire dependency injection
- ✅ OpenAPI documentation generation
Verify the backend APIs:
cd backend
gow run admin
Visit http://localhost:7788/docs/ and confirm that the ArticleService APIs have appeared in the Swagger UI.
3. Frontend Development (Completed)
Assume the frontend page development has been completed (see Frontend Tutorial: Adding a New Business Page), including:
- ✅ API service layer
- ✅ Composable layer
- ✅ Page components
- ✅ Route registration
4. Permission and Menu Configuration
This is the key step of full-stack integration: menus and permissions need to be configured in the admin management system.
4.1 Log In to the Admin Console
Log in to the admin management system with the default account admin / admin.
4.2 Create Menus
Go to Permission Management → Menu Management and click "New Menu".
Create a Top-Level Directory
| Field | Value |
|---|---|
| Menu name | Article Management |
| Parent menu | None (top level) |
| Menu type | Directory |
| Route path | /app/article |
| Component path | Leave empty |
| Icon | mdi:file-document-outline |
| Order | 100 |
| Visible | Yes |
| Cached | No |
Click "Submit" to save.
Create a Second-Level Menu (List Page)
Click "New Menu" again:
| Field | Value |
|---|---|
| Menu name | Article List |
| Parent menu | Article Management |
| Menu type | Menu |
| Route path | index |
| Component path | /app/article/index |
| Icon | Leave empty |
| Order | 1 |
| Visible | Yes |
| Cached | Yes |
| Permission code | article:list |
Click "Submit" to save.
Create Button Permissions (Optional)
If button-level permission control is needed, continue creating:
New button:
| Field | Value |
|---|---|
| Menu name | Create Article |
| Parent menu | Article List |
| Menu type | Button |
| Permission code | article:create |
Edit button:
| Field | Value |
|---|---|
| Menu name | Edit Article |
| Parent menu | Article List |
| Menu type | Button |
| Permission code | article:update |
Delete button:
| Field | Value |
|---|---|
| Menu name | Delete Article |
| Parent menu | Article List |
| Menu type | Button |
| Permission code | article:delete |
4.3 Assign Permissions to a Role
Go to Permission Management → Role Management and select the role to authorize (e.g. "Super Administrator").
- Click "Set Permissions"
- Check "Article Management" and its sub-menus in the permission tree
- Click "OK" to save
4.4 Verify the Menu Display
Log out and log in again, then check the left menu — the "Article Management" menu item should be visible.
5. API Integration Testing
5.1 Check the Environment Variables
Confirm that the API address in the frontend .env.development is configured correctly:
VITE_GLOB_API_URL=http://localhost:7788
5.2 Start the Frontend
cd frontend/admin/vue-vben
pnpm dev:antd
Visit http://localhost:5666.
5.3 Functional Testing
Test the List Query
- Go to "Article Management → Article List"
- Open the browser developer tools (F12)
- Switch to the Network tab
- Refresh the page and observe whether a request is sent to
/admin/v1/article - Check whether the response data is correct
If you see a 401 error, the token is missing or expired; try logging in again.
If you see a 403 error, the permissions are insufficient; check whether the role has been assigned the corresponding permissions.
Test Creating an Article
- Click the "Create" button
- Fill in the form
- Click "Submit"
- Watch the Network tab and confirm that the POST request is sent to
/admin/v1/article - Check whether the response status code is 200
Test Editing an Article
- Click the "Edit" button of a record
- Modify the form content
- Click "Submit"
- Watch the Network tab and confirm that the PUT request is sent to
/admin/v1/article/{id}
Test Deleting an Article
- Click the "Delete" button of a record
- Confirm the deletion
- Watch the Network tab and confirm that the DELETE request is sent to
/admin/v1/article/{id}
6. Troubleshooting Common Issues
6.1 The Menu Does Not Show
Possible causes:
- The menu is not configured correctly
- The user role has not been assigned the permissions
- The browser cache has not been cleared
Solutions:
- Check whether the
menustable in the backend database has the corresponding record - Check whether the
role_menusassociation table is correct - Clear the browser cache (Ctrl + Shift + Delete)
- Log out and log in again
6.2 API Requests Return 401
Possible causes:
- The token is not attached
- The token has expired
- The token format is wrong
Solutions:
- Check whether the request headers contain
Authorization: Bearer <token> - Log in again to get a new token
- Check whether the Axios interceptors are configured correctly in the frontend code
6.3 API Requests Return 403
Possible causes:
- The user does not have the corresponding permission
- The permission code is misconfigured
- The authorization engine is not initialized correctly
Solutions:
- Check whether the user role has been assigned the corresponding menu permissions
- Check whether the menu's "Permission code" field matches the backend
- Temporarily change
authz.typetonoopinauth.yamlfor testing
6.4 API Requests Return 404
Possible causes:
- The API path is wrong
- The backend service is not running
- The handler is not registered
Solutions:
- Check whether the frontend request paths match the Protobuf definitions
- Confirm the backend service is running
- Check whether the corresponding handler is registered in
rest_server.go
6.5 TypeScript Type Errors
Possible causes:
- The latest TypeScript code has not been generated
- IDE cache issues
Solutions:
- Run
make tson the backend to regenerate the code - Restart the frontend development server
- Restart the IDE (VSCode / WebStorm)
7. Debugging Tips
7.1 Backend Logs
The backend outputs logs to the console by default. You can get more debugging information by adjusting the log level in logger.yaml:
logger:
type: std
zap:
level: "debug" # Change to debug to see more details
7.2 Frontend Debugging
In the browser developer tools:
- Console tab: view JavaScript errors and console.log output
- Network tab: view HTTP requests and responses
- Vue Devtools: install the Vue Devtools extension to inspect component state and events
7.3 Swagger UI Testing
During development, prefer the Swagger UI to test the backend APIs:
- Visit http://localhost:7788/docs/
- Find ArticleService
- Click "Authorize" and enter the token
- Test the APIs one by one
This way you can first make sure the backend APIs work, then debug the frontend.
8. Performance Optimization Suggestions
8.1 Backend Optimization
Database indexes: add indexes for frequently queried fields
CREATE INDEX idx_articles_title ON articles(title); CREATE INDEX idx_articles_status ON articles(status);Paginated queries: avoid loading large amounts of data at once; always use pagination
Cache hot data: use Redis caching for frequently read data
8.2 Frontend Optimization
- Lazy-load routes: Vben Admin enables route lazy loading by default
- Import components on demand: avoid importing unused Ant Design Vue components
- Image compression: compress images before uploading
9. Deployment Notes
9.1 Backend Deployment
When deploying to production:
- Change the database address and password in
data.yaml - Change the JWT secret in
auth.yaml - Disable the Swagger UI (
enable_swagger: false) - Enable HTTPS
9.2 Frontend Deployment
- Change the API address in
.env.productionto the production address - Run
pnpm run build:antdto build the production bundle - Deploy the
dist/directory to Nginx or another web server
9.3 CORS Configuration
If the frontend and backend are deployed under different domains, configure CORS in the backend server.yaml:
server:
rest:
cors:
origins:
- "https://your-frontend-domain.com"
10. Summary
In this tutorial, we completed the full full-stack integration workflow:
- Backend development: Protobuf → Ent → Data → Service → Server
- Frontend development: API → Composable → Page → Route
- Permission configuration: menu management → role authorization
- Integration testing: functional verification → troubleshooting
Once you master this workflow, you can quickly develop any new business module and ensure seamless frontend-backend integration.
