# ArchitectLearning
**Repository Path**: _codefans/architect-learning
## Basic Information
- **Project Name**: ArchitectLearning
- **Description**: 用于软考系统架构师与分析师学习研究使用
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2024-11-06
- **Last Updated**: 2024-11-06
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 为什么学习铁路购票项目
申明:本项目参考互联网开放源码,仅用于个人学习,不得用于商业用途,任何商业用途造成侵权行为,由个人承担后果。
这个项目旨在让学习系统架构师与系统分析师的同学可以快速掌握分布式系统设计的技巧,从软件工程、软件设计的维度讲解项目,让没有项目经验的同学,能够快速深入理解系统架构师与系统分析师的考察内容,尤其适合对高并发、分布式感兴趣的同学学习。
## 项目描述
12306 铁路购票服务是与大家生活和出行相关的关键系统,包括会员、购票、订单、支付和网关等服务。
这个项目旨在让学习系统架构师与系统分析师的同学可以快速掌握分布式系统设计的技巧,尤其适合对高并发、分布式感兴趣的同学学习。如果想深入理解和应用分布式系统的设计原则,这个项目是一个很好的学习资源,本项目学习。
12306 项目中包含了缓存、消息队列、分库分表、设计模式等代码,通过这些代码可以全面了解分布式系统的核心知识点。
为了方便大家学习,该系统提供了两种版本:
- SpringBoot 聚合服务版本:适合测试和部署,可以直接启动 `aggregation-service` 聚合服务和网关服务。
- SpringCloud 微服务版本:适合学习微服务设计,可以分别启动支付、订单、用户、购票和网关服务。
根据自己的学习和使用需求,选择合适的版本启动即可。微服务版本侧重学习设计,聚合服务版本侧重测试和部署。请根据场景需要,选择正确的版本进行学习和使用。

## 技术架构
在系统设计中,采用最新 JDK17 + SpringBoot3&SpringCloud 微服务架构,构建高并发、大数据量下仍然能提供高效可靠的 12306 购票服务。
通过学习 12306 项目,不仅能了解其运作机制,还能接触最新技术体系带来的新特性,从而拓展技术视野并提升自身技术水平。

