Snipster
A code snippet management application built with FastAPI backend and Reflex frontend.
Development Setup
Prerequisites
- Python 3.8+
- uv package manager
Quick Start (Recommended)
For the fastest setup, use the provided Makefile commands:
# Install dependencies and start backend server
make dev
# In another terminal, start the frontend
make ui
This will automatically:
- Install all dependencies
- Initialize the database
- Start the FastAPI backend at http://localhost:8000
- Start the Reflex frontend at http://localhost:3000
Manual Setup
If you prefer to run commands manually, follow the steps below.
Backend (FastAPI)
The FastAPI backend provides the REST API for managing code snippets.
-
Navigate to the project root:
cd snipster
-
Install dependencies:
uv sync -
Initialize the database (REQUIRED):
uv run alembic upgrade head
Important: This step is required before starting the server. It creates the database tables and schema.
-
Start the FastAPI development server:
uv run fastapi dev src/snipster/api.py
The API will be available at
http://localhost:8000 -
Optional: Run tests:
uv run pytest
Frontend (Reflex)
The Reflex frontend provides a modern web interface for managing snippets.
-
Navigate to the frontend directory:
cd ui
-
Install dependencies:
uv sync -
Start the Reflex development server:
uv run reflex run
The frontend will be available at
http://localhost:3000 -
Optional: Build for production:
uv run reflex export
Database Management
Alembic Migrations
Alembic handles database schema migrations for the project.
-
Create a new migration:
uv run alembic revision --autogenerate -m "Description of changes"
-
Apply pending migrations:
uv run alembic upgrade head
-
Rollback to previous migration:
uv run alembic downgrade -1 ``****`
-
View migration history:
uv run alembic history
-
Check current migration status:
uv run alembic current
Note: Always review auto-generated migrations before applying them to production.
Project Structure
Backend (src/snipster/)
api.py: FastAPI application with REST endpointsmodels.py: Pydantic models for request/response validationrepo.py: Data access layer for snippetsdb.py: Database connection and session managementcli.py: Command-line interface for snippet management
Frontend (ui/)
ui/ui.py: Main Reflex application with UI componentsrxconfig.py: Reflex configuration (ports, app name)pyproject.toml: Frontend dependencies and configuration
Database
alembic/: Database schema migrationssnipster.sqlite: SQLite database file
Development Tools
pyproject.toml: Project configuration and dependenciesMakefile: Common development commands.pre-commit-config.yaml: Code quality hookstests/: Comprehensive test suite
API Endpoints
-
GET /health- Health checkGET /health Response: {"status": "ok"} -
POST /create- Create new snippetPOST /create { "title": "Hello World", "code": "print('Hello World')", "language": "python", "tags": ["example", "hello"] }
-
GET /snippets- List all snippetsGET /snippets Response: [ { "id": 1, "title": "Hello World", "code": "print('Hello World')", "language": "python", "tags": ["example", "hello"] } ] -
GET /snippets/{id}- Get snippet by IDGET /snippets/1 Response: { "id": 1, "title": "Hello World", "code": "print('Hello World')", "language": "python", "tags": ["example", "hello"] } -
DELETE /snippets/{id}- Delete snippetDELETE /snippets/1 Response: {"message": "Snippet deleted"} -
POST /snippets/{id}/toggle-favorite- Toggle favorite statusPOST /snippets/1/toggle-favorite Response: {"id": 1, "is_favorite": true} -
POST /snippets/{id}/add-tags- Add tags to snippetPOST /snippets/1/add-tags { "tags": ["new", "tags"] } Response: { "id": 1, "tags": ["example", "hello", "new", "tags"] }
-
GET /search- Search snippets by query stringGET /search?q=hello Response: [ { "id": 1, "title": "Hello World", "code": "print('Hello World')", "language": "python", "tags": ["example", "hello"] } ]
Development Workflow
- Start the FastAPI backend first
- Start the Reflex frontend
- Make changes to either backend or frontend
- Both servers support hot reloading for development
Metadata
Release files for pdc-snipster-cli 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pdc_snipster_cli-0.1.0.tar.gz | 7.9 kB | Without provenance | Details for pdc_snipster_cli-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pdc_snipster_cli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pdc_snipster_cli-0.1.0-py3-none-any.whl |
Total release size: 17.6 kB
Release files / pdc_snipster_cli-0.1.0.tar.gz
| Download URL | pdc_snipster_cli-0.1.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09a294e6d86d116360e7f3649f1e9fb2e6f6f490d260b6bc79761b507453e4b6
|
|
BLAKE2b-256 checksum How to use checksums |
acf91be04c632e640e3c934e6f642c03c3b17076ab03ea259903657b3425b59e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / pdc_snipster_cli-0.1.0-py3-none-any.whl
| Download URL | pdc_snipster_cli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71de50909c17f228d1c294026460c39ad7a481c7fc47c74ef78af4f0e929371d
|
|
BLAKE2b-256 checksum How to use checksums |
4b9cb07fed62ea410bb8596b20bb6a493f0a1a356af114b24d875ddb3991f371
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Security for pdc-snipster-cli 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.