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. π
# π 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
python3 -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
pip install -r requirements.txt
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
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
Follow the prompts to enter an admin username, email, and password.
python manage.py runserver
The API will be available at: http://127.0.0.1:8000/
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"
}
Railway.app is the easiest way to deploy.
- Create a new project on Railway.app
- Connect your GitHub repository
- Add PostgreSQL as a plugin
- Set environment variables in the Railway dashboard
- Deploy π
Render provides free hosting.
- Create a Render Web Service
- Connect GitHub repository
- Add PostgreSQL Database
- Add environment variables
- Deploy π
For manual deployment, install NGINX + Gunicorn:
sudo apt update && sudo apt install python3-pip python3-venv gunicorn nginx
Then configure Gunicorn & Nginx for production.
- Backend: Django Rest Framework (DRF)
- Database: PostgreSQL
- Authentication: Clerk (external), JWT (optional)
- Deployment: Railway, Render, VPS (NGINX + Gunicorn)
- Frontend: Next.js (Connects via API)
- Add WebSocket support for real-time updates
- Implement Celery for background tasks
- Improve error handling & validation
- Add Admin Dashboard for managing users
This project is licensed under the MIT License.
Developed for the Ardhi WebGIS project.