A Full stack Image Upload Application built with Nextjs and Golang
- Frontend: https://image-app-614g.vercel.app/
- Backend: https://image-app-production.up.railway.app/
- User authentication (signup/login)
- Image upload
- View all uploaded pictures
- Delete Picture
- Language: Golang
- Chi for creating HTTP Handlers
- gqlgen for creating GraphQL server in golang
- JWT for authentication
- AWS S3 for photo storage
- spectaql for generating documentation
- Mongodb driver
- framework: Next.js(app router)
- Redux for state management
- Tanstack Query for asynchronous state management
- Tailwind CSS for styling
- Shadcn UI as UI Kit
- vitest for testing
Prerequisites:
- Node.js
- Go
- MongoDB
- AWS account with S3 bucket
Clone the repository:
git clone https://github.com/[YOUR_ACCOUNT]/image-app.git
- Navigate to the project directory:
cd frontend
- Install the dependencies:
npm install
- Start the server:
npm run dev
- Open your browser and navigate to
http://localhost:3000
- Navigate to the project directory:
cd backend
- Install the dependencies:
go mod tidy
- Copy the
.env.example
file to.env
and update the environment variables as needed:cp .env.example .env
- Start the server:
go run main.go
- Create an S3 bucket in your AWS account
- Ensure your AWS credentials have the necessary permissions
-
In the backend, I'm using Golang with Chi Router to create HTTP handlers and gqlgen for creating schema-based GraphQL APIs.
-
I'm using MongoDB to store data in the database from MongoDB Atlas and using the Go driver to interact with the database. I have not used any ORM because the setup is simpler and faster.
-
I have created a middleware called authMiddleware to access protected routes.
-
For deployment, I have created a Dockerfile and added instructions on how to build and run the app.
-
The Frontend is built with:
- Next.js
- Tailwind CSS
- Redux
- TanStack Query
- Shadcn UI
-
I'm using TanStack Query instead of Apollo Client because it offers a simpler setup and comes with developer tools, which greatly enhances the Developer Experience (DX).
-
For the UI Kit, I've utilized Shadcn UI due to its high customizability and lack of extra dependencies. With Shadcn UI, we only need to install the specific UI components we intend to use.
-
Note on Authentication: JWT tokens are stored in local storage. In a production environment, a more secure approach would be to store tokens in HTTP-only cookies to mitigate XSS risks.