Giter Club home page Giter Club logo

mall-project's Introduction

商场项目

一个前后端分离的商场项目,包含完整购物,下单流程

演示地址

账号: test
密码: test

商品首页 购物车 商品搜索

特性

  • 使用Makefile管理编译流程
  • 支持HTTPS(Let's Encrypt的证书,需要域名)
  • Nginx 反向代理后端应用,支持HTTP2
  • 前后端容器化,使用docker-compose将Mysql,Redis,前后端应用整合起来,支持一键启动

项目介绍

采用前后端分离的架构,前端用Vue实现,后端用Gin (Go 的一个Web框架)提供RestfulAPI

项目结构

.
├── CHANGELOG.md
├── LICENSE
├── Makefile                                  # Make 配置
├── README.md
├── docker-compose.yml                        # docker-compose配置文件
├── docs                                      # 项目文档
├── nginx                                     # nginx 配置
├── scripts                                   # letsencrypt 初始化脚本
├── server                                    # 后端代码
└── webapp                                    # 前端代码

后端介绍

后端项目结构:

.
├── Dockerfile                          # Docker文件
├── README.md
├── cmd
│   └── main.go                         # 项目入口
├── conf                                # 配置文件
│   ├── config.deploy.yml               
│   └── config.local.yml                
├── go.mod
├── go.sum
├── internal
│   ├── api                             # api层,路由注册和路由函数实现
│   ├── dto                             # dto层,request和response的数据对象
│   ├── mapper                          # mapper层,model层到dto层的数据转换
│   ├── model                           # model层,对应mysql表结构
│   ├── repository                      # repository层,表的增删查改
│   └── service                         # 业务逻辑层
├── pkg
│   ├── app                             # 负责工程初始化,初始化repository层,service层,API层
│   ├── conf                            # 配置模块
│   ├── database                        
│   ├── errno                           # 业务逻辑错误码
│   ├── handler                         # 接口响应的封装
│   ├── log                             # 日志模块,支持
│   ├── token                           # jwt token
│   └── util                            # 工具函数
├── scripts
│   └── wait_for.sh                     # 一个shell脚本,docker-compose时等待mysql初始化
└── test                                
    ├── mall_data.sql                   
    └── mall_test.sql                   # 数据表结构


后端采用三层架构模型(Repository,Service,API),通过依赖注入的方式实现控制反转,使用wire 管理对象的初始化

实现了

  • Graceful Shutdown
  • Jwt登录认证, 基于 jwt-go
  • 配置热加载,基于 viper
  • 日志结构化,日志切分,基于zap

怎么用?

环境依赖:

  • make
  • docker
  • docker-compose

安装完依赖,把项目拉下来

cd mall-project && make serve

已经编写好了Makefile,make serve 即可启动项目,不出意外的话访问 http://localhost 就是商场首页了

有问题可以 make log可查看日志

感谢

前端是基于 newbee-mall-vue3-app 修改

后端日志模块,配置模块参考了 snake

License

MIT

mall-project's People

Contributors

wljgithub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.