Skip to content

Rahul108/note-keeper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note Keeper Application

A full-stack web application for managing notes, built with Golang backend, NextJS frontend, MongoDB database, and containerized with Docker.

Architecture

  • 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

Project Structure

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

Prerequisites

  • Docker and Docker Compose
  • Git
  • For infrastructure management:
    • Terraform
    • Ansible

Getting Started

  1. Clone the repository:

    git clone <repository-url>
    cd note-keeper
    
  2. Start the application using Docker Compose:

    docker compose up -d
    
  3. The application will be available at:

Docker Development

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
    

Technical Implementation Details

Backend (Golang)

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

Key Technical Solutions

For the backend Docker container, we implemented:

  1. Multi-stage build to reduce image size:

    • Build stage with full Golang image for compilation
    • Runtime stage with Alpine base for smaller footprint
  2. Static binary compilation with CGO disabled:

    • Ensures the binary runs correctly in Alpine container
    • Eliminates dependency on shared libraries
  3. CA certificates added to the Alpine image:

    • Ensures HTTPS connections work properly
    • Required for secure external API calls

Frontend (NextJS)

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

API Endpoints

The backend API provides the following endpoints:

  • GET /api/notes - Get all notes
  • GET /api/notes/:id - Get a note by ID
  • POST /api/notes - Create a new note
  • PUT /api/notes/:id - Update a note
  • DELETE /api/notes/:id - Delete a note

Deployment

Development Environment

./scripts/deploy.sh dev

Production Environment

./scripts/deploy.sh prod

Using Terraform for Infrastructure Management

  1. Navigate to the terraform directory:

    cd terraform
    
  2. Initialize Terraform:

    terraform init
    
  3. Apply the configuration:

    terraform apply
    

Using Ansible for Deployment

  1. Navigate to the ansible directory:

    cd ansible
    
  2. Run the deployment playbook:

    ansible-playbook -i inventory.ini deploy.yml
    

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors