This project involves building a backend for a social media platform with features for posts, likes, follows, and hashtags. You'll be creating the core functionality that would support a social networking application.
- 📝 Create posts with text content
- 👥 Follow and unfollow other users
- ❤️ Like posts
- #️⃣ Tag posts with hashtags
You must implement CRUD (Create, Read, Update, Delete) operations for all entities. Additionally, implement these specific endpoints:
-
/api/feed- Show users their personalized content stream 🌊- Returns a paginated list of posts from users the current user follows
- Posts should be sorted by creation date (newest first)
- Include post content, author details, like count, and hashtags
- Support pagination with
limitandoffsetquery parameters
-
/api/posts/hashtag/:tag- Find posts by hashtag 🔍- Returns all posts containing the specified hashtag
- Support case-insensitive hashtag matching
- Include post content, author details, and like count
- Implement pagination with
limitandoffsetparameters
-
/api/users/:id/followers- Get user's followers 👥- Returns a list of users who follow the specified user
- Include follower's basic profile information
- Support pagination with
limitandoffsetparameters - Sort followers by follow date (newest first)
- Include total follower count in response
-
/api/users/:id/activity- View user activity history 📜- Returns a chronological list of user activities
- Include posts created and likes given
- Show follow/unfollow actions
- Support filtering by activity type and date range
- Implement pagination for large activity histories
- Important: If the test script fails to run, your submission will not be considered for evaluation
⚠️ - The shell script should test all CRUD operations for each entity and all the endpoints defined above
- Each endpoint must have its own test case in the shell script
- Test coverage is mandatory for all endpoints
- Test results should be clearly logged and visible in the console output
The project includes a test.sh script that provides an interactive testing interface with the following structure:
-
Main Menu
- List of all entities
- Exit option
-
Entity Submenus Each entity has its own submenu with CRUD operations:
- Get all
- Get by ID
- Create
- Update
- Delete
- Back to main menu
-
Special Endpoint Tests The script includes tests for all the specific endpoints mentioned above, in addition to the standard CRUD operations on entities.
Note: The test script follows a consistent structure for all entities and endpoints. Each new entity should follow the same submenu pattern as the existing implementations.
- Follow TypeORM entity structure (see
src/entities/User.ts) for all entities ⚠️ Do not use thesynchronize: trueoption in TypeORM - use migrations instead (seesrc/migrations/1713427200000-CreateUserTable.ts)- Use appropriate column types and decorators
- Add Joi validations for all entities to ensure data integrity
- Follow the API pattern established in the codebase for consistency
- Migration commands:
npm run migration:generate- Generate new migrationsnpm run migration:run- Apply pending migrationsnpm run migration:revert- Rollback last migration
- Create proper relationships between entities
- Implement efficient indexes for quick queries ⚡
- Use composite indexes where needed
- Document your indexing decisions 📚
- ✅ Implement all required entities
- ✅ Define proper relationships
- ✅ Write efficient queries
- ✅ Plan smart indexing
- ✅ Maintain code quality
- ✅ Keep structure consistent
⚠️ Do not use LLMs for this assignment- All code should be written by you
- Solutions should demonstrate your own understanding and skills
To submit your completed assignment:
- Fork this repository to your personal GitHub account
- Complete the assignment in your forked repository
- Push all your changes to your forked repository
- Send the link to your forked repository to your assignment reviewer
Important Notes:
- Ensure your repository is public so reviewers can access it
- Make sure all the code is committed and pushed before submitting
- Do not create pull requests to the original repository
- Fill in the existing
DESIGN.mdfile with:- Database schema design and entity relationships
- Indexing strategy for performance optimization
- Scalability considerations and solutions
- Any other important design considerations
⚠️ Ensure migrations run correctly - submissions which fail the migration script will be disqualified
If selected for an interview, you will be asked to:
- Extend this assignment with additional features in real-time
- Answer questions about your code, design patterns, and technical decisions
Please have your development environment fully configured and ready before the interview session.
- Fork this repository to your personal GitHub account
- Clone your forked repository to your local machine
- Run
npm install - Run migrations with
npm run migration:runto set up the database - Start the server with
npm run dev - Use SQLite Viewer Extension in VS Code to view the database, or any other viewer if not using VS Code
Made with ❤️ by the VI team