Skip to content

Latest commit

 

History

History
326 lines (219 loc) · 4.53 KB

File metadata and controls

326 lines (219 loc) · 4.53 KB

Address Sync System

MIT License Python Version FastAPI Docker SQLAlchemy

Address Sync System


📋 Overview

The Address Sync System is a microservice that simplifies updating address information across multiple agencies using Aadhaar as a unique identifier.

Users can request updates → agencies approve/reject → system syncs changes.


✨ Features

🏠 Requester (Citizen)

  • Register/Login via Aadhaar
  • View agencies
  • Submit address update requests
  • Track request status
  • Cancel pending requests

🏢 Agency

  • Register/Login
  • View pending requests
  • Approve/Reject requests
  • Access request history

📊 Admin

  • Status tracking (Pending / Approved / Rejected / Cancelled)
  • Filtering
  • Stats dashboard
  • Audit logs

🏗️ Tech Stack

Backend

  • FastAPI
  • SQLAlchemy
  • SQLite / PostgreSQL
  • JWT Auth
  • Python 3.10+

Frontend

  • HTML, CSS, Vanilla JS

DevOps

  • Docker
  • Docker Compose
  • Git

⚙️ System Flow

Citizen → Request → Agency
   ↓           ↑
Status ← Approval
   ↓
Address Updated

📦 Prerequisites

  • Python 3.10+
  • Docker & Docker Compose
  • Git
  • curl

🚀 Installation

1. Clone

git clone https://github.com/yourusername/address-sync-system.git
cd address-sync-system

2. Backend Setup

Option A: Docker

cd backend
docker-compose up -d --build
docker-compose logs -f
docker-compose down

Option B: Local

cd backend
python -m venv venv
source venv/bin/activate   # Linux/Mac
venv\Scripts\activate      # Windows

pip install -r requirements.txt

mkdir data static

Create .env:

DATABASE_URL=sqlite:///./data/address_sync.db
SECRET_KEY=your-secret-key
DEBUG=True
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:8000

Run:

uvicorn main:app --reload

🌐 Access

Service URL
App http://localhost:8000
Docs http://localhost:8000/docs
ReDoc http://localhost:8000/redoc

💻 Usage

Demo Users

Aadhaar Name Password
123456789012 Rajesh Kumar Rajesh@1234

Demo Agencies

ID Name
municipal_bangalore Bangalore MC

🔌 API Example

# Health
curl http://localhost:8000/health

# Register
curl -X POST http://localhost:8000/users/register \
-H "Content-Type: application/json" \
-d '{"aadhaar_number":"123456789012","password":"Test@123"}'

📡 API Endpoints

User

  • POST /users/register
  • POST /users/login
  • GET /users/me

Agency

  • POST /agencies/register
  • POST /agencies/login

Requests

  • POST /requests/create
  • GET /requests/my-requests
  • PUT /requests/{id}

📊 Data Models

User

{
  "aadhaar_number": "string",
  "name": "string",
  "email": "string",
  "current_address": "string"
}

Request

{
  "id": "uuid",
  "status": "pending | approved | rejected"
}

⚙️ Environment Variables

DATABASE_URL=sqlite:///./data/address_sync.db
SECRET_KEY=secret
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=1440

🐳 Docker

services:
  backend:
    build: ./backend
    ports:
      - "8000:8000"

🧪 Testing

python test_full_api.py

🚢 Deployment

Railway

railway up

Render

  • Build: pip install -r requirements.txt
  • Start: uvicorn main:app --host 0.0.0.0 --port $PORT

🔧 Troubleshooting

Port Issue

lsof -i :8000
kill -9 PID

Docker Issue

sudo systemctl start docker

🤝 Contributing

git checkout -b feature/new-feature
git commit -m "Add feature"
git push origin feature/new-feature

📄 License

MIT License


🙌 Credits

  • FastAPI
  • SQLAlchemy
  • Docker

📞 Contact

  • GitHub Issues
  • Docs
  • Community

Made with ❤️