Skip to content

Commit d7c4ede

Browse files
committed
Scaffold project structure: Rust workspace + Python FastAPI + CI/CD
- Rust workspace with 5 crates (lipi, sandhi, prakriya, kosha, cheda) - Python package structure with FastAPI REST API - FastAPI endpoints: /v1/transliterate, /v1/segment, /v1/analyze, /v1/generate - Pydantic request/response models - uv-based dependency management (pyproject.toml) - GitHub Actions CI/CD (test-rust, test-python, lint, build-check, security) - Basic API tests with pytest - CORS middleware for web demos - Auto-generated OpenAPI docs at /docs
1 parent 23d6b2c commit d7c4ede

15 files changed

Lines changed: 764 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
test-rust:
15+
name: Test Rust Core
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install Rust
22+
uses: dtolnay/rust-toolchain@stable
23+
with:
24+
components: rustfmt, clippy
25+
26+
- name: Cache Cargo
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.cargo/bin/
31+
~/.cargo/registry/index/
32+
~/.cargo/registry/cache/
33+
~/.cargo/git/db/
34+
target/
35+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
36+
37+
- name: Check formatting
38+
run: cargo fmt --all -- --check
39+
working-directory: ./rust
40+
41+
- name: Run clippy
42+
run: cargo clippy --all-targets --all-features -- -D warnings
43+
working-directory: ./rust
44+
45+
- name: Run tests
46+
run: cargo test --all
47+
working-directory: ./rust
48+
49+
- name: Run benchmarks (dry run)
50+
run: cargo bench --no-run
51+
working-directory: ./rust
52+
53+
test-python:
54+
name: Test Python API
55+
runs-on: ubuntu-latest
56+
strategy:
57+
matrix:
58+
python-version: ['3.10', '3.11', '3.12']
59+
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- name: Install uv
64+
uses: astral-sh/setup-uv@v5
65+
with:
66+
enable-cache: true
67+
68+
- name: Set up Python ${{ matrix.python-version }}
69+
run: uv python install ${{ matrix.python-version }}
70+
71+
- name: Install dependencies
72+
run: uv sync --all-extras
73+
74+
- name: Run tests
75+
run: uv run pytest tests/ -v --cov=python/vedyut --cov-report=xml
76+
77+
- name: Upload coverage
78+
uses: codecov/codecov-action@v5
79+
with:
80+
files: ./coverage.xml
81+
flags: python
82+
name: codecov-python-${{ matrix.python-version }}
83+
84+
lint-python:
85+
name: Lint Python
86+
runs-on: ubuntu-latest
87+
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- name: Install uv
92+
uses: astral-sh/setup-uv@v5
93+
94+
- name: Set up Python
95+
run: uv python install 3.12
96+
97+
- name: Install dependencies
98+
run: uv sync
99+
100+
- name: Run ruff (format check)
101+
run: uv run ruff format --check .
102+
103+
- name: Run ruff (lint)
104+
run: uv run ruff check .
105+
106+
build-check:
107+
name: Build Check
108+
runs-on: ${{ matrix.os }}
109+
strategy:
110+
matrix:
111+
os: [ubuntu-latest, macos-latest, windows-latest]
112+
113+
steps:
114+
- uses: actions/checkout@v4
115+
116+
- name: Install Rust
117+
uses: dtolnay/rust-toolchain@stable
118+
119+
- name: Build Rust workspace
120+
run: cargo build --release
121+
working-directory: ./rust
122+
123+
- name: Install uv
124+
uses: astral-sh/setup-uv@v5
125+
126+
- name: Set up Python
127+
run: uv python install 3.12
128+
129+
- name: Check Python package
130+
run: uv sync
131+
132+
security:
133+
name: Security Audit
134+
runs-on: ubuntu-latest
135+
136+
steps:
137+
- uses: actions/checkout@v4
138+
139+
- name: Install Rust
140+
uses: dtolnay/rust-toolchain@stable
141+
142+
- name: Run cargo audit
143+
run: |
144+
cargo install cargo-audit
145+
cargo audit
146+
working-directory: ./rust

pyproject.toml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[project]
2+
name = "vedyut"
3+
version = "0.1.0"
4+
description = "High-performance Sanskrit NLP toolkit - Rust core + Python bindings"
5+
authors = [
6+
{name = "Vedant Madane", email = "vedant@example.com"}
7+
]
8+
readme = "README.md"
9+
license = {file = "LICENSE"}
10+
requires-python = ">=3.10"
11+
keywords = ["sanskrit", "nlp", "linguistics", "panini", "grammar"]
12+
classifiers = [
13+
"Development Status :: 3 - Alpha",
14+
"Intended Audience :: Developers",
15+
"Intended Audience :: Science/Research",
16+
"License :: OSI Approved :: MIT License",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Rust",
21+
"Topic :: Text Processing :: Linguistic",
22+
]
23+
24+
dependencies = [
25+
"fastapi>=0.100.0",
26+
"uvicorn>=0.23.0",
27+
"pydantic>=2.0.0",
28+
]
29+
30+
[project.optional-dependencies]
31+
dev = [
32+
"pytest>=7.4.0",
33+
"pytest-asyncio>=0.21.0",
34+
"pytest-cov>=4.1.0",
35+
"httpx>=0.24.0",
36+
"ruff>=0.1.0",
37+
]
38+
llm = [
39+
"openai>=1.0.0",
40+
"anthropic>=0.5.0",
41+
"langchain>=0.1.0",
42+
]
43+
44+
[project.urls]
45+
Homepage = "https://github.com/VedantMadane/vedyut"
46+
Documentation = "https://vedyut.readthedocs.io"
47+
Repository = "https://github.com/VedantMadane/vedyut"
48+
Issues = "https://github.com/VedantMadane/vedyut/issues"
49+
50+
[build-system]
51+
requires = ["maturin>=1.0,<2.0"]
52+
build-backend = "maturin"
53+
54+
[tool.maturin]
55+
features = ["pyo3/extension-module"]
56+
python-source = "python"
57+
module-name = "vedyut._core"
58+
59+
[tool.pytest.ini_options]
60+
testpaths = ["tests"]
61+
python_files = ["test_*.py"]
62+
python_classes = ["Test*"]
63+
python_functions = ["test_*"]
64+
asyncio_mode = "auto"
65+
66+
[tool.ruff]
67+
line-length = 100
68+
target-version = "py310"
69+
70+
[tool.ruff.lint]
71+
select = ["E", "F", "I", "N", "W", "UP"]
72+
ignore = ["E501"]
73+
74+
[tool.coverage.run]
75+
source = ["python/vedyut"]
76+
omit = ["*/tests/*"]

python/vedyut/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Vedyut - High-performance Sanskrit NLP Toolkit
2+
3+
A next-generation Sanskrit NLP toolkit combining Rust performance
4+
with Python ease-of-use.
5+
"""
6+
7+
__version__ = "0.1.0"
8+
9+
# TODO: Import Rust core when built
10+
# from ._core import *
11+
12+
__all__ = ["__version__"]

python/vedyut/api/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""FastAPI application for Vedyut"""
2+
3+
from .main import app
4+
5+
__all__ = ["app"]

0 commit comments

Comments
 (0)