How pinterest/snappass works
Major Components
• Client / User Interface:
• Web browser (or API client) interacting with the application.
• Uses a standard web UI (HTML templates, JavaScript, Bootstrap, and FontAwesome assets from snappass/templates and snappass/static).
• Flask Web Application:
• Located in the snappass folder with key files (__init__.py, main.py).
• Responsible for rendering templates, routing, and handling both Simple and REST APIs as described in the README.
• API Endpoints:
• Two API categories as described: the simple API (e.g., /api/set_password) and the REST API (e.g., /api/v2/passwords).
• These endpoints encapsulate the server’s logic to create, validate, and retrieve secure passwords.
• Encryption Layer:
• Uses the cryptography library’s Fernet encryption. This isn’t shown as a separate file, but it is an integral part of how the password is secured before storing.
• Redis Store:
• Acts as the temporary, in-memory data store for passwords.
• The README highlights that Redis is used to save encrypted and ephemeral password data. Environment settings (e.g., REDIS_HOST, REDIS_PORT) point to Redis configuration.
• External/Deployment Components:
• Docker and Docker Compose configuration for containerized deployment (Dockerfile, docker-compose.yml).
• Continuous Integration aspects (GitHub workflows, Makefile) – these are separate from runtime architecture but worth noting in the overall system for build and deployment pipelines.
Establish Relationships and Interactions
• The Client sends HTTP requests (GET, POST, HEAD) to the Flask application.
• Flask routes requests to the appropriate view functions based on the URL—this includes either rendering an HTML page (password preview or set_password screens) or processing an API request.
• When a password is created:
• The application encrypts the password on the fly using Fernet.
• It then stores metadata in Redis (keyed with a unique token) without saving the encryption key (passed with the link).
• For password retrieval:
• Validations are made (check if the password exists, is not expired or already read).
• The encrypted password is sent if the correct token is provided.
• Docker/Docker Compose is used to spin up both the Flask application and the Redis store, with configuration provided in the docker-compose.yml file.
Final Checklist
• Every component is clearly labeled and easy to understand.
• Annotations to represent the major configuration options and any notes on security (e.g., using Fernet) as per the README.