How gobblergang/server works
Project Type & Purpose
• This is a monolithic, full-stack backend application written in Python (likely Flask or similar), exposing a RESTful API for secure file sharing.
• Its responsibilities include user authentication, file encryption/decryption, access control, certificate generation (PAC), and persistence in a MySQL/MariaDB database plus the file system.
File Structure
• Top-level files:
– run.py (entry point launching the HTTPS server)
– generate_sql.py (build-time script that emits server_db_schema.sql)
– server_db_schema.sql (DB schema import artifact)
– requirements.txt (Python dependencies)
– uploads/ (encrypted file store)
• app/ directory:
– __init__.py (app factory or Flask initialization)
– auth.py (nonce-based challenge/response, login/logout, registration)
– files.py (upload, download, share, revoke, delete flows)
– models.py (ORM mappings for users, files, PACs, nonces, etc.)
README for Additional Insights
• Security features: end-to-end encryption, digital signatures, PAC system, nonce cleanup job.
• SSL in dev vs. production is fronted by Nginx or reverse proxy.
• Core API endpoints for auth and file operations.
Main Components & Their Relationships
a. Clients
• Web/browser or any HTTPS-capable client
• Requests JSON payloads to /api/...
b. API Server (Flask app in run.py/app/)
• Modules:
– Authentication (app/auth.py)
– File Service (app/files.py)
– Data Models & ORM (app/models.py)
– Background job (nonce cleanup)
• Encryption/Decryption Library (integrated within file service)
c. Database (MySQL/MariaDB)
• Stores user records, file metadata, PAC certificates, nonces
d. File Storage (local uploads/ folder, encrypted blobs)
e. Certificate Authority Logic (PAC generation & validation inside the app)
f. (Optional Production Nginx Reverse Proxy)
• SSL offload, rate limiting, security headers
Architectural Patterns & Design Principles
• Monolithic REST API (container)
• MVC-style separation:
• Models (ORM layer)
• Controllers (auth.py, files.py)
• E2E Encryption ensures that file payloads are encrypted before persistence
• Nonce-based challenge/response for replay protection
• PAC system as an internal certificate authority micro-subsystem
• Background scheduler or cron-like job for nonce cleanup