Welcome to the Food Delivery App Backend! This project is a robust backend built with Ktor and designed to power a food delivery ecosystem comprising three main applications:
- Customer App: For users to explore restaurants, view menu items, place orders, and track deliveries.
- Rider App: For delivery personnel to manage and update order statuses and share live locations.
- Restaurant App: For restaurant owners to manage their listings, update order statuses, and oversee operations.
This backend is scalable, modular, and optimized for real-world deployment scenarios.
The backend follows a clean and modular structure:
configs/
- Contains configuration files.
database/
- Includes database models and table definitions.
models/
- Houses data classes used for JSON serialization and business logic.
routes/
- Defines routes for handling API endpoints for various features.
services/
- Contains the core business logic and operations.
utils/
- Provides utility functions like error handling and helper methods.
Application.kt
- The entry point for the Ktor application.
- Email and Password Login: Secure authentication using hashed passwords.
- OAuth Support: Google and Facebook login integration.
- JWT-based Authentication: Stateless and secure token-based authorization.
- Add and manage categories for restaurant menus (e.g., Fast Food, Desserts, Beverages).
- Preloaded with commonly used categories.
- Add restaurants with the following details:
- Name
- Address
- Geolocation (latitude, longitude)
- Associated category
- Fetch restaurants based on proximity to the user (within a 5km radius).
- Manage menu items for restaurants:
- Name
- Description
- Price
- Optional AR metadata for immersive product viewing.
- Handle order placements:
- Customer details
- Restaurant details
- List of menu items
- Manage order statuses:
- Pending → Preparing → Ready → Picked Up → Delivered.
- Rider Location Sharing: Real-time tracking using websockets for live updates.
- Customer View: Track delivery progress on a map.
- Customers can leave ratings and reviews for orders.
- Ktor: Fast and lightweight Kotlin framework for backend development.
- Exposed: ORM library for database operations.
- Kotlin: For clean, concise, and expressive code.
- MySQL: Reliable and scalable relational database.
- Spatial Data Support: Geolocation-based queries for restaurants.
- JWT: For secure and stateless session management.
- OAuth: Google and Facebook login support.
- Kotlin 1.8+
- MySQL
- Gradle
- Clone the repository:
git clone https://github.com/your-username/food-delivery-backend.git cd food-delivery-backend
- Start the Ktor server::
./gradlew run
- The server will be running at http://localhost:8080.
Method | Endpoint | Description |
---|---|---|
POST | /auth/register |
Register a new user |
POST | /auth/login |
Login with email and password |
POST | /auth/oauth |
Login with Google or Facebook |
Method | Endpoint | Description |
---|---|---|
GET | /categories |
Fetch all categories |
POST | /categories |
Add a new category (Admin) |
Method | Endpoint | Description |
---|---|---|
GET | /restaurants |
Fetch all restaurants near a location |
GET | /restaurants/{id} |
Fetch details of a specific restaurant |
POST | /restaurants |
Add a new restaurant (Owner/Admin) |
Method | Endpoint | Description |
---|---|---|
POST | /orders |
Place a new order |
GET | /orders/{id} |
Fetch details of a specific order |
PATCH | /orders/{id}/status |
Update the status of an order |