Skip to content

First release #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: [hamkee-dev-group, hamkee]
ko_fi: edvmfoss
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ ENV/
# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.

2. If the pull request adds functionality, the docs should be updated.
Put your new functionality into a function with a docstring, and add the feature to the list in `README.md`.
Put your new functionality into a function with a docstring.
8 changes: 1 addition & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# Install uv
FROM python:3.13-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv

# Change the working directory to the `app` directory
WORKDIR /app

# Copy the lockfile and `pyproject.toml` into the image
COPY uv.lock /app/uv.lock
COPY pyproject.toml /app/pyproject.toml

# Install dependencies
RUN uv sync --frozen --no-install-project

# Copy the project into the image
COPY . /app

# Sync the project
RUN uv sync --frozen

CMD ["uvicorn", "topsecret.adapters.webapi:api", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uv", "run", "fastapi", "run", "topsecret/adapters/webapi.py"]
619 changes: 619 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ clean-build: ## Clean build artifacts
@echo "🚀 Removing build artifacts"
@uv run python -c "import shutil; import os; shutil.rmtree('dist') if os.path.exists('dist') else None"

.PHONY: docs-test
docs-test: ## Test if documentation can be built without warnings or errors
@uv run mkdocs build -s

.PHONY: docs
docs: ## Build and serve the documentation
docs: ## Make / build / compile/ whatever the documentation
@uv run mkdocs build

.PHONY: see-docs
see-docs: ## Serve the documentation
@uv run mkdocs serve

.PHONY: help
Expand Down
48 changes: 26 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# TopSecret

![TopSecret](static/screenshots/default.png)

TopSecret is an encryption and decryption service with a REST API.

It provides two primary methods of encryption:
Expand All @@ -9,6 +11,11 @@ It provides two primary methods of encryption:

The project includes a FastAPI web service that expose encryption functionality through HTTP endpoints, allowing users to encrypt sensitive information and share decryption URLs.


## Documentation

Project documentation is available at [https://edvm.github.io/secrets-py/](https://edvm.github.io/secrets-py/).

## Sponsorship

A special thanks to [Hamkee](https://hamkee.net/) for sponsoring the project and providing hosting services.
Expand All @@ -21,7 +28,7 @@ If you find this project useful, consider supporting its development:

### Prerequisites

- Python 3.10 or higher and `make` installed.
0- Python 3.10 or higher and `make` installed.

1- Install `uv` (Linux and MacOS)
```bash
Expand All @@ -44,12 +51,12 @@ Clone the repository:

```bash
git clone https://github.com/edvm/secrets-py.git
cd secrets-py
cd secrets-py
```

### Using the Makefile

The project includes a Makefile trying to make your life easier. You can use it to automate common tasks.
The project includes a Makefile trying to make your life easier. You can use it to automate common tasks.

Be sure to have `make` and `uv` installed.

Expand Down Expand Up @@ -80,11 +87,14 @@ make run

The API will be available at http://localhost:8000.

## Testing the API

### Using the API Documentation
### Running with Docker Compose
If you prefer to run the API using Docker Compose, you can use the provided `compose.yml` file.
1. Build and run the Docker container:

Visit http://localhost:8000/docs for an interactive Swagger UI to test the API endpoints.
```bash
docker compose up --build
```
2. Access the API at http://localhost:8000.

### Using curl

Expand All @@ -104,25 +114,19 @@ curl -X POST http://localhost:8000/encrypt \
#### Testing the decrypt endpoint
```sh
# Example 3: Decrypt a secret (replace HASH_VALUE with the actual hash from the encrypt response)
curl -X GET http://localhost:8000/decrypt/HASH_VALUE
curl -X POST http://localhost:8000/decrypt/HASH_VALUE

# Example 4: Decrypt a passphrase-protected secret
curl -X GET "http://localhost:8000/decrypt/HASH_VALUE?passphrase=mysecretpassword123"
curl -X POST http://localhost:8000/decrypt/HASH_VALUE \
-H "Content-Type: application/json" \
-d '{"passphrase": "mysecretpassword123"}'
```

#### Example workflow
### Skins / Themes

```sh
# Step 1: Encrypt a secret and capture the hash
RESPONSE=$(curl -s -X POST http://localhost:8000/encrypt \
-H "Content-Type: application/json" \
-d '{"secret": "My super secret info"}'
)
You can create your own skins by modifying the HTML and CSS files in the `static/themes` directory. Use `default.html` as base template and create your own theme by copying it to a new file, e.g., `mytheme.html`. Then, you can specify the theme by query parameter in the URL, e.g., `http://localhost:8000/encrypt?theme=mytheme` or override `default.html` with your
custom skin.

# Step 2: Extract the hash from the response (requires jq)
HASH=$(echo $RESPONSE | jq -r '.hash')
echo "Hash: $HASH"
Here are some screenshots of built-in themes:

# Step 3: Decrypt using the hash
curl -X GET http://localhost:8000/decrypt/$HASH
```
![Sakura](static/screenshots/sakura.png)
12 changes: 12 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"
volumes:
- .:/app
restart: unless-stopped
environment:
- PYTHONUNBUFFERED=1
3 changes: 3 additions & 0 deletions docs-md/adapters/webapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
WebAPI Adapter is a component that expose the functionality of the TopSecret application through a web API. It allows external systems to interact with the application using standard HTTP methods.

::: topsecret.adapters.webapi
3 changes: 3 additions & 0 deletions docs-md/domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Domain layer is the core of the application. It contains interfaces and business logic. It is independent of any framework or technology. It should not depend on any other layer. It should only depend on the entities and value objects.

::: topsecret.domain
39 changes: 39 additions & 0 deletions docs-md/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# topsecret

`top secret` is an encryption and decryption service with a REST API.

It provides two primary methods of encryption:

1. **Auto encryption**: Generates keys automatically and stores them securely
2. **Passphrase encryption**: Uses a user-provided passphrase for more secure encryption

The project includes a FastAPI web service that expose encryption functionality through HTTP endpoints, allowing users to encrypt sensitive information and share decryption URLs.

## Sponsorship

A special thanks to [Hamkee](https://hamkee.net/) for sponsoring the project and providing hosting services.

If you find this project useful, consider supporting its development:
[![Ko-fi](https://img.shields.io/badge/Ko--fi-Donate-blue?style=social)](https://ko-fi.com/edvmfoss)


## Run API on three simple steps

### Prerequisites

- Python 3.10 or higher and `make` installed.

1- Install `uv` (Linux and MacOS)
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

2- Run `make install` to install dependencies.
```bash
make install
```

3- Run `make run` to start the API server.
```bash
make run
```
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions docs-md/infra/cipher/aes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AES is a symmetric encryption algorithm that is widely used for securing data. It operates on fixed-size blocks of data and uses a secret key for both encryption and decryption. AES is known for its speed and security, making it a popular choice for various applications.

::: topsecret.infra.cipher.aes
Empty file.
3 changes: 3 additions & 0 deletions docs-md/infra/storage/inmem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
In-Memory Storage is a simple key-value store that keeps data in memory. It is useful for testing and development purposes, but not suitable for production use due to its volatility.

::: topsecret.infra.storage.inmem
6 changes: 6 additions & 0 deletions docs-md/services/encryption.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Encryption Service provides encryption and decryption functionality for sensitive data.

::: topsecret.services.encryption
options:
members:
- EncryptionService
Loading