Technical Design Document
Technical Design Document
Web App
Document Title: Technical Design Document
Version: 2.0
Purpose
This document outlines the technical architecture and implementation details for a Reddit-like web
app MVP, using Java for the backend, MySQL for the database, and React.js for the frontend. It
ensures the system meets the functional and non-functional requirements within an 8–12 week
timeline.
Scope
● In Scope: Technical design for core features (user accounts, posts, comments, voting,
subreddits, home feed, search).
● Out of Scope: Advanced features (e.g., real-time updates, complex moderation), scalability
beyond 1,000 users.
System Architecture
Overview
The app uses a client-server architecture with a single-page application (SPA) frontend, a RESTful
API backend, and a relational database (MySQL) for structured data storage.
High-Level Diagram
[User Browser] <--> [Frontend: React SPA] <--> [Backend: Java API] <-->
[Database: MySQL]
| | |
[Vercel Hosting] [AWS Elastic Beanstalk] [AWS RDS
MySQL]
Technology Stack
Frontend
● Framework: React.js
○ Reason: Widely used, component-based, excellent for dynamic feeds and real-time
updates (e.g., voting). Alternatives like Angular or Vue.js were considered, but
React’s ecosystem and simplicity suit an MVP.
● Styling: CSS-in-JS (e.g., Styled Components)
○ Reason: Scoped styles, responsive design.
● State Management: Redux or Context API
○ Reason: Manage user sessions, feed data.
Backend
● Language: Java (Spring Boot)
○ Reason: Robust, enterprise-grade framework with Spring Boot for rapid API
development, dependency injection, and scalability. Java’s strong typing and
ecosystem suit a Reddit-like app’s structure.
● API: RESTful
○ Reason: Simple, interoperable with React frontend.
Database
● Type: MySQL (Relational)
○ Reason: Structured schema for users, posts, and comments; strong relational
support for joins (e.g., posts to subreddits); widely supported by Java (JDBC,
Hibernate).
● Hosting: AWS RDS (Relational Database Service)
○ Reason: Managed MySQL instance, free tier available for small projects.
Hosting
● Frontend: Vercel
○ Reason: Easy React deployment, free tier, custom domain support.
● Backend: AWS Elastic Beanstalk
○ Reason: Simplifies Java app deployment, integrates with RDS, scalable.
Additional Tools
● Authentication: JWT (via Spring Security)
○ Reason: Secure, stateless tokens.
● OAuth: Google OAuth (Spring Security OAuth2)
○ Reason: Simplified social login.
● ORM: Hibernate (Spring Data JPA)
○ Reason: Maps Java objects to MySQL tables.
● Testing: JUnit (backend), Jest (frontend), Postman (API).
Data Model
API Endpoints
User Accounts
● POST /api/register: Create user (email, password, username).
● POST /api/login: Authenticate, return JWT.
● GET /api/profile/:user_id: Fetch profile data.
Posts
● POST /api/posts: Create post (title, content, subreddit_id).
● PUT /api/posts/:id: Edit post.
● DELETE /api/posts/:id: Delete post.
● GET /api/posts/:id: Fetch post details.
Comments
● POST /api/comments: Create comment (post_id, content, parent_comment_id).
● PUT /api/comments/:id: Edit comment.
● DELETE /api/comments/:id: Delete comment.
Voting
● POST /api/votes: Cast vote (target_id, target_type, vote).
● Response: Updated vote count.
Subreddits
● POST /api/subreddits: Create subreddit (name, description).
● GET /api/subreddits/:id: Fetch subreddit posts.
● POST /api/subreddits/:id/join: Join subreddit.
Implementation Notes
Frontend (React.js)
● Routing: React Router (e.g., /, /r/:subreddit, /post/:id).
● Components: PostCard, CommentTree, SubredditList.
● Responsive Design: CSS media queries (<768px mobile, >1024px desktop).
Database (MySQL)
● Schema: Relational tables with foreign keys for strict integrity.
● Queries: Optimized with indexes (e.g., SELECT * FROM posts ORDER BY upvotes DESC).
● Joins: Used for feed (Posts → Subreddits) and comments (Comments → Posts).
Non-Functional Compliance
● Performance: MySQL indexes for fast queries; API responses <500ms for small datasets.
● Security: HTTPS via AWS, SQL injection prevention via prepared statements.
● Reliability: Transactional updates for votes (e.g., ACID compliance in MySQL).
Assumptions
● Initial load: <1,000 users, <10,000 posts/comments.
● AWS free tier (RDS, Elastic Beanstalk) suffices for MVP.
● Basic polling for updates (no WebSockets in MVP).