Skip to content

amirgamil/carly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Carly ✉️

Genereate beautiful letters for your loved ones that can be shared in seconds

Carly was written to help me send a birthday letter to my mum halfway around the world. Now anyone can do it too!

letter1 letter2 letter3 letter4

Details

Carly is written in Next.js + React on the frontend (hosted on Vercel) and Go with MongoDB Atlas on the backend (hosted as a systemd file with nginx on Digital Ocean).

To run this locally, you will need to run the web server in Go (using go run main.go) as well as the frontend (navigate inside the frontend directory and run yarn dev).

You will also need a MongoDB atlas account (free tier M0 can be accessed by anyone). Once you've made an account, configure a user with admin access and store the username, password, and shared URL in a .env file with MONGO_USER, MONGO_PASS, MONGO_SHARD_URL as the variable names respectively. Make sure that this .env file is located in the same directory as the go.mod file.

You will also need to create a .env.local file inside the frontend folder and populate it with two variables NEXT_PUBLIC_HOST=localhost:3000 NEXT_PUBLIC_HOSTAPI=127.0.0.1:port/api You can select any port like 8998.

API

The API provides two endpoints

POST /api

  • Accepts a JSON body that looks like this: { "title": "titleLetter", "expiry": "getExpiryDate()", "password": "", "content": [ { "person": "person1", "msg": "msg1", "imgAdd": "imgAdd1" }, { "person":"person2", "msg": "msg2", "imgAdd": "imgAdd2" }... ] }

The API returns the genereated hash if successful #200 OK #{ "hash": "166989a"}

GET /api/{hash}

The API returns #401 Unauthorized if the letter is password protected

OR

#404 Bad request if it does not find the hash in the database (or for any other possible error)

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Acknowledgements