# README
Snippetbox - A Golang Web Application
Welcome to Snippetbox, a web application for storing and managing snippets of text. This project is built as part of my journey to learn web development in Go (Golang), based on the book Let's Go! by Alex Edwards.
š Project Overview
Snippetbox is a simple yet powerful web application that allows users to:
- Create snippets of text.
- View snippets by their unique ID.
- Browse a list of the latest snippets.
This project is a learning exercise designed to implement the best practices in Go web development, including working with templates, routing, forms, authentication, and more.
š Features
- Fast and Efficient: Built using Go, a statically-typed, compiled language optimized for performance.
- Clean Architecture: Implements the layered design principles from Let's Go!
- HTML Templates: Dynamically render web pages using Go's
html/template
package. - Secure: Includes best practices for input validation and protection against common vulnerabilities like XSS.
- MySQL Integration: Uses MySQL as the database to store snippet information.
š What I Learned
While building this project, I focused on:
- Structuring a Go web application for maintainability and scalability.
- Using Go's built-in libraries for routing and templating.
- Handling forms and managing user input securely.
- Working with a database (MySQL) in Go.
- Adding session-based authentication.
š§ Getting Started
Prerequisites
- Go (1.20 or higher recommended)
- MySQL
- Docker
- Docker Compose
Installation
-
Clone the repository:
git clone https://github.com/Turtel216/snippetbox.git cd snippetbox
-
Install dependencies:
go mod tidy
-
Set up Docker:
docker-compose up --build
-
Open your browser and visit: http://localhost:4000
š Project Structure
snippetbox/
āāā cmd/
ā āāā web/ # Entry point for the application
āāā internal/
ā āāā models/ # Database models and queries
ā āāā handlers/ # HTTP handlers for routing
ā āāā validation/ # Form validation helpers
ā āāā ā¦
āāā init-scripts/ # Database schema and migrations
āāā go.mod # Dependencies file
āāā Dockerfile # Snippetbox docker container
āāā docker-compose.yml # Data base and web app config
āāā README.md # Project documentation
š¤ Contributing
Contributions are welcome! Feel free to submit issues or pull requests to improve this project.
š License
This project is for educational purposes and is not intended for production use.
š Acknowledgments
- Special thanks to Alex Edwards for writing Let's Go!, which served as the primary resource for this project.