A full-stack web application for managing notes, built with Golang backend, NextJS frontend, MongoDB database, and containerized with Docker.
- Backend: Golang API with CRUD operations for notes
- Frontend: NextJS application for a responsive UI
- Database: MongoDB for data storage
- Web Server: Nginx for reverse proxy and static file serving
- Infrastructure: Terraform for infrastructure as code
- Deployment: Ansible for automated deployment
note-keeper/
├── ansible/ # Ansible playbooks for deployment
├── backend/ # Golang API server
├── frontend/ # NextJS frontend application
├── mongodb/ # MongoDB-related files
├── nginx/ # Nginx configuration
├── scripts/ # Utility scripts
├── terraform/ # Terraform configuration files
└── docker-compose.yml # Docker Compose configuration
- Docker and Docker Compose
- Git
- For infrastructure management:
- Terraform
- Ansible
-
Clone the repository:
git clone <repository-url> cd note-keeper -
Start the application using Docker Compose:
docker compose up -d -
The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080/api/notes
- Nginx: http://localhost:80
The application uses Docker Compose for containerization and orchestration:
-
To build the containers:
docker compose build -
To start all services:
docker compose up -d -
To view logs from containers:
docker compose logs -f [service_name] -
To stop all services:
docker compose down
The backend is built with Golang and provides a RESTful API for note management with the following features:
- Framework: Gin web framework for routing and middleware
- Database: MongoDB for data storage with the official Go driver
- CORS: Support for Cross-Origin Resource Sharing
- Docker: Multi-stage build for efficient container size
- API Design: RESTful endpoints for CRUD operations
For the backend Docker container, we implemented:
-
Multi-stage build to reduce image size:
- Build stage with full Golang image for compilation
- Runtime stage with Alpine base for smaller footprint
-
Static binary compilation with CGO disabled:
- Ensures the binary runs correctly in Alpine container
- Eliminates dependency on shared libraries
-
CA certificates added to the Alpine image:
- Ensures HTTPS connections work properly
- Required for secure external API calls
The frontend is built with NextJS and provides a modern, responsive UI for the note-keeping application:
- Framework: Next.js for server-side rendering and routing
- UI: Modern responsive design with CSS modules
- API Integration: Custom service for communicating with the backend
The backend API provides the following endpoints:
GET /api/notes- Get all notesGET /api/notes/:id- Get a note by IDPOST /api/notes- Create a new notePUT /api/notes/:id- Update a noteDELETE /api/notes/:id- Delete a note
./scripts/deploy.sh dev./scripts/deploy.sh prod-
Navigate to the terraform directory:
cd terraform -
Initialize Terraform:
terraform init -
Apply the configuration:
terraform apply
-
Navigate to the ansible directory:
cd ansible -
Run the deployment playbook:
ansible-playbook -i inventory.ini deploy.yml
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.