AhmedShahan commited on
Commit
753fd19
Β·
1 Parent(s): e3ecb83

Add README.md with project overview, setup instructions, API endpoints, and deployment details

Browse files
Files changed (1) hide show
  1. README.md +78 -0
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # JobSathi Backend
2
+
3
+ A lightweight FastAPI authentication API for register/login with phone number and password (Argon2-hashed), backed by Supabase Postgres.
4
+
5
+ ## Features
6
+
7
+ - `POST /register` β€” register with phone number + password
8
+ - `POST /login` β€” verify password against stored Argon2 hash
9
+ - `GET /` β€” health check
10
+ - Passwords stored as **Argon2 hashes** (via `argon2-cffi`), never plaintext
11
+ - Duplicate phone number detection on registration
12
+ - Supabase Postgres via psycopg2
13
+ - CI/CD to HuggingFace Space with secret sync via GitHub Actions
14
+
15
+ ## Project Structure
16
+
17
+ ```
18
+ job_sathi_backend/
19
+ β”œβ”€β”€ api.py # FastAPI app and routes
20
+ β”œβ”€β”€ request_model.py # Pydantic models (LoginRequest, RegisterRequest)
21
+ β”œβ”€β”€ queries.py # SQL statement constants
22
+ β”œβ”€β”€ utils.py # DB connection + Argon2 hash/verify
23
+ β”œβ”€β”€ sync_secrets.py # Syncs .env keys to HF Space secrets
24
+ β”œβ”€β”€ requirements.txt
25
+ β”œβ”€β”€ .env # Local DB config (gitignored)
26
+ β”œβ”€β”€ .env.gpg # GPG-encrypted .env (committed)
27
+ └── .github/workflows/
28
+ β”œβ”€β”€ deploy-to-hf.yml # Deploys to HF Space on push to main
29
+ └── sync-secrets.yml # Decrypts .env.gpg and syncs secrets
30
+ ```
31
+
32
+ ## Setup & Run
33
+
34
+ ```bash
35
+ git clone https://github.com/AhmedShahan/job_sathi_backend.git
36
+ cd job_sathi_backend
37
+ python -m venv .venv
38
+ source .venv/bin/activate
39
+ pip install -r requirements.txt
40
+ ```
41
+
42
+ Create `.env` with:
43
+ ```
44
+ DB_HOST=...
45
+ DB_PORT=...
46
+ DB_NAME=...
47
+ DB_USER=...
48
+ DB_PASSWORD=...
49
+ ```
50
+
51
+ Run:
52
+ ```bash
53
+ uvicorn api:app --host 0.0.0.0 --port 8000 --reload
54
+ # or
55
+ python api.py
56
+ ```
57
+
58
+ Interactive docs at `http://localhost:8000/docs`.
59
+
60
+ ## API Endpoints
61
+
62
+ | Method | Path | Body | Response |
63
+ |--------|------------|----------------------------------------|----------|
64
+ | GET | `/` | β€” | `{"response": "Login Auth API is running"}` |
65
+ | POST | `/register`| `{"phoneNumber": "...", "password": "..."}` | `{"response": "Registered successfully"}` / `"Phone Number already registered"` / `"Server error: ..."` |
66
+ | POST | `/login` | `{"phoneNumber": "...", "password": "..."}` | `{"response": "Authorized"}` / `"Phone Number or Password is Incorrect"` / `"Server error: ..."` |
67
+
68
+ ## Database
69
+
70
+ Expects a `login` table with:
71
+ - `phone_number` (text, unique)
72
+ - `password` (text) β€” stores **Argon2 hash**
73
+
74
+ ## Deployment & CI
75
+
76
+ - Push to `main` β†’ deploys to HF Space `AhmedShahan/JobSathi_Backend`.
77
+ - When `.env.gpg` changes β†’ decrypts with GPG (`GPG_PASSPHRASE` secret) and syncs keys as Space secrets via `sync_secrets.py` (requires `HF_TOKEN`).
78
+ - **Never commit a plaintext `.env`; keep it encrypted as `.env.gpg`.**