This project is a web application for securely sharing self-destructing secret notes. It is built using Go for the backend and Vue for the frontend. The backend provides a RESTful API with Swagger documentation, and the frontend offers a simple, responsive UI. This README overviews the project setup, dependencies, and how to run it using Docker.
- User Authentication: Sign up and sign in functionality.
- Note Creation: Create notes with text content, maximum view limits, and expiration time.
- Note Viewing: Retrieve and view notes securely using unique URLs.
- Note Self-Destruction: Notes self-destruct after the specified number of views or expiration time.
- Security: Secure URL generation for every note.
- Rate Limiting: Implements rate limiting to prevent abuse.
- Go (1.16 or later)
- Node.js (14.x or later) with npm
- Docker and Docker Compose (for containerized setup)
- Clone the repository:
git clone github.com/codescalersinternships/secret-note-api-spa-amr
- Build and run the Docker containers:
docker-compose up --build
This command will build the Docker images and start the containers for the application and necessary services.
- Access the application:
Once the containers are up and running.
- access the web application at http://localhost:8090/
- Access the backend server at http://localhost:8000/
- Navigate to the Sign-Up Page:
- Visit
http://localhost:3000/signup
in your web browser.
- Visit
- Fill in the Sign-Up Form:
- Enter your desired username and password.
- Submit the Form:
- Click the "Sign Up" button to create your account.
- Redirection to Sign-In Page:
- After a successful sign-up, you will be redirected to the sign-in page.
- Navigate to the Sign-In Page:
- Visit
http://localhost:3000/signin
in your web browser.
- Visit
- Fill in the Sign-In Form:
- Enter your username and password.
- Submit the Form:
- Click the "Sign In" button to log into your account.
- Redirection to Note Creation Page:
- After a successful sign-in, you will be redirected to the note creation page.
- Navigate to the Note Creation Page:
- If you are not already there, visit
http://localhost:3000/create
.
- If you are not already there, visit
- Fill in the Note Form:
- Enter your note content, maximum views, and expiration time.
- Submit the Form:
- Click the "Create Note" button to generate a unique URL for your note.
- View the Note URL:
- A unique URL for your note will be displayed. You can share this URL with others.
- Visit the Note URL:
- Open the unique URL generated during note creation in your web browser.
- View the Note:
- The content of the note will be displayed. If the note has expired or reached its view limit, you will see an appropriate message.
Ensure Minikube or another Kubernetes cluster is installed and running.
-
Start Minikube (if not already running):
minikube start
-
Apply Kubernetes Configuration: Deploy the frontend and backend applications to Kubernetes using the provided YAML files.
For the backend:
kubectl apply -f k8s/backend-deployment.yaml kubectl apply -f k8s/backend-service.yaml
For the frontend:
kubectl apply -f k8s/frontend-deployment.yaml kubectl apply -f k8s/frontend-service.yaml
-
Check the Deployment Status: Verify that the pods are running and the services are set up correctly:
kubectl get pods kubectl get services
-
Access the Application:
Frontend:
-
Get the Minikube IP:
minikube ip
-
Access the frontend application at:
http://<Minikube_IP>:<NodePort>
Replace
<Minikube_IP>
with the IP obtained and<NodePort>
with the port from thefrontend-service
(e.g.,31591
).
Backend:
-
Since the backend service is
ClusterIP
, it is only accessible from within the cluster. For local testing, you can use port forwarding:kubectl port-forward service/backend-service 8000:8000
-
Access the backend server at http://localhost:8000/
-
Swagger documentation is available at http://localhost:8000/swagger/index.html when the backend server is running.
Navigate to backend directory and run the tests:
cd backend
go test ./...
-
Install Cypress:
- Ensure you have Cypress installed as a development dependency:
npm install cypress --save-dev
-
Open Cypress Test Runner:
- Run the following command to open the Cypress Test Runner:
npx cypress open
-
Run the Tests:
- In the Cypress Test Runner, click on the test spec file to run the tests. Cypress will launch a browser and execute the tests.
Feel free to open issues or submit pull requests with improvements.