Skip to content

Ardhi-OWM/ardhi-webgis-backend

Repository files navigation

Here's a README.md file for your Django + REST API + PostgreSQL backend project (ardhi_backend). It includes setup instructions, environment variables, database setup, API documentation, and deployment steps. πŸš€


πŸ“œ README.md - Ardhi Backend

# 🌍 Ardhi Backend

Ardhi Backend is a Django-based REST API that powers the **Ardhi WebGIS** application. It provides endpoints for user data, API inputs, subscriptions, and visualization. The backend uses **Django Rest Framework (DRF)** with **PostgreSQL** as the database.

## πŸš€ Features

- 🌐 **Django Rest Framework (DRF)** for building REST APIs
- πŸ—„οΈ **PostgreSQL** as the database
- πŸ”‘ **JWT Authentication** for security
- πŸ“‘ **Clerk Authentication** integration
- πŸ“¬ **Subscription system** for users
- πŸ“Š **Supports API, Model, and Dataset inputs**
- ☁️ **Easily deployable on Render, Railway, or VPS**

---

## πŸ“¦ Installation & Setup

### 1️⃣ **Clone the Repository**
```bash
git clone https://github.com/yourusername/ardhi_backend.git
cd ardhi_backend

2️⃣ Set up a Virtual Environment

python3 -m venv venv
source venv/bin/activate   # On Windows use: venv\Scripts\activate

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Set Up Environment Variables (IGNORE)

Create a .env file inside the project folder:

touch .env

Add the following environment variables to .env:

DEBUG=True
DATABASE_URL=postgres://user:password@localhost:5432/ardhi_db
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000

5️⃣ Set Up the Database

python manage.py makemigrations
python manage.py migrate

6️⃣ Create a Superuser (Optional)

python manage.py createsuperuser

Follow the prompts to enter an admin username, email, and password.

7️⃣ Run the Development Server

python manage.py runserver

The API will be available at: http://127.0.0.1:8000/


πŸ”Œ API Endpoints

Endpoint Method Description
/api/inputs/ POST Add a new API, Model, or Dataset input
/api/inputs/ GET Get all inputs
/api/inputs/<id>/ GET Retrieve a single input
/api/inputs/<id>/ PUT Update an input
/api/inputs/<id>/ DELETE Delete an input
/api/subscriptions/ POST Subscribe a user
/api/subscriptions/ GET List all subscribers
/api/token/ POST Obtain JWT Token (if using authentication)
/api/token/refresh/ POST Refresh JWT Token

Example POST Request to /api/inputs/:

{
  "user_id": "user_abc123",
  "input_type": "API",
  "data_link": "https://example.com/api"
}

🌍 Deployment Guide

1️⃣ Deploying on Railway

Railway.app is the easiest way to deploy.

  1. Create a new project on Railway.app
  2. Connect your GitHub repository
  3. Add PostgreSQL as a plugin
  4. Set environment variables in the Railway dashboard
  5. Deploy πŸš€

2️⃣ Deploying on Render

Render provides free hosting.

  1. Create a Render Web Service
  2. Connect GitHub repository
  3. Add PostgreSQL Database
  4. Add environment variables
  5. Deploy πŸš€

3️⃣ Deploying on VPS (Hostinger, DigitalOcean)

For manual deployment, install NGINX + Gunicorn:

sudo apt update && sudo apt install python3-pip python3-venv gunicorn nginx

Then configure Gunicorn & Nginx for production.


πŸ”₯ Tech Stack

  • Backend: Django Rest Framework (DRF)
  • Database: PostgreSQL
  • Authentication: Clerk (external), JWT (optional)
  • Deployment: Railway, Render, VPS (NGINX + Gunicorn)
  • Frontend: Next.js (Connects via API)

πŸ’‘ Future Improvements

  • Add WebSocket support for real-time updates
  • Implement Celery for background tasks
  • Improve error handling & validation
  • Add Admin Dashboard for managing users

πŸ“œ License

This project is licensed under the MIT License.


πŸ™Œ Credits

Developed for the Ardhi WebGIS project.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •