SnippetBox is a secure and efficient web application for managing and sharing code snippets. Built with Go, it offers a clean user interface and a robust backend, making it an ideal tool for developers who need to organize their code snippets effectively. The application features user authentication, session management, and a RESTful API for seamless integration with other tools.
- Secure User Authentication: Sign up, log in, and manage your account securely.
- Snippet Management: Create, view, and delete your code snippets with ease.
- Session Management: Persistent sessions allow you to stay logged in.
- RESTful API: A well-defined API for programmatic access to your snippets.
- Secure by Design: Implemented with security best practices, including HTTPS and password hashing.
The application follows a classic client-server architecture, with a Go backend serving HTML templates and a RESTful API. The database is a MySQL instance, and communication is secured with TLS.
graph TD;
A[Client] -->|HTTPS Request| B(Go Web Server);
B -->|Database Query| C(MySQL Database);
C -->|Query Result| B;
B -->|HTML/JSON Response| A;
- Go (version 1.22 or higher)
- MySQL
-
Clone the repository:
git clone https://github.com/adcondev/snippet-box.git cd snippetbox -
Install dependencies:
go mod tidy
-
Set up the database: Connect to your MySQL instance and run the SQL scripts in the
/sqldirectory to create the necessary tables and user.⚠️ Security Warning:
Before runningsql/create_user.sql, edit the file to change the default username and password to strong, unique values.
Never use the default credentials in production environments.
-
Configure the application: Set the required environment variables, such as the database DSN. You can use the
.env.examplefile as a template. -
Run the server:
go run ./cmd/web -dsn="web:password@/snippetbox?parseTime=true"The server will start on
https://localhost:4000by default.
Contributions are welcome! Please feel free to submit a pull request or open an issue to discuss your ideas.
This project is licensed under the MIT License. See the LICENSE file for more details.
