Code snippet repository
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdc_snipster_cli-0.1.0.tar.gz.
File metadata
- Download URL: pdc_snipster_cli-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09a294e6d86d116360e7f3649f1e9fb2e6f6f490d260b6bc79761b507453e4b6
|
|
| MD5 |
7c1629254820af99ccee742bc2897948
|
|
| BLAKE2b-256 |
acf91be04c632e640e3c934e6f642c03c3b17076ab03ea259903657b3425b59e
|
File details
Details for the file pdc_snipster_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pdc_snipster_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71de50909c17f228d1c294026460c39ad7a481c7fc47c74ef78af4f0e929371d
|
|
| MD5 |
39df22c2645f92407879b065a749c96b
|
|
| BLAKE2b-256 |
4b9cb07fed62ea410bb8596b20bb6a493f0a1a356af114b24d875ddb3991f371
|