Go Markdown Note-Taking App
A simple note-taking API built with Go that allows users to upload markdown files, check grammar, save notes, and render them as HTML.
Based on Markdown Note-Taking App Project from roadmap.sh.
Features
- ✅ Upload and save markdown notes
- ✅ Grammar checking for notes
- ✅ List all saved notes
- ✅ Render markdown notes as HTML
- ✅ RESTful API design
- ✅ Docker support for easy deployment
- ✅ Comprehensive API documentation (OpenAPI/Swagger)
Project Structure
go-markdown-note-taking-app/
├── cmd/
│ └── server/
│ └── main.go # Application entry point
├── internal/
│ ├── api/
│ │ ├── handlers/ # HTTP handlers
│ │ ├── middleware/ # Middleware functions (CORS, logging)
│ │ └── routes/ # Route definitions
│ ├── config/ # Configuration management
│ ├── models/ # Data models
│ ├── services/ # Business logic
│ │ ├── grammar/ # Grammar checking service
│ │ ├── markdown/ # Markdown processing service
│ │ └── storage/ # Note storage service
│ └── utils/ # Utility functions
│ ├── errors/ # Error handling utilities
│ ├── file/ # File handling utilities
│ └── testutils/ # Testing utilities
├── api/
│ └── openapi.yaml # OpenAPI specification
├── docs/ # Documentation
├── examples/ # Example markdown files
├── scripts/ # Build and deployment scripts
├── docker/ # Docker-related files
├── notes/ # Directory for stored notes
├── go.mod
├── go.sum
├── Dockerfile
├── docker-compose.yml
└── README.md
Prerequisites
- Go 1.21 or higher
- Docker and Docker Compose (optional, for containerized deployment)
- Git
Installation
- Clone the repository:
git clone https://github.com/JumpingMonkey/go-markdown-note-taking-app.git
cd go-markdown-note-taking-app
- Install dependencies:
go mod download
- Create the notes directory:
mkdir -p notes
Running the Application
Local Development
go run cmd/server/main.go
The server will start on http://localhost:8080 by default.
Using Docker
docker-compose up --build
API Endpoints
1. Save a Note
2. Check Grammar
3. List All Notes
- GET
/api/v1/notes
- Response: Array of saved notes
4. Get a Specific Note
- GET
/api/v1/notes/{id}
- Response: Note details in markdown format
5. Get HTML Rendered Note
- GET
/api/v1/notes/{id}/html
- Response: Note rendered as HTML
6. Upload Markdown File
- POST
/api/v1/notes/upload
- Request: Multipart form with markdown file
- Response: Created note with ID
API Documentation
The API documentation is available in OpenAPI format:
- View the OpenAPI specification:
/api/v1/docs/openapi.yaml
- Interactive Swagger UI:
/api/v1/docs (when running the server)
Configuration
The application can be configured using environment variables:
PORT: Server port (default: 8080)
NOTES_DIR: Directory to store notes (default: ./notes)
LOG_LEVEL: Logging level (default: info)
Development
Running Tests
# Local tests (if Go is installed)
go test ./...
# Docker-based tests (no Go installation required)
./scripts/run-tests.sh
Building the Application
go build -o bin/server cmd/server/main.go
Code Style
This project follows the standard Go formatting guidelines. Use go fmt to format your code:
go fmt ./...
Docker Support
Building the Docker Image
docker build -t go-markdown-note-app .
Running with Docker Compose
docker-compose up -d
Common Docker Issues
If you encounter build errors related to Go modules during the Docker build process, try the following solutions:
- Ensure your
go.mod and go.sum files are properly initialized
- Use the provided Docker configuration which includes all necessary build dependencies
- For detailed logs, check the Docker build output with the
-v flag enabled
This will start the application along with any required services.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -am 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments