car_park
🚗 Car Park
This is a project written using Amber. Enjoy!
🧠 Consideration
Here I am listing the reason why I am using technology inside this project
-
Amber
- Have built in ORM with Granite
- More Rails like
-
PostgreSQL
- Have native geometry data type that can be used seamlessly with PostGIS
-
Redis
- Work as caching in this project so we don't need to always API to the source
-
PostGIS
- Have function to calculate distance
🚀 Getting Started
These instruction will guide you through how to setup and run this API end point
🛠️ Prerequisites
Things that need to be installed on your local before we start setting up the projects
- Crystal => Crystal Installation Guide
- PostgreSQL => Ubuntu Installation Guide
- Amber => [Amber Dependencies for Ubuntu] => (https://docs.amberframework.org/amber/guides/installation#from-source)
- Amber => [Amber Installation Guide] (https://docs.amberframework.org/amber/guides/installation#from-source)
▶️ Run App
To start your Amber server:
- On project root folder, run this command
chmod +x bin/setup
- Change key
database_url
insideconfig/environments/development.yml
to match your postgres database configuration
e.gdatabase_url: postgres://[postgres_user]:[postgres_password]@[host]:[port]/car_park_development
database_url: postgres://postgres:mypass@localhost:5433/car_park_development
- Rename
env.example
to.env
and fill it according to your postgres setup - Run this command to start setup
bin/setup
- Wait until the setup is finished
- Start Amber server with
amber watch
Now you can visit http://localhost:3000/ from your browser / Postman
🌐 Access the API
You can access the api from this url in your browser / postman
http://localhost:3000/car_parks/nearest?lat=[your_lat_value]&long=[your_long_value]
🧊 Caching Strategy
- When user request data, we check if redis have data inside it
- If Redis have data then return it's data
- If data is missing or cache expired we then fetch from API then store it in cache
🎖️ Credit
Credit to this CGCAI/SVY21 Repo for providing svy21 to wgs84 calculation that I implement in this project
Repository
car_park
Owner
Statistic
- 0
- 0
- 0
- 0
- 9
- 18 days ago
- April 14, 2025
License
Links
Synced at
Fri, 09 May 2025 08:10:53 GMT
Languages