服务中使用到的后端技术列表如下:
| | 技术 | 名称 | 版本 | 官网 |
| ---- | ------------------- | ------------------ | -------------- | ------------------------------------------------------------ |
| 1 | Spring Boot | 基础框架 | 3.0.7 | [https://spring.io/projects/spring-boot(opens new window)](https://spring.io/projects/spring-boot) |
| 2 | SpringCloud Alibaba | 分布式框架 | 2022.0.0.0-RC2 | [https://github.com/alibaba/spring-cloud-alibaba(opens new window)](https://github.com/alibaba/spring-cloud-alibaba) |
| 3 | SpringCloud Gateway | 网关框架 | 2022.0.3 | [https://spring.io/projects/spring-cloud-gateway(opens new window)](https://spring.io/projects/spring-cloud-gateway) |
| 4 | MyBatis-Plus | 持久层框架 | 3.5.3.1 | [https://baomidou.com(opens new window)](https://baomidou.com/) |
| 5 | Redis | 分布式缓存数据库 | Latest | [https://redis.io(opens new window)](https://redis.io/) |
| 6 | RocketMQ | 消息队列 | 2.2.3 | [https://rocketmq.apache.org(opens new window)](https://rocketmq.apache.org/) |
| 7 | ShardingSphere | 数据库生态系统 | 5.3.2 | [https://shardingsphere.apache.org(opens new window)](https://shardingsphere.apache.org/) |
| 8 | FastJson2 | JSON 序列化工具 | 2.0.36 | [https://github.com/alibaba/fastjson2(opens new window)](https://github.com/alibaba/fastjson2) |
| 9 | Canal | BinLog 订阅组件 | 1.1.6 | [https://github.com/alibaba/canal(opens new window)](https://github.com/alibaba/canal) |
| 10 | HuTool | 小而全的工具集项目 | 5.8.2 | [https://hutool.cn(opens new window)](https://hutool.cn/) |
| 11 | Maven | 项目构建管理 | 3.9.1 | [http://maven.apache.org(opens new window)](http://maven.apache.org/) |
| 12 | Redisson | Redis Java 客户端 | 3.21.3 | [https://redisson.org(opens new window)](https://redisson.org/) |
| 13 | Sentinel | 流控防护框架 | 1.8.6 | [https://github.com/alibaba/Sentinel(opens new window)](https://github.com/alibaba/Sentinel) |
| 14 | Hippo4j | 动态线程池框架 | 1.5.0 | [https://hippo4j.cn(opens new window)](https://hippo4j.cn/) |
| 15 | XXL-Job | 分布式定时任务框架 | 2.4.0 | [http://www.xuxueli.com/xxl-job(opens new window)](http://www.xuxueli.com/xxl-job) |
| 16 | TTL | 增强版 ThreadLocal | 2.14.3 | [https://github.com/alibaba/transmittable-thread-local(opens new window)](https://github.com/alibaba/transmittable-thread-local) |
服务中使用到的前端技术列表如下:
| | 技术 | 名称 | 版本 | 官网 |
| ---- | ---------- | ---------- | ------ | ------------------------------------------------------------ |
| 1 | JS 框架 | Vuejs | 3.2.13 | [https://cn.vuejs.org(opens new window)](https://cn.vuejs.org/) |
| 2 | UI 框架 | Ant Vue | 3.2.20 | [https://antdv.com/components/overview-cn(opens new window)](https://antdv.com/components/overview-cn) |
| 3 | Ajax 请求 | Axios | 1.4.0 | [https://axios-http.com/(opens new window)](https://axios-http.com/) |
| 4 | 前端路由 | Vue-router | 4.0.3 | [https://router.vuejs.org/(opens new window)](https://router.vuejs.org/) |
| 5 | 前端脚手架 | Vue-cli | 5.0.8 | https://cli.vuejs.org/ |
下方的架构图全面描述了项目的服务集合、组件库列表和基础设置层等要素,有助于用户快速了解 12306 平台的顶层设计和业务细节,从零到一进行构建。

## 项目带来什么价值
我理解大家对选择一个合适的项目以投入时间和精力的担忧。选对项目既可以锻炼技能,又可以产出价值是非常重要的。
以用户服务系统为例,低并发和低数据量的系统相对简单,但高并发和海量数据的系统则需要考虑很多额外因素。
1. 判断用户名是否已被注册接口,如何应对海量并发请求带来的缓存穿透问题?
2. 用户敏感数据存储到数据库后,如何避免被黑客将数据库攻破并窃取用户信息?
3. 海量并发查询车票列表接口,如何应对海量请求的查询,以及众多条件如何满足?
4. 海量并发下单接口,如何应对海量用户下单请求,如何进行限流以保证系统不崩溃?以及如何正确落库?
5. 用户下单后如何保障列车座位余票缓存和数据库一致性?非常典型的数据库和缓存一致性问题。
6. 用户下单十分钟未支付,如何取消用户未付款订单?如果用户已支付,如何避免错误取消?
7. 系统中用了消息队列后,如何确保消息不会被重复消费,保证业务系统消费幂等性?
8. 海量用户和订单数据如何存储,通过什么分库分表规则保障系统高性能响应用户查询等请求?
9. 如何通过分库分表基因算法保障分片键的易用性?比如一个订单号字段同时支持订单号和用户 ID 查询。
10. 海量数据分库分表后,为什么选择雪花算法作为 ID?如何保障雪花算法在大规模集群下生成不重复?
## 项目基础业务
在 12306 铁路购票系统中,包括会员、购票、订单、支付以及网关服务。

## 控制台手册
12306 前端系统实现了与官网极为接近的业务逻辑和 UI 展示,这可以极大地方便前后端联调。
在学习过程中,通过类似官网的前端系统直接调试后端服务,可以避免纯通过接口测试的繁琐。这种真实场景的模拟,使得学习过程更加流畅高效。
前端参考 12306 官网开发,基本上保证 80% 以上还原度,用户可体验极致购票下单以及支付流程。
### 车票查询功能
### 订单选择乘车人
### 高铁在线选座
### 订单确认页
