# Sample Web Application Using Beego and Mgo

DevFeed: [Sample Web Application Using Beego and Mgo](<https://devfeed.tech/articles/sample-web-application-using-beego-and-mgo-22089.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2013/12/sample-web-application-using-beego-and.html>)

Published: 2013-12-11T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Web Development](<https://devfeed.tech/topics/web-development.md>), [MongoDB](<https://devfeed.tech/topics/mongodb.md>), [Code](<https://devfeed.tech/topics/code.md>), [Go Language](<https://devfeed.tech/topics/go-language.md>), [JSON](<https://devfeed.tech/topics/json.md>)

Tags: [ardan-labs](<https://devfeed.tech/tags/ardan-labs.md>), [blog](<https://devfeed.tech/tags/blog.md>), [code](<https://devfeed.tech/tags/code.md>), [database](<https://devfeed.tech/tags/database.md>), [framework](<https://devfeed.tech/tags/framework.md>), [go](<https://devfeed.tech/tags/go.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [golang](<https://devfeed.tech/tags/golang.md>), [json](<https://devfeed.tech/tags/json.md>), [programming](<https://devfeed.tech/tags/programming.md>), [test](<https://devfeed.tech/tags/test.md>), [web](<https://devfeed.tech/tags/web.md>)

## AI overview

A tutorial showing how to build a sample web application with the Beego framework and Mgo. The application uses MongoDB, renders grid and modal views, exposes a JSON web service, reads configuration from the environment, includes tests, and uses logging.

## Source excerpt

Introduction I am very excited about the Beego web framework. I wanted to share with you how I use the framework to build real world web sites and web services. Here is a picture of the sample website the post is going to showcase: View linked image: Screen Shot The sample web application: Implements a traditional grid view of data calling into MongoDB Provides a modal dialog box to view details using a partial view to generate the HTML Implements a web service that returns a JSON document Takes configuration parameters from the environment using envconfig Implements tests via goconvey Leverages my logging package The code for the sample can be found in the GoingGo repository up on Github: External resource on github.com: https://github.com/goinggo/beego-mgo You can bring the code down and run it. It uses a public MongoDB database I created at MongoLab. You will need git and bazaar installed on your system before running go get. go get github.com/goinggo/beego-mgo To quickly run or test the web application, use the scripts located in the zscripts folder. Web Application Code Structure Let's take a look at the project structure and the different folders that exist: controllers Entry point for each Web call. Controllers process the requests. localize Provides localization support for different languages and cultures models Models are data structures used by the business and service layers routes Mappings between URL's and the controller code that handles those calls. services Services provide primitive functions for the different services that exist. These could be database or web calls that perform a specific function. static Resource files such as scripts, stylesheets and images test Tests that can be run through the go test tool. utilities Code that supports the web application. Boilerplate and abstraction layers for accessing the database and handling panics. views Code related to rendering views zscripts Support scripts to help make it easier to build, run and te