This website is a personal project built for the CVWO Winter Assignment 2024.
The tech stack used is largely based on the specifications of the assignment, with a few personal choices made to enhance features and simplify the build process.
The frontend of the website is built using:
- React with Vite
- TypeScript
- Tailwind CSS
I opted for TailwindCSS instead of component libraries like Material UI to ensure the app remains lightweight, customizable, and consistent, while speeding up the development cycle.
The backend of the website is built using:
- Go (Golang)
- Gin Framework ( gin-gonic.com )
- PostgreSQL
I chose PostgreSQL for its popularity, comprehensive documentation, and generous free hosting options. The backend interacts with the database using the GORM library, which simplifies the codebase.
- The frontend and backend communicate using a RESTful API.
- High-frequency operations (such as fetching posts) are written to prioritize simplicity and interface versatility.
- Less frequently used operations are modularized for easier maintenance.
- The codebase is optimized to be lightweight for hosting on free services by:
- Preventing unnecessary operations.
- Implementing frontend controls to avoid invalid operations and excess backend requests.
Considering this project will be hosted on free services with limited compute power, it is designed to be as lightweight as possible
The app started with features outlined in the assignment requirements and has since been expanded to include additional functionality.
- Post Creation: Make posts with a rich text editor (utilizing the tiptap library).
- Replies: Reply to posts and reply to replies (similar to Reddit).
- Upvoting & Downvoting: Vote on posts and comments.
- Post Management: Edit and delete posts by the author or administrators.
- User Profile: Update user profile, including password and biography (with rich text support).
- User Authentication: JWT-based authentication with bcrypt password hashing.
- Poop Count: A fun feature I implemented while learning React and Tailwind CSS.
- Search: Search for posts, replies, and users. Searching for posts will also query an AI Model, making the responses more useful.
- Tagging: Add tags to posts.
- Admin roles: Allow admins (role assigned from the database) to edit and delete all posts.
- Filtering & Sorting: Ability to filter and sort posts. (partially implemented)
- Swipe to Vote: Similar to Tinder swipe for voting.
- Embed Code Editor: Implement a code editor that can execute simple code snippets.
- More Features: Additional features will be added over time.
The app is designed to provide an intuitive, simple, and customizable experience. To maintain consistency and ease of color theme adjustments, the app is configured to use 5 colors, which are labeled as:
- Primary
- Secondary
- Light
- Dark
- Text
These colors are configurable in tailwind.config.js
with future plans to allow for color customization via the .env
file or database.
Currently, the greeting text (which appears on the home screen) and the post prompt are customizable via the database. There are plans to add more controls by customizing the infos
table in the database.
Both the frontend and backend are included in the same repository for simplicity. They are located in the following directories:
./front-end
: Contains the frontend code../back-end
: Contains the backend code.
The bulk of the code can be found within the src
folder in both sections.
- Set the root directory to
./front-end
. - Set environment variables with the following names
- VITE_AI_API_KEY (Your api key for Gemini)
- VITE_AI_MODEL (The name of AI model to be used, e.g. gemini-1.5-flash)
- VITE_API_TIMEOUT (Set timeout for backend repsonse before throwing an error)
- VITE_BACKEND_URL (URL of the backend server)
- VITE_BASE_URL (URL of the frontend website)
- Build the app: Run
npm run build
. - Start the app: Run
./app
.
-
Set the root directory to
./back-end
. -
Set Environment variables with the following names
- Database informations
- DB_NAME
- DB_PORT
- HOST
- PORT
- PASSWORD
- USER
- FRONTEND_URL
- Database informations
-
Build the app: Run
go build
. -
Start the app: Run
main.go
.