The goal of this project is to make social application like twitter with distributed and reliable backend system
-
Angular CLI
npm install -g @angular/cli
cd cmd/frontend
npm install
Configure backend url in cmd/frontend/src/environment
ng serve
The frontend will listen on port 4200 by default.
./runServers.bat
The backend server will listen on port 9090 by default. The port can be changed in the config.toml file. Please note that if you want to use the config.toml file, you need to start services from the root folder (Mini-Twitter/). This is because the services look in the current working directory for the config file. Otherwise they will use default values.
-
Download the latest etcd binaries
-
Install goreman
go get github.com/mattn/goreman
-
In the etcd directory, use goreman to start the etcd cluster. Goreman will read the Procfile.
Note:- To run on windows operating system, you need to remove the single quotes (' ') around the cluster definition.goreman start
Project structure is based on package oriented design
Mini-Twitter
│ config.toml # config file for all services
│ runServers.bat # batch file to start services
│
├───cmd
│ ├───authd
│ │ main.go # start authd server
│ │
│ ├───frontend\ # start frontend
│ ├───postd
│ │ main.go # start postd
│ │
│ ├───userd
│ │ main.go # start userd
│ │
│ └───webd
│ │ main.go # start backend web server
│ │
│ └───handlers\ # backend web server handlers
│ │
│ ├───middleware\ # middleware
│ │
│ └───models\ # request/response models
│
├───internal # Application logic
│ ├───auth # Authentication service
│ │ │ auth_etcd_test.go
│ │ │ auth_test.go
│ │ │ models.go # Repo Interface definition
│ │ │
│ │ ├───authentication # Protobuf files
│ │ │ auth.pb.go
│ │ │ auth.proto
│ │ │
│ │ ├───service
│ │ │ auth_service.go # Service Implementation
│ │ │
│ │ └───storage # Repo Implementations
│ │ ├───etcd
│ │ │ client.go
│ │ │ repository.go
│ │ │ testrepository.go
│ │ │
│ │ └───memstorage
│ │ memory.go
│ │ repository.go
│ │ testrepository.go
│ │
│ ├───config # Config parsing
│ │ config.go
│ │
│ ├───post # Post service
│ │ │ models.go # Repo Interface
│ │ │ post_etcd_test.go
│ │ │ post_test.go
│ │ │ service.go # Service Implementation
│ │ │
│ │ ├───postpb
│ │ │ post.pb.go
│ │ │ post.proto
│ │ │
│ │ └───storage # Repo Implementations
│ │ ├───etcd
│ │ │ client.go
│ │ │ repository.go
│ │ │
│ │ └───memstorage
│ │ repository.go
│ │ storage.go
│ │ testrepository.go
│ │
│ └───user # User service
│ │ models.go # Repo Interface
│ │ service.go # Service Implementation
│ │ user_etcd_test.go
│ │ user_test.go
│ │
│ ├───storage # Repo Implementations
│ │ │ testrepository.go
│ │ │
│ │ ├───etcd
│ │ │ client.go
│ │ │ repository.go
│ │ │
│ │ └───memstorage
│ │ repository.go
│ │ storage.go
│ │
│ └───userpb # Protobuf files
│ user.pb.go
│ user.proto
│
└───vendor