Push Tracker
ria-ran--sim-drop/plan/00-project-structure.md
A ashkan@beigi.net 8672b0de6b Add Phase-1 eSIM provisioning implementation
Full working closed-loop eSIM provisioning stack (spec in claude.md / plan/):
Flask API, SQLite subscriber store, credential/profile generator, Open5GS
and free5gc core adapters, captive portal, operational scripts, systemd
units, network configs, and a 44-test suite.

Profile generation currently returns a mock JSON profile; real SGP.22
generation via pySim is the planned Phase-2 upgrade.

Fixes two bugs found while getting the suite green:
- generate_imsi hardcoded a 10-digit MSIN, producing 16-digit IMSIs for a
  3-digit MNC; MSIN length is now 15 - len(mcc) - len(mnc).
- check_rate_limit compared timestamps as strings across mismatched formats
  (SQLite CURRENT_TIMESTAMP vs Python isoformat); both sides now normalized
  via SQLite datetime() so the window check is chronologically correct.

Add .gitignore for venv, caches, runtime config.yaml, and databases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 05:56:31 +00:00

86 lines
2.1 KiB
Markdown

# Unit 00 — Project Structure
## Goal
Scaffold all directories, `__init__` files, `requirements.txt`, and `config.yaml.example`. No logic yet — just the skeleton.
## Files to Create
### `requirements.txt`
```
Flask==3.0.0
cryptography==41.0.7
pymongo==4.6.0
requests==2.31.0
pyyaml==6.0.1
pytest==7.4.0
```
> Note: `pySim` is deferred to Unit 06 (real eSIM profile generation) due to install complexity. Unit 02 uses a mock profile.
### `config.yaml.example`
```yaml
network:
mcc: "302"
mnc: "720"
plmn: "302720"
op_key: "63bfa50ee6523365ff14c1f45f88737d" # 16-byte hex OP key
wifi:
ssid: "Emergency-5G"
channel: 6
ip: "192.168.4.1"
subnet: "192.168.4.0/24"
dhcp_range: "192.168.4.10,192.168.4.250"
server:
host: "0.0.0.0"
port: 5000
debug: false
database:
path: "/opt/esim-provisioning/data/subscribers.db"
rate_limiting:
max_profiles_per_mac: 1
window_hours: 1
core:
type: "open5gs" # "open5gs" | "free5gc" | "none"
mongodb_uri: "mongodb://localhost:27017"
database_name: "open5gs"
profile:
carrier_name: "Ad-Hoc Network"
profile_name: "Emergency 5G"
apn: "internet"
```
### Directory Structure
```
esim-provisioning/
├── requirements.txt
├── config.yaml.example
├── server/
│ ├── __init__.py (empty)
│ └── core_adapters/
│ └── __init__.py (empty — factory added in Unit 04)
├── portal/
│ ├── css/ (populated in Unit 06)
│ ├── js/ (populated in Unit 06)
│ └── assets/ (empty)
├── scripts/ (populated in Unit 07)
├── tests/
│ └── __init__.py (empty)
├── android/ (populated in Unit 09)
├── systemd/ (populated in Unit 08)
├── configs/ (populated in Unit 08)
└── plan/ (these files — already done)
```
## Verification
```bash
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
# Should complete with no errors
python -c "import flask, cryptography, pymongo, yaml; print('OK')"
```