My submission for Inter IIT Dev
git clone https://github.com/saksham-kumar-14/Repliq
cd ./Repliq
./backend/.env according to ./backend/.env.example provideddocker-compose up --build
http://localhosthttp://localhost:8000git clone https://github.com/saksham-kumar-14/repliq
cd ./backend
go mod tidy
go run ./cmd/api/*.go
In another terminal,
cd ./frontend
bun install
bun run dev
http://localhost:5173http://localhost:8000GET /v1/health : basic check for server healthGET /v1/user/:id : get specific user informationPOST /v1/user: user registrationPOST /v1/user/login: user loginGET /v1/api/token: JWT verification
** The following routes use JWT middleware for user verification.
headers:{Authorization: "Bearer <jwt-token>"}GET /v1/post: get all postsPOST /v1/post: create postGET /v1/post/:id: get specific postPATCH /v1/post/:id: update specific postDELETE /v1/post/:id: delete specific post/:├── backend/
├── cmd/
├── api/
├── api.go # for api and server config
├── main.go # main file to run
├── errors.go # api resp errors are defined
├── json.go # for writing json responses and reading json requests
├── middleware.go # for JWT auth
├── user.go # user api functions
├── comment.go # posts api functions
└── health.go # api function for basic health check
├── internal/
├── auth/ # JWT auth
├── db/ # initialize db
├── rateLimiter/ # rate limiting
└── store/ # db store for user and comments
└── Dockerfile
├── frontend/
│ ├── src/
│ │ ├── lib/ # Svelte components
│ │ ├── store/ # API service functions
│ │ ├── utils/ # util functions
│ │ └── App.svelte
├── nginx
| ├── Dockerfile # This first builds svelte frontend, then host it with nginx on PORT 80
| ├── nginx.conf # configuration for nginx
├── docker-compose.yml
└── README.md
type User struct {
ID uint `json:"id" gorm:"primaryKey"`
Username string `json:"username" gorm:"uniqueIndex"`
Avatar string `json:"avatar"`
Email string `json:"email" gorm:"uniqueIndex"`
Password []byte `json:"-"`
CreatedAt time.Time `json:"created_at"`
}
type Comment struct {
ID uint `json:"id" gorm:"primaryKey"`
ParentId int `json:"parent_id"`
Text string `json:"text"`
Upvotes int `json:"upvotes"`
UserId uint `json:"user_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